Mux Video is the API that makes you a video expert. With just a few simple API calls, add and stream videos that play anywhere and look beautiful, every time, at scale.
For interacting with the Mux API we created open source language-specific SDKs for most popular server-side languages. Find more information about them here:
1. Get an API Access Token
The Mux Video API uses a token key pair that consists of a Token ID and Token Secret for authentication. If you haven't already, generate a new Access Token in the Access Token settings of your Mux account dashboard.


The Access Token should be set to "Full Access" for Mux Video.


Access Tokens also belong to an Environment. Be sure to use the same Environment when using Mux Video and Mux Data together, so the data from Mux Data can be used to optimize your Mux Video streams.


2. POST a video
Videos stored in Mux are called assets. To create your first video asset, send a POST request to the /assets endpoint and set the "input" property to the URL of a video file that's accessible online.
Note that Mux does not store the original file in its exact form, so if you want to retain your masters, don't delete them after submitting to Mux. Mux will also never need to download your video file again, unless you use it to create more assets.
Fill in the form details to auto-populate the example code.
curl https://api.mux.com/video/v1/assets \
-H "Content-Type: application/json" \
-X POST \
-d '{ "input": "{INPUT_URL}", "playback_policy": "public" }' \
-u {MUX_TOKEN_ID}:{MUX_TOKEN_SECRET} | json_pp
The response will include an Asset ID and a Playback ID.
- Asset IDs are used to manage assets using
api.mux.com
(e.g. to read or delete an asset). - Playback IDs are used to stream an asset to a video player through
stream.mux.com
. You can add multiple playback IDs to an asset to create playback URLs with different viewing permissions, and you can delete playback IDs to remove access without deleting the asset.
{
"data" : {
"id" : "ymDhKE00YZ12XxJLFo76DIVqCzL15bVf2",
"created_at" : "1517531451",
"playback_ids" : [
{
"id" : "EsxKJmzkfLvGV01cbThYHDcEz7TKcbR31",
"policy" : "public"
}
],
"status" : "preparing"
}
}
3. Wait for "ready"
As soon as you POST a video, Mux begins downloading and processing the video. For shorter files, this often takes just a few seconds. Very large files over poor connections may take a few minutes (or longer).
When the video is ready for playback, the asset "status" changes to "ready".
The best way to do this is via webhooks. Mux can send a webhook notification as soon as the asset is ready. See the Webhooks documentation for details.
If you can't use webhooks for some reason, you can manually poll the asset API to see asset status. Note that this only works at low volume. Try this example:
Fill in the form details to auto-populate the example code.
curl -X GET https://api.mux.com/video/v1/assets/{ASSET_ID} \
-u {MUX_TOKEN_ID}:{MUX_TOKEN_SECRET} | json_pp
Please don't poll this API more than once per second.
4. Watch it
To play back an asset, just create a playback URL using the PLAYBACK_ID you received when you created the asset.
Fill in the form details to auto-populate the example code.
https://stream.mux.com/{PLAYBACK_ID}.m3u8
The easiest way to test asset playback is to try this playback URL in Safari (Mac) or Edge (Windows), which can natively play back HTTP Live Streaming (HLS) video.


5. Configure playback
Now you're ready to integrate with a video player. Mux Video supports any modern video player capable of playing the HLS streaming format: most web players, iOS, Android, and many connected TV devices.
6. Generate thumbnails
Now see what else you can do with the API, starting with thumbnails. Generate images directly from the video in real time.
7. Configure Mux Data for monitoring
Mux Video is optimized by real-world performance monitoring, via Mux Data. Use Mux Data to monitor your whole video playback stack, including your player and application performance. Installing Mux Data is easy, and usually just involves pasting in a bit of Javascript (or Objective-C, or Java) alongside your video player.
Postman API Collection
If you want to check out our Video and Data APIs as a Postman Collection, take a look here!
Updated about a month ago