HTTP Reference
StreamAPI's HTTP API is a REST-like protocol. Requests are always either GET or POST methods as specified per API function. Replies are always formatted using XML. API requests originate at your server, not from the end user's web browser. We offer sample code and official client libraries for only some languages, although using our interface is trivial in virtually any language.
All API requests must include a minimum of three parameters: key (API key), sig (signature), and rid (request ID). The API key identifies your account, the signature lets us verify that the request is legitimate and has not been tampered with, and the rid prevents the replaying of previous requests. The rid is a number that you generate and must increase with every request.
- API and Secret Keys
- Signing Your Requests
- Generating the Request ID
- Create Session
- Get Live Session Info
- List Live Sessions
- Get public host ID
- Get private host ID
- List Video Recordings
1) API Key and Secret key
When you sign up for a StreamAPI account you are assigned a Secret Key and an API Key. You can see these in your API Settings page from within your account. These are to be kept private and should never be shared.
API Settings
Signing Your Requests
A new signature must be generated for every API request. The signature is an MD5 hash of the current request values, request_id, and your secret key. Generated as follows, in pseduo code: md5_hex(concatenate(request_param_values_in_alphabetical_order_of_param_names,secret_key,rid))
A typical example of a create session (with optional parameters username and site_user_id) request is shown here:
Parameters
Request
Response
2) Generating the Request ID
The request ID (rid) parameter must increase with every request. The easiest way to generate it is by using the current system time in milliseconds.
Example code in Java, Python, and Perl
Status Codes
All API responses include status code (<code></code>). Anything other than 0 (zero) is an error. When a request is not successful a human readable message will be available, such as <msg>Invalid API key</msg>.
3) Create Session
Description
Creates a new StreamAPI session which includes a private_hostid (for broadcasters) and public_hostid (for viewers).
URL
http://api.streamapi.com/service/session/create
Method
POST
Parameters
Required
- key
- sig
- rid
Optional
- site_user_id [0-9] Overrides auto-generated public_hostid with your site's user ID
- username [a-zA-Z0-9] Displayed in UserList component and as overlay in video components.
- fme_key [a-zA-Z0-9] To create a live session using a different flash media encoder (such as the Adobe Flash Media Live Encoder), you can pass in a fme_key value, which is a secret unique value that you can set for that user. The fme_key value that is set in StreamAPI and that your user will need to enter in the URL will need to be rtmp://fme.streamapi.com/hd_receiver/[public_host_id]-[fme_key_value] For example, if the fme_key value for a user is f1b8221d2b69 and the user's public host id is 1000016132, the real fme_key that StreamAPI will set is 1000016132-f1b8221d2b69 and the RTMP URL will be rtmp://fme.streamapi.com/hd_receiver/1000016132-f1b8221d2b69
- is_video_private To create a live session that will allow only authenticated viewers to see the live video and join the live sesion, you can pass in is_video_private with a value of true
Status Codes
| Code | Description |
| 1 | Missing required parameter(s) |
| 8 | No user found |
| 46 | No session found |
| 100 | Unknown Error |
| 200 | Invalid API key |
| 201 | Cannot request this call for user that was not created by API caller |
| 202 | Invalid sig (or signature) value |
| 203 | Invalid request ID value |
4) Get Live Session Info
Description
Fetch information about a particular session using its public_hostid.
URL
http://api.streamapi.com/service/session/live
Method
GET
Parameters
Required
- key
- sig
- rid
- public_hostid [0-9]
Optional
NONE
Example response
Status Codes
| Code | Description |
| 1 | Missing required parameter(s) |
| 8 | No user found |
| 100 | Unknown Error |
| 200 | Invalid API key |
| 202 | Invalid sig (or signature) value |
| 203 | Invalid request ID value |
5) List Live Sessions
Description
Fetch a list of all sessions that are currently streaming. Note: There is up to a 60 second delay from the time a session begins streaming to the time it will show up in this list.
URL
http://api.streamapi.com/service/session/live/list
Method
GET
Parameters
Required
- key
- sig
- rid
Optional
NONE
Example response
Status Codes
| Code | Description |
| 1 | Missing required parameter(s) |
| 100 | Unknown Error |
| 200 | Invalid API key |
| 202 | Invalid sig (or signature) value |
| 203 | Invalid request ID value |
6) Get public host ID
Description
A helper function that tells you what the public host ID is for a particular private host ID.
URL
http://api.streamapi.com/service/host/id/public
Method
GET
Parameters
Required
- key
- sig
- rid
- private_hostid [A-Z0-9]
Optional
NONE
Example response
Status Codes
| Code | Description |
| 1 | Missing required parameter(s) |
| 8 | No user found |
| 46 | No session found |
| 100 | Unknown Error |
| 200 | Invalid API key |
| 201 | Cannot request this call for user that was not created by API caller |
| 202 | Invalid sig (or signature) value |
| 203 | Invalid request ID value |
7) Get private host ID
Description
A helper function that tells you what the private host ID is for a particular public host ID.
URL
http://api.streamapi.com/service/host/id/private
Method
GET
Parameters
Required
- key
- sig
- rid
- public_hostid [0-9]
Optional
NONE
Example response
Status Codes
| Code | Description |
| 1 | Missing required parameter(s) |
| 8 | No user found |
| 46 | No session found |
| 100 | Unknown Error |
| 200 | Invalid API key |
| 201 | Cannot request this call for user that was not created by API caller |
| 202 | Invalid sig (or signature) value |
| 203 | Invalid request ID value |
8) Get live video recordings
Description
List live session recordings for a site, host, or date range
URL
http://api.streamapi.com/service/video/list
Method
GET
Parameters
Required
- key
- sig
- rid
Optional
- public_hostid [0-9]
- start_date [0-9] - milliseconds Start creation date (in milliseconds) of videos to be retrieved.
- end_date [0-9] - milliseconds Latest creation date (in milliseconds) of videos to be retrieved.
Example response
Status Codes
| Code | Description |
| 1 | Missing required parameter(s) |
| 8 | No user found |
| 46 | No session found |
| 100 | Unknown Error |
| 200 | Invalid API key |
| 202 | Invalid sig (or signature) value |
| 203 | Invalid request ID value |
8) Get layout themes
Description
List layout themes
URL
http://api.streamapi.com/service/theme/list
Method
GET
Parameters
Required
- key
- sig
- rid
Optional
- None
Example response
Status Codes
| Code | Description |
| 1 | Missing required parameter(s) |
| 46 | No session found |
| 100 | Unknown Error |
| 200 | Invalid API key |
| 202 | Invalid sig (or signature) value |
| 203 | Invalid request ID value |