REST API guide is one of the missing guides that our lovely users need to get started. In designing Ant Media Server, we’re trying to make almost everything configurable and accessible through REST API. Actually, we need to do this in order to develop a web management panel. Before starting, let’s quickly define the REST API.
What is REST API?
A REST API (also known as RESTful API) is an application programming interface (API or web API) that conforms to the constraints of REST architectural style and allows for interaction with RESTful web services. REST stands for representational state transfer and was created by computer scientist Roy Fielding.
We quickly remembered what the REST API is. So I can say that by using REST API you can almost do anything on Ant Media Server. Here is an abstract Ant Media Server API list of available methods in REST API
- CRUD(Create/Read/Update/Delete) Operations on
- CRUD Operations on VoD streams
- Add/Remove RTMP Endpoints to the Streams
- Authorize/Revoke Social Endpoints
- Change Settings(Bitrates, Recording, Enable/Disable Object Detection, VoD Folder Path) via root app
For the full REST API Reference, please visit the https://antmedia.io/rest
For the rest of this guide, we try to explain how to call REST methods, give some samples and mention about Security (IP Filtering)
How to Call REST API Methods
All REST methods are the binding
rest path of the app. Let me give a sample. Ant Media Server Community Edition has
WebRTCApp by default. On the other hand, Enterprise Edition has
WebRTCAppEE by default. The
LiveApp REST methods (for instance broadcast’s get method) are available as follows
Let’s make an example with the so-famous
curl tool. By the way, Postman is another great tool for testing purposes. It also generates code snippets in several programming languages such as Java, PHP, Go, Python, etc.
According to REST Reference, we should call
create the method is as follows.
Important Note: Please keep in mind that the REST interface only responds to the calls that are made from 127.0.0.1 by default. If you call from any other IP Address, it does not return. For allowing more IP Addresses, take a look at the Security section later in this post.
curl -X POST
-H ‘content-type: application/json’
We can provide a
Broadcast object as a parameter in JSON format. Ant Media Server returns created broadcast object in JSON format again. The most critical field in the returned response is
streamId field in JSON. We use
streamId in getting broadcast.
Getting a broadcast is easier. You just need to add the
streamId as a query parameter to
streamId the variable as follows.
curl -X GET
get method returns the Broadcast object as
create method. This is the sample JSON response that get method returns.
REST API Reference
The samples below show how to call the REST methods in an easy way. In order to have a look at all methods and their parameters, you can study the REST API Reference at https://antmedia.io/rest which has a good look and feel. Thanks to the Swagger.
Security – IP Filtering
Ant Media Server generally runs behind an application server so you want Ant Media Server to respond to the calls that are made from specific IP ranges. By default, Ant Media Server only responds to the calls that are made from 127.0.0.1.
In order to add IP ranges, you should go to the Settings of the app in the Web Management Panel and add
IP Ranges in CIDR notation. You can add multiple comma-separated IP Address Ranges.
You can use the REST API of Ant Media Server as explained above. If you’re using the community edition and have questions, you can ask the community or email@example.com (a reply will be provided with the best effort). If you’re an enterprise user, you can ask firstname.lastname@example.org or to the specified channel allocated for you.
I hope this blog post help some guys get started easily
Ant Media Server API references.
You can start using Ant Media Server for free with all its features!
You can download native Android and iOS WebRTC SDKs and integrate them into your applications for free!
Ant Media Server Github Wiki