HTTP API Quick Start
This article shows how to log in to the Alta HTTP API and publish a channel with curl. For an overview of roles, response codes, and conventions, read HTTP API.
Requirements
Section titled “Requirements”- Requests go to the API Server (default port
8100), not to the OTT Server. Read more HTTP Server. - You need a user of the Alta web interface with the
adminrole. Read more Users.
Log In
Section titled “Log In”The API supports two methods:
- Bearer token: Get a token with
/api/loginand send it in theAuthorization: Bearer <token>header. - HTTP Basic: Send the login and the password of the user in every request.
Log in:
curl -sS -X POST 'http://alta.example.com:8100/api/login' \ -H 'Content-Type: application/json' \ -d '{"id": "admin", "password": "PASSWORD"}'The response is the token as plain text. Save it in a variable:
TOKEN=$(curl -sS -X POST 'http://alta.example.com:8100/api/login' \ -H 'Content-Type: application/json' \ -d '{"id": "admin", "password": "PASSWORD"}')Check the token with the application information request:
curl -sS -H "Authorization: Bearer $TOKEN" 'http://alta.example.com:8100/api/about'With HTTP Basic, use the -u option of curl instead of the token:
curl -sS -u 'admin:PASSWORD' 'http://alta.example.com:8100/api/about'Publish a Channel
Section titled “Publish a Channel”A channel needs a receiver with the input stream. Create the receiver first, then the channel that uses it.
1. Create a receiver:
curl -sS -X POST 'http://alta.example.com:8100/api/ott/receiver' \ -H "Authorization: Bearer $TOKEN" \ -H 'Content-Type: application/json' \ -d '{ "id": "news-source", "name": "News source", "source": "udp://239.1.1.1:1234", "enable": true }'2. Create a channel with one variant:
curl -sS -X POST 'http://alta.example.com:8100/api/ott/channel' \ -H "Authorization: Bearer $TOKEN" \ -H 'Content-Type: application/json' \ -d '{ "id": "news", "name": "News", "enable": true, "variants": { "main": { "enable": true, "receiver": "news-source" } } }'Both requests return 204 with an empty body.
3. Open the playlist in a player. The playlist is served by the OTT Server, not by the API Server:
http://alta.example.com:<ott-port>/news/index.m3u8The OTT port is set in Settings → HTTP Servers. Read more about playlist addresses in URL Format for HLS Access.
4. Check the viewers:
curl -sS -H "Authorization: Bearer $TOKEN" 'http://alta.example.com:8100/api/ott/sessions/status'To remove the example, delete the channel first, then the receiver:
curl -sS -X DELETE -H "Authorization: Bearer $TOKEN" 'http://alta.example.com:8100/api/ott/channel?id=news'curl -sS -X DELETE -H "Authorization: Bearer $TOKEN" 'http://alta.example.com:8100/api/ott/receiver?id=news-source'Next Steps
Section titled “Next Steps”- Channels: variants, archive storage, access control, start and stop.
- Receivers: sources and import from an M3U playlist.
- Authorizers: protect channels with IP rules or Securetoken.