REST API (Beta)
The REST APIs provided by OME allow you to query or change settings such as VirtualHost and Application/Stream.
The APIs are currently beta version, so there are some limitations/considerations.
- Settings of VirtualHost can only be viewed and cannot be changed or deleted.
- If you add/change/delete the settings of the App/Output Profile by invoking the API, the app will be restarted. This means that all sessions associated with the app will be disconnected.
- The API version is fixed with v1 until the experimental stage is complete, and the detailed specification can be changed at any time.
By default, OvenMediaEngine's APIs are disabled, so the following settings are required to use the API:
Set the
<Port>
to use by the API server. If you omit <Port>
, you will use the API server's default port, port 8081
.
<Server version="8">
...
<Bind>
<Managers>
<API>
<Port>8081</Port>
<!-- If you need TLS support, please uncomment below:
<TLSPort>8082</TLSPort>
-->
</API>
</Managers>
...
</Bind>
...
</Server>
<Host>
sets the Host name and TLS certificate information to be used by the API server, and <AccessToken>
sets the token to be used for authentication when calling the APIs. You must use this token to invoke the API of OvenMediaEngine.<Server version="8">
...
<Managers>
<Host>
<Names>
<Name>*</Name>
</Names>
<!--
If you want to set up TLS, set it up by referring to the following:
<TLS>
<CertPath>airensoft_com.crt</CertPath>
<KeyPath>airensoft_com.key</KeyPath>
<ChainCertPath>airensoft_com_chain.crt</ChainCertPath>
</TLS>
-->
</Host>
<API>
<AccessToken>your_access_token</AccessToken>
</API>
</Managers>
</Server>
If you face a CORS problem by calling the OME API on your browser, you can set
<CrossDomains>
as follows:<Server version="10">
...
<Managers>
<Host>
<Names>
<Name>*</Name>
</Names>
</Host>
<API>
...
<CrossDomains>
<Url>*.airensoft.com</Url>
<Url>sub-domain.airensoft.com</Url>
<Url>http://http-only.airensoft.com</Url>
</CrossDomains>
</API>
</Managers>
</Server>
If protocol is omitted like
*.airensoft.com
, both HTTP and HTTPS are supported.In this manual, the following format is used when describing the API.
get
http://<OME_HOST>:<API_PORT>
/<VERSION>/<API_PATH>[/...]
<VERSION>/<API_PATH>
This means the IP or domain of the server on which your OME is running.
This means the port number of the API you set up in
Server.xml
. The default value is 8081.Indicates the version of the API. Currently, all APIs are v1.
Indicates the API path to be called. The API path is usually in the following form:
/resource-group[/resource[/resource-group[/resource/...]]][:action]
resource
means an item, such as VirtualHost
or Application
, and action
is used to command an action to a specific resource, such as push
or record
.
// Single data request example
// << Request >>
// Request URI: GET /v1/vhosts/default
// Header:
// authorization: Basic b21lLWFjY2Vzcy10b2tlbg==
// << Response >>
// HTTP Status code: 200 OK
// Response Body:
{
"statusCode": 200,
"message": "OK",
"response": ... // Requested data
}
// Multiple data request (Status codes are the same)
// << Request >>
// Request URI: POST /v1/vhost/default/apps
// Header:
// authorization: Basic b21lLWFjY2Vzcy10b2tlbg==
// Request Body:
[
{ ... }, // App information to create
{ ... }, // App information to create
]
// << Response >>
// HTTP Status code: 200 OK
// Response Body:
[
{
"statusCode": 200,
"message": "OK",
"response": ... // App1
},
{
"statusCode": 200,
"message": "OK",
"response": ... // App2
}
]
// Multiple data request (Different status codes)
// << Request >>
// Request URI: POST /v1/vhost/default/apps
// Header:
// authorization: Basic b21lLWFjY2Vzcy10b2tlbg==
// Request Body:
[
{ ... }, // App information to create
{ ... }, // App information to create
]
// << Response >>
// HTTP Status code: 207 MultiStatus
// Response Body:
[
{
"statusCode": 200,
"message": "OK",
"response": ... // App1
},
{
"statusCode": 404,
"message": "Not found"
}
]
VirtualHost
settings created by Server.xml
cannot be modified through API. This rule also applies to Application
/OutputStream
, etc. within that VirtualHost. So, if you call a POST/PUT/DELETE API for VirtualHost
/Application
/OutputProfile
declared in Server.xml
, it will not work with a 403 Forbidden
error.
Last modified 7d ago