How to make API calls with Postman and Livepeer Video Services
Tags: tutorial, programming, postman, livestreaming
Published: 2022-03-15 22:18:57

APIs are essential when it comes to software development. It allows softwares to communicate with each other to exchange information. In the beginning, when learning to make API calls, it can be a challenge using tools such as cURL in the terminal, **FETCH** in the frontend or backend option such as **Express**. Postman is a great tool for understanding the process of making API calls and getting feedback on the response of those calls. It provides a visual interface and allows developers to get a sense of the workflow which can provide easier transitions to using other tools such as cURL or Express.

In this tutorial, we will be using [Postman](https://www.postman.com/) to make API requests to [Livepeer Video Services](https://livepeer.com/) to get a better understanding on building an application similar to Twitch or YouTube. The Livepeer Video Services API consists of the standard features for users such as creating new live streams, recording the streams and getting a list of their streams. By leveraging [Livepeer's decentralized network](https://livepeer.org/) for transcoding, it will be easier and cost effective to scale for in the future.

**Step 1:** Get access to Postman
- Go to [Postman's website](https://www.postman.com/) and sign up for a free account.

![Postman website](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/983f8k575k33h80y7131.png)
- You can use their web browser tool or download the desktop version. For this tutorial, we will use the desktop version with Mac OS, but it is also available for Windows and Linux.

**Step 2:** Get access to Livepeer Video Services
- Go to [Livepeer Video Services](https://livepeer.com/) and sign up for a free account.

![Livepeer Video Services dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8e135md3hb2xg1sxtjec.png)

![Livepeer Video Services dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1n64xb31z9s4arsknlft.png)

Now that we have access to these two services, let's start interacting with them.

**Step 3:** Get an API key
- In your Livepeer dashboard, tap the developers tab and select API keys
- Click the button that says **Create Key**
- Then give your key a name and click **Create**

![Livepeer Video Services dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a6q1qqrzmvfniws01to6.png)


![Livepeer Video Services dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vjiin9xdgnsv71evwt59.png)

With the API key, we will start going through the **Stream** section of Livepeer Video Services' [API Reference](https://livepeer.com/docs/api-reference/stream/post-stream). The reference uses the cURL command but we will do this using Postman instead.

To learn more about streaming Livepeer Video Services with the cURL command, visit the tutorial [How To Stream With Livepeer Video Service's RTMP API](https://livepeer.com/blog/streaming-with-rtmp-api)

**Step 4**: Launch the Postman desktop app
- Click the **+** icon under the Reports tab to start a new request or select **New Tab** under the file menu

![Postman dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b5h1t4lspmvmwuevalax.png)

**Step 5:** Create a stream

- Select the **POST** option and the paste in Livepeer Video Services' base URL for streaming **`https://livepeer.com/api/stream`**

![Postman dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pcqbx3wewif0mw5n17gw.png)
- Then underneath the URL, click on the **Authorization** tab, and select **Bearer Token** as the type
- Copy and paste your API key from Livepeer Video Services

![Postman dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xminn4qcjzcyfdnuiukg.png)

- Now select the **Body** tab and then underneath select the **raw** radio button
- Then click the the Text drop down menu and select the JSON option
- In the text box field below, paste the following code which is from the [Livepeer Video Services API reference docs](https://livepeer.com/docs/api-reference/stream/post-stream). You can change the **name** to whatever you want as this is for the name of your stream

![Stream code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rdd0sh95osq4f3x6rc40.png)


![Postman dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/02d8wwzr7z14rtbdnstb.png)

- Now click on the **Send** button and you should receive a confirmation that it went through with a 201 status
- Scroll down in the response and copy the id for the stream that was just created. It should be under renditions


![Postman dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zaem5jugql8663bvb35q.png)

- Check the Livepeer Video Services' dashboard and the stream that you just created should come up


![Livepeer Video Services dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6t0p1k37ghzjw90oxj3g.png)

Now let's get the stream we just created

**Step 6:** Retrieve a stream

- In the Postman app, we will change from **POST** to **GET**, and in the URL paste in **`https://livepeer.com/api/stream/{id}`** and replace **`{id}`** with the id we copied from our response earlier.
- Click the blue send button and you should get back a 200 status with the response including the parameters of the stream


![Postman dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gwk20t0bdkoexydmqrah.png)

**Step 7:** Get a list of streams

- In order to get a list of streams, follow **Step 5** to create a second stream so that there is more than one stream
- Give it a name of your choice, but for this example, it will be named _Second Stream_


![Postman dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hc9eze52yjhevnsnnc70.png)

- Go back to Livepeer Video Services' dashboard and you should see the **Second Stream** appear


![Livepeer Video Services dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/siv4bctnc2ejpece8eh6.png)

- Now that we have multiple streams, go back to the Postman app and retrieve them
- Similar to **Step 6** we are changing **POST** to **GET** and insert the base URL for retrieving multiple streams **`https://livepeer.com/api/stream?streamsonly=1`**
- Remember that the body should have the **none radio button** selected since we are not passing in any data
- Click the blue send button and it should confirm with a response of status 200 meaning that the request went through and a response back with a list of your streams


![Postman dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hgpcfwg3lw3wkz40qly1.png)

Step 8: Toggling a stream
- Replace **GET** with **Patch** and insert the URL for for toggling recording **`https://livepeer.com/api/stream/{id}/record`** and replace **`{id}`** with the one you have at the end of **Step 5**
- Now we will toggle the recording on by putting the following in body, just as we did in **Step 5**

`{
"record": true
}`
- Click the blue send button and it should confirm with a response of status 204 meaning that the request went through


![Postman dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9whenklbprjf36uywq34.png)

**Step 9:** Update a stream
- Select **Patch** and insert the URL for updating a stream **`https://livepeer.com/api/stream/{id}`** and replace **`{id}`** with the one you have at the end of **Step 5**
- Now we will not have the recording on and suspend the stream by putting the following in body, just as we did in **Step 5**

`{
"record": false,
"suspend": true
}`

- Click the blue send button and it should confirm with a response of status 204 meaning that the request went through


![Postman dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k09lhvzfssyv11ul7m07.png)

**Step 10:** Delete a stream

- We will delete **Second Stream** by replacing **Patch** with **Delete** and insert the URL for deleting a stream **`https://livepeer.com/api/stream/{id}`** and replace the **`{id}`** you have at the end of **Step 5**
- Click the blue send button and you should get a status 204 as a response to confirm the stream has been deleted


![Postman dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x2dybda1lzm3rdak7grt.png)

- Go back to Livepeer Video Services' dashboard to confirm that the stream has been deleted


![Livepeer Video Services dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s4wxljeir3e7do8pacrn.png)

Now that you are able to use Postman to interact with Livepeer Video Services' API, take your skills to another level using cURL. To learn more, check out the tutorial How to Stream With Livepeer Video Service's RTMP API.


[How to Stream with RTMP API]
(https://livepeer.com/blog/streaming-with-rtmp-api)