Livestream API

In this guide, you will learn how to build a live streaming platform with Crunch's live streaming.

Authentication

Every request to the API is authenticated via an Access Token and Secret Token. Token-based authentication works by providing the Access Token Secret token in the API request. For More Information Click Here.

									--user $ACCESS_TOKEN_ID:$SECRET_KEY
								

Webhook

Crunch uses webhooks to notify your application about things that happen asynchronously, apart from the API request-response cycle. Click Here.

Check all live stream Webhook events here

GET Regions

Get all the available regions to start a live stream. Choose the region closest to you for optimum stream speed

GET Regions

https://api.crunchmediaworks.com/live/v1/regions

Response Parameters

ParameterTypeDescription
dataarrayList of regions supported for creating live stream session
messagestringStatus message of the API

											
												curl -L -X GET 'https://api.crunchmediaworks.com/live/v1/regions' \
												-u $ACCESS_TOKEN_ID:$SECRET_KEY
											
										
											
											
										

Create LiveStream

POST Create Live Stream

https://api.crunchmediaworks.com/live/v1/live-streams/session

Body Parameters

ParameterTypeDescription
regionstringregion value must be one of the value from the region API which is allocated for the user. Providing invalid region value will throw error while creating session
namestringName of the session
inputstringEnum: "RTMP_PUSH" "RTMP_PULL" "RTMPS_PUSH" "RTMPS_PULL" RTMP input source type
modestringEnum: "HA" "NORM" Session Mode supports two input class: HA and NORM. HA - Provides support for two pipeline, Where one pipeline acts as main and second pipeline acts as a backup. Client must handle the switching when any one of the pipeline fails. NORM - Single pipeline support
input_presetobject
Input stream presets
codecstringValue: "H264" Codec
resolutionstringValue: "SD" "HD" "FULL_HD" Resolution of the input stream
bitratestringValue: "MAX_10_MBPS" "MAX_20_MBPS" Bitrate of the input stream
output_modestringEnum: "RTMP_PULL" "RTMPS_PULL"
RTMP output mode type
input_source_astringInput Source A is a RTMP or RTMPS Endpoint, Input Source A is required if the input source is RTMP_PULL or RTMPS_PULL
input_source_bstringInput Source B is a RTMP or RTMPS Endpoint, Input Source B is required if the mode HA and if the input source is RTMP_PULL or RTMPS_PULL
output_destination_astringOutput Destination A is a RTMP or RTMPS Endpoint, Output Destination A is required if the output mode is RTMP_PUSH or RTMPS_PUSH
output_destination_bstringOutput Destination B is a RTMP or RTMPS Endpoint, Output Destination B is required if the mode HA and if the output mode is RTMP_PUSH or RTMPS_PUSH
enable_input_recordbooleanIf input record is enabled, the live stream will be recorded and once the live stream is completed successfully, user will be able to download the recorded file.
is_scheduledbooleanUser can schedule live session if 'is_scheduled' is set to true.
timezonestringTimezone value expects a tz database which is also known as tzdata. Eg: 'America/New_York'
scheduled_atstringScheduled_At expects datetime string in 'YYYY-MM-DD HH:MM' format based on the user timezone. Eg: '2021-06-24 22:02'

Response Parameters

ParameterTypeDescription
idstringSession ID
regionstringRegion where the session has been created
namestringName of the session
inputstringEnum: "RTMP_PUSH" "RTMP_PULL" "RTMPS_PUSH" "RTMPS_PULL" RTMP input source type
modestringEnum: "HA" "NORM" Session Mode selected while creating the session
input_presetobject
Input stream presets
codecstringValue: "H264" Codec
resolutionstringValue: "SD" "HD" "FULL_HD" Resolution of the input stream
bitratestringValue: "MAX_10_MBPS" "MAX_20_MBPS" Bitrate of the input stream
output_modeobjectEnum: "RTMP_PULL" "RTMPS_PULL" RTMP output mode type
enable_input_recordbooleanIf input record is enabled, the live stream will be recorded and once the live stream is completed successfully, user will be able to download the recorded file.
statusstringStatus describes the current state of the session. Session can be any one the following values : 'PENDING', 'PROVISIONING', 'ALLOCATED', 'READY', 'STOPPING', 'STOPPED', 'TERMINATED', 'ERROR', 'SCHEDULED', 'CANCELLED'
is_scheduledbooleanUser can schedule live session if 'is_scheduled' is set to true.
timezonestringTimezone value is a tz database which is also known as tzdata. Eg: 'America/New_York', Value will be empty if is_scheduled is false
scheduled_atstringScheduled_At is a datetime string in 'YYYY-MM-DD HH:MM' format based on the user timezone. Eg: '2021-06-24 22:02', Value will be empty if is_scheduled is false

											
												curl -L -X POST 'https://api.crunchmediaworks.com/live/v1/live-streams/session' \
												-H 'Content-Type: application/json' \
												-u $ACCESS_TOKEN_ID:$SECRET_KEY \
												-d '{
												    "region": "ap-southeast-1",
												    "name": "test_1",
												    "input": "RTMP_PUSH",
												    "mode": "NORM",
												    "input_preset": {
												       "codec": "H264",
												       "resolution": "HD",
												       "bitrate": "MAX_10_MBPS"
												    },
												    "output_mode": "RTMP_PULL",
												    "enable_input_record": false
												}'
											
										
											
											
										

