Summary
The Panda Merb application provides a REST API for managing videos. Both YAML (recommended) and XML is supported, determined by the extension of the url (.yaml or .xml). All data is posted as form parameters.
If you’re implementing your own library for accessing the API, the Panda gem is a good starting point.
Example flow of a video through Panda
- A user on your site wants to upload a new video. Your site makes a background call to the Panda API to retrieved a new video id.
- Your site displays an upload form within an iframe for the user, which includes the video id previously retrieved.
- The users selects a video file and submits the form, uploading the file directly to Panda.
- Panda verifies the upload and displays a progress bar as the file is uploaded.
- Panda receives the file and the video is added to the encoding queue.
- The user is redirected to the url defined in your Panda settings.
- Once the video has been encoded, Panda sends a second notification to your application.
API Reference
If you’re accessing Panda from another environment such as Flash, or there is currently no library which supports your environment, you can access the API directly.
Create new video
POST hq.pandastream.com/videos.(yaml|xml)
Creates and empty video which a file can then be upload to.
Parameters
account_key: 32aa8390-b6f6-012a-2162-0017f22c2d49
Responses
Status: 200 OK
---
:video:
:id: a92fdd10-b6f6-012a-a860-0017f22c2d49
Status: 401 Unauthorized
Display video upload form
GET upload.pandastream.com/videos/id/form (html only)
The page returned will contain a form to allow the user to upload a video with the corresponding id. It is suggested that this page is displayed in either an iframe or a popup window. Whilst uploading, a progress bar will keep the users informed of the upload.
Once completed, the user will be redirected to the “Upload redirect url” defined in your Panda config. If setting this is left blank the user will be redirected to a default thank you page.
Upload video file
POST upload.pandastream.com/videos/id/upload.(html|yaml|xml)
It’s recommended that you use the form described above (which submits to this resource), but if required (such as from within Flash) the file can be submitted directly.
Parameters
file: The video file
Responses
Status: 200 OK
If the video id is not found the following status is returned.
Status: 404 Not Found
When calling using either yaml or xml formats, there are several different error response which may be returned.
- NoFileSubmitted: No file parameter was submitted (check your form’s html if you’re not using the default Panda form)
- FormatNotRecognised: The video format is not supported or the video could not be read.
- InternalServerError: There was a internal error. This error will be logged and resolved as soon as possible.
All are returned in the following format.
Status: 500
---
:error: ErrorMessage
Get details
GET hq.pandastream.com/videos/id.(yaml|xml)
Retrieve details for a specific video. Included in the response will be all of its encodings and their current statuses.
The status of a video may be one of the following:
- empty: video has been created but the actual video file has yet to be uploaded
- original: video has had a file uploaded to it
The status of an encoding may be one of the following:
- queued: video is waiting in queue for processing
- processing: the encoding is currently being encoded
- success: the encoding was successful
- error: there was an error encoding or handling the video
Responses
Status: 200 OK
---
:video:
:width: 320
:duration: 15900
:screenshot: bac01bf0-503a-012b-1406-123138002145.flv.jpg
:original_filename: sneezing_panda.flv
:height: 240
:status: original
:thumbnail: bac01bf0-503a-012b-1406-123138002145.flv_thumb.jpg
:encodings:
- :video:
:encoded_at: 2008-08-19 16:35:53 +00:00
:width: 320
:duration: 15900
:profile_title: Flash video SD
:screenshot: c2e83ee0-503a-012b-1407-123138002145.flv.jpg
:original_filename: sneezing_panda.flv
:height: 240
:status: success
:thumbnail: c2e83ee0-503a-012b-1407-123138002145.flv_thumb.jpg
:parent: bac01bf0-503a-012b-1406-123138002145
:profile: 82d587f0-43cf-012b-13f4-123138002145
:encoding_time: 10
:filename: c2e83ee0-503a-012b-1407-123138002145.flv
:id: c2e83ee0-503a-012b-1407-123138002145
:filename: bac01bf0-503a-012b-1406-123138002145.flv
:id: bac01bf0-503a-012b-1406-123138002145
Status: 404 Not Found
Get details for all videos
GET hq.pandastream.com/videos.(yaml|xml)
Parameters
account_key: 32aa8390-b6f6-012a-2162-0017f22c2d49
Responses
Status: 200 OK
Array of videos in format described above for a single video.
Status: 401 Unauthorized
Callbacks
When the state of a video changes, Panda will notify your application with a callback. A POST request is made to the “State update url” defined in your Panda config (note that the $id part of this url will be replaced with the id of the video whose status has changed). The request will be attempted a maximum of 5 times, after which time it will be logged as an error and you will be notified (the max number of retries can be set in the Panda config).
Example callback
POST http://mysite/videos/id/state
Parameters
---
:video:
:width: 320
:duration: 15900
:screenshot: bac01bf0-503a-012b-1406-123138002145.flv.jpg
:original_filename: sneezing_panda.flv
:height: 240
:status: original
:thumbnail: bac01bf0-503a-012b-1406-123138002145.flv_thumb.jpg
:encodings:
- :video:
:encoded_at: 2008-08-19 16:35:53 +00:00
:width: 320
:duration: 15900
:profile_title: Flash video SD
:screenshot: c2e83ee0-503a-012b-1407-123138002145.flv.jpg
:original_filename: sneezing_panda.flv
:height: 240
:status: success
:thumbnail: c2e83ee0-503a-012b-1407-123138002145.flv_thumb.jpg
:parent: bac01bf0-503a-012b-1406-123138002145
:profile: 82d587f0-43cf-012b-13f4-123138002145
:encoding_time: 10
:filename: c2e83ee0-503a-012b-1407-123138002145.flv
:id: c2e83ee0-503a-012b-1407-123138002145
:filename: bac01bf0-503a-012b-1406-123138002145.flv
:id: bac01bf0-503a-012b-1406-123138002145
Responses
When sending a notification Panda will check the response status code, and if it’s not a 200 the notification will be logged as a failed.

