Tutorials · 3 min read

Create a Live Stream

Create a Live Stream

Live streaming your content is a great way to connect with your audience. In this tutorial, we'll walk through he steps you need to follow to set up a video livestream.

Doug Sillars

May 4, 2020

Live streaming your content is a great way to connect with your audience. In this tutorial, we'll walk through the steps you need to follow to set up a video livestream.

Note: we have example code of setting up a live stream in the browser, with Zoom and with OBS.

Here is the direct link to the technical docs to create a live stream.

In order to establish a video livestream, you must first create a livestream container at api.video. Then you can begin streaming with the tool of your choice. In this example, the live stream will be created with OBS, free and open source software for video streaming.

Creating Live Stream

Step 1: Authenticate

You need an access_token in order to create and upload a video.

You will need your API key to obtain the access_token. You can find your API key in your dashoard.

This tutorial uses the sandbox endpoint. To upload your video in production, simply replace all sandbox.api.video instances with ws.api.video.

First, call the authentication endpoint and get your access token.

Example - Curl Request

javascript

Example - Http Request

javascript

Example - Json Response

javascript

Step 2: Create the Live Stream

Now we create the live stream. In the JSON parameter, feel free to edit the name of the live stream from "Your Stream Name" to whatever you want to name your stream.

Example - Curl Request

javascript

Example - Json Response

javascript

Now the server is ready to accept our live stream, and once broadcast begins (JSON above shows broadcasting:false), it will be viewable on the urls listed in the JSON response.

Connecting Live Video

The JSON response above lists your live stream's streamKey, which will be needed in OBS to connect your video to the server.

in the OBS application:

  1. Esablish a source. In the sources section, choose a video feed to share. You could choose to share your screen, or to share your camera (on a Mac: Video Capture Device, and then in the "Device" dropdown choose the camera). You should now see the video source in the main OBS window.
  2. Connect OBS to api.video. Under Settings, choose Stream. You'll see a choice for service - choose custom.
  3. The server should be rtmp://broadcast.api.video/s and the streamKey is the value you received in the Json when you created the stream. Click OK to accept the changes.
  4. Press Start Streaming.
  5. Share the embed, iFrame, so that others can watch your stream!

Extra Step: The default video poster that your users will see is api.video branded. You can update the thumbnail with an image of your choice:

javascript

Conclusion

That's all it takes. We've walked through the process of creating a livestream at api.video, and then how to connect that video's streamKey into OBS. Using OBS, we are then able to broadcast video to all our viewers, who can watch using the player (oriframe) url provided by the api.

Give it a try, and let us know how it worked for you in our community forum. We're also there to help out if you run into any difficulties.

Try out more than 80 features for free

Access all the features for as long as you need.
No commitment or credit card required

Video API, simplified

Fully customizable API to manage everything video. From encoding to delivery, in minutes.

Built for Speed

The fastest video encoding platform. Serve your users globally with 140+ points of presence. 

Let end-users upload videos

Finally, an API that allows your end-users to upload videos and start live streams in a few clicks.

Affordable

Volume discounts and usage-based pricing to ensure you don’t exceed your budget.