Make Your First API Call
If you are testing out the Dacast API for the first time, we recommend that you use an online tool such as PostMan, or an application such as Advanced REST Client to play with the APIs and get a good feel for how they work.
Once you have got your API key, you can use this to authenticate calls to our APIs.
The base URL for all calls is https://developer.dacast.com.
You will then need to know:
- What endpoint you want to call.
- What action you want to perform.
- What parameters you need to provide.
These can all be found in the API reference guide here.
For instance, to create a new livestream channel, you need:
- The /v2/channel endpoint.
- The POST action (to create a livestream),
- The minimal parameters needed are:
1-Title - the name of the channel.
2-Description - a short description of the channel.
3-Region - where is your encoder located in the world, so that the closest server can be used to feed the broadcast in.
4-Rendition_count - the number (between 1 and 5) of resolutions you will provide in the broadcast.
These parameters should all be provided in a JSON object body payload.
So, using PostMan as an example:
First, create a new collection.
Under the Variables tab, you can define common variables that you can use in place of looking for those values over and over again, as well as change them globally instead of having to change them in multiple locations.
The common values to define are BASE_URL and API_KEY:
Make sure to set the API key to your own API key, and hit “Save” before moving on otherwise you will not be able to access the variables!
- Then, you’ll head to “Add a request to start working” on the left hand menu underneath the collection you created:
- Set the Request Method to POST, the URL to {{BASE_URL}}/v2/channel and go to the Headers tab, insert X-Api-Key with a value of {{API_KEY}} and X-Format with a value of default:
If you correctly set the variables, these will be highlighted as orange values; if you did not set them correctly, then they will be red. If they are red, go back to the collection variables tab and check that they are set, and hit “Save”.
- Go to the “Body” tab, select “Raw”, and select JSON from the dropdown box to the right of the options, then enter your parameters as a JSON object:
- You can use a tool like The JSON Validator to validate your JSON formatted correctly.
- When done, hit the big blue Send button:
- If all is well, you should get a response back containing the details of the channel in JSON format, including the ID that you can then use to find the channel in the future using other API commands!
You’ve just made your first call to the Dacast API. Now you can go on to build out your application on top of our world-class, best-in-breed video platform!
Updated 8 months ago