Get Stream Session Details

GET Session

https://api.crunchmediaworks.com/live/v1/live-streams/session/{id}

Body Parameters

ParameterTypeDescription
idstringThe session id of the session to fetch

Response Parameters

ParameterTypeDescription
idstringSession ID
regionstringRegion where the session has been created
namestringName of the session
inputstringEnum: "RTMP_PUSH" "RTMP_PULL" "RTMPS_PUSH" "RTMPS_PULL" RTMP input source type
modestringEnum: "HA" "NORM" Session Mode selected while creating the session
input_presetobject
Input stream presets
codecstringValue: "H264" Codec
resolutionstringValue: "SD" "HD" "FULL_HD" Resolution of the input stream
bitratestringValue: "MAX_10_MBPS" "MAX_20_MBPS" Bitrate of the input stream
input_source_astringInput Source A is a RTMP or RTMPS Endpoint provided while creating session, Input Source A must be shown only if the input source is RTMP_PULL or RTMPS_PULL
input_source_bstringInput Source B is a RTMP or RTMPS Endpoint provided while creating session, Input Source A must be shown only if the mode HA and the input source is RTMP_PULL or RTMPS_PULL
output_modeobjectEnum: "RTMP_PULL" "RTMPS_PULL" RTMP output mode type
output_destination_astringOutput Destination A is a RTMP or RTMPS Endpoint, Output Destination A must be shown only if the output mode is RTMP_PUSH or RTMPS_PUSH
output_destination_bstringOutput Destination B is a RTMP or RTMPS Endpoint, Output Destination B is must be shown only if the mode HA and if the output mode is RTMP_PUSH or RTMPS_PUSH
enable_input_recordbooleanIf input record is enabled, the live stream will be recorded and once the live stream is completed successfully, user will be able to download the recorded file.
input_endpoint_astringInput Endpoint A is a RTMP or RTMPS Endpoint, Input Endpoint A will be generated and must be shown only if the input source is RTMP_PUSH or RTMPS_PUSH
input_endpoint_bstringInput Endpoint B is a RTMP or RTMPS Endpoint, Input Endpoint B will be generated and must be shown only if the mode is HA and if the input source is RTMP_PUSH or RTMPS_PUSH
output_endpoint_astringOutput Endpoint A is a RTMP or RTMPS Endpoint, Output Endpoint A will be generated and must be shown only if the ouput mode is RTMP_PULL or RTMPS_PULL
output_endpoint_bstringOutput Endpoint B is a RTMP or RTMPS Endpoint, Output Endpoint B will be generated and must be shown only if the mode is HA and if the ouput mode is RTMP_PULL or RTMPS_PULL
statusstringStatus describes the current state of the session. Session can be any one the following values : 'PENDING', 'PROVISIONING', 'ALLOCATED', 'READY', 'STOPPING', 'STOPPED', 'TERMINATED', 'ERROR', 'SCHEDULED', 'CANCELLED'
is_scheduledbooleanUser can schedule live session if 'is_scheduled' is set to true.
timezonestringTimezone value is a tz database which is also known as tzdata. Eg: 'America/New_York', Value will be empty if is_scheduled is false
scheduled_atstringScheduled_At is a datetime string in 'YYYY-MM-DD HH:MM' format based on the user timezone. Eg: '2021-06-24 22:02', Value will be empty if is_scheduled is false

											
												curl -L -X GET 'https://api.crunchmediaworks.com/live/v1/live-streams/session/a460b312-531c-4ba4-8ded-4e9fe4528796' \
												-u $ACCESS_TOKEN_ID:$SECRET_KEY
											
										
											
											
										

List Stream Sessions:

https://api.crunchmediaworks.com/live/v1/live-streams/session

Response Parameters

ParameterTypeDescription
Sessions (Array of objects)
idstringThe session id to fetch the next 100 session details. This needs to be passed only if you get a value as a response for the previous request in the LastEvaluatedKey field.
user_idstringUser ID of the user who has created the session
regionstringRegion where the session has been created
namestringName of the session
inputstringEnum: "RTMP_PUSH" "RTMP_PULL" "RTMPS_PUSH" "RTMPS_PULL" RTMP input source type
modestringEnum: "HA" "NORM" Session Mode selected while creating the session
input_presetobject
Input stream presets
codecstringValue: "H264" Codec
resolutionstringValue: "SD" "HD" "FULL_HD" Resolution of the input stream
bitratestringValue: "MAX_10_MBPS" "MAX_20_MBPS" Bitrate of the input stream
input_source_astringInput Source A is a RTMP or RTMPS Endpoint provided while creating session, Input Source A must be shown only if the input source is RTMP_PULL or RTMPS_PULL
input_source_bstringInput Source B is a RTMP or RTMPS Endpoint provided while creating session, Input Source A must be shown only if the mode HA and the input source is RTMP_PULL or RTMPS_PULL
output_modestringEnum: "RTMP_PULL" "RTMPS_PULL" RTMP output mode type
output_destination_astringOutput Destination A is a RTMP or RTMPS Endpoint, Output Destination A must be shown only if the output mode is RTMP_PUSH or RTMPS_PUSH
output_destination_bstringOutput Destination B is a RTMP or RTMPS Endpoint, Output Destination B is must be shown only if the mode HA and if the output mode is RTMP_PUSH or RTMPS_PUSH
transcoder_idstringID of transcoder preset user for transcoding
enable_input_recordbooleanIf input record is enabled, the live stream will be recorded and once the live stream is completed successfully, user will be able to download the recorded file.
input_endpoint_astringInput Endpoint A is a RTMP or RTMPS Endpoint, Input Endpoint A will be generated and must be shown only if the input source is RTMP_PUSH or RTMPS_PUSH
input_endpoint_bstringInput Endpoint B is a RTMP or RTMPS Endpoint, Input Endpoint B will be generated and must be shown only if the mode is HA and if the input source is RTMP_PUSH or RTMPS_PUSH
sub_domain_astringSubdomain A is a customer specific domain name
sub_domain_bstringSubdomain B is a customer specific domain name generated if mode is HA
output_endpoint_astringOutput Endpoint A is a RTMP or RTMPS Endpoint, Output Endpoint A will be generated and must be shown only if the ouput mode is RTMP_PULL or RTMPS_PULL
output_endpoint_bstringOutput Endpoint B is a RTMP or RTMPS Endpoint, Output Endpoint B will be generated and must be shown only if the mode is HA and if the ouput mode is RTMP_PULL or RTMPS_PULL
elastic_ip_astringElastic IP allocated for the session
elastic_ip_bstringElastic IP allocated for the session if the Mode is HA
portinteger <int64>Port allocated for session
egress_portinteger <int64>Egress Port allocated for session
statusstringStatus describes the current state of the session. Session can be any one the following values : 'PENDING', 'PROVISIONING', 'ALLOCATED', 'READY', 'STOPPING', 'STOPPED', 'TERMINATED', 'ERROR', 'SCHEDULED', 'CANCELLED'
is_scheduledbooleanUser can schedule live session if 'is_scheduled' is set to true.
timezonestringTimezone value is a tz database which is also known as tzdata. Eg: 'America/New_York', Value will be empty if is_scheduled is false
scheduled_atstringScheduled_At is a datetime string in 'YYYY-MM-DD HH:MM' format based on the user timezone. Eg: '2021-06-24 22:02', Value will be empty if is_scheduled is false
LastEvaluatedKey (object)
It is used for cursor paginating the list of live stream sessions. It has ability to fetch 100 live stream sessions per API call along with pointer to next set of live stream sessions
idstringPointer to the next set of live stream sessions [session ID] which needs to be passed as query string in subsequent request
user_idstringPointer to the next set of live stream sessions [User ID] which needs to be passed as query string in subsequent request
created_at_user_idstringPointer to the next set of live stream sessions which needs to be passed as query string in subsequent request

											
												curl -L -X GET 'https://api.crunchmediaworks.com/live/v1/live-streams/session' \
												-u $ACCESS_TOKEN_ID:$SECRET_KEY
											
										
											
											
										
  •     Optimizer API