Dolby
  • Up and Running
  • Getting Started
  • Amazon IAM
  • Configure Web Player
  • Hybrik JSON
  • Hybrik REST API
  • Hybrik API with Postman
  • Stitching
  • Trimming
  • Definitions and Placeholders
  • Tagging
  • Analyze and Quality Control
  • Quality Control Jobs
  • Troubleshooting Tips
  • Amazon Web Services
  • Sources
  • Hybrik JSON
  • Video Filters
  • Audio Filters
  • Working with Audio
  • Task Modifiers
  • Package Task
  • Analysis & Quality Control
  • Dolby Technologies
  • Additional Tasks
  • Hybrik Versions
  • QC Player
  • Machine Performance Analysis

    Hybrik REST API

    Hybrik can be easily integrated into your application or workflow through a simple RESTful API. In this tutorial, we’ll walk through the steps of authenticating, submitting a job, and checking the job status via the API using curl to make the HTTP requests.

    All API calls will include the X-Hybrik-Compliance header, which ensures your code remains compatible with the Hybrik API as the API evolves over time. While developing your Hybrik integration, you should use the current date to ensure you’re interacting with the latest version of the API. In a production environment, this date should be locked and not changed without testing.

    API Details

    You can find your API details in the Account > Info section of the Hybrik Web Interface. Note that the OAPI Key and OAPI Secret are only visible to the account owner. The OAPI Key and OAPI Secret are shared across all users in the account. account_info

    Creating an API User

    NOTE: In Hybrik version 1.220 we are beginning to phase out API access for Web Console login credentials. If you previously used your Web Console login for API access, please create an API user and update your credentials as described below.

    Navigate to your API Users tab in the Hybrik Web Console. Click the New API User button. api_users_tab

    A popup will appear with a one-time opportunity to get your user’s auth_key and auth_secret. create_api_user

    Once you click “OK”, you will not be able to view the auth secret again. The user will appear in the list. api_user_created

    Step 1: Authenticate

    Hybrik uses two methods to authenticate calls to the API. All HTTP requests must include your Hybrik API user’s auth_key and API user’s auth_secret via HTTP Basic Authentication - this authorizes the connection to the API server. See the section above on creating an API User for details on getting these credentials.

    You will also use your OAPI Key and OAPI Secret to authorize access to the resources within your Hybrik account. To do this, you’ll request a temporary authorization token and provide the token when interacting with the API. The example below shows a sample curl command to POST a login request to the API and retrieve an auth token. We’re using the --user parameter to provide the OAPI Key and OAPI Secret via HTTP Basic Authentication. In the body of the request (--data), we provide the API User’s auth_key and auth_secret that were generated when creating the API user.

    curl --header "X-Hybrik-Compliance: 20171201" \
    --header "Content-Type: application/json" \
    --user OAPI_KEY:OAPI_SECRET \
    --data '{"auth_key":"API_USER_AUTH_KEY","auth_secret":"API_USER_AUTH_SECRET"}' \
    -X POST https://api-demo.hybrik.com/v1/login
    

    The response will look like this:

    {
        "token": "vFfVGj6FKmFiNqvfEB....HXyp-1Z2-XIGBXJyp9A",
        "expiration_time": "2019-01-23T02:41:14.081Z"
    }
    

    We’ll hold on to the token to use in the next API request. Auth tokens expire after 30 minutes, but the expiration is reset with each new request using that token.

    Step 2: Submit a Job

    Now that we have a temporary auth token, we can send an API call to submit a job. We will use a similar curl command, except we add the X-Hybrik-Sapiauth header to supply the auth token we received above. In the body of the request (--data), we’re supplying the job details as a JSON string, and we’re POSTing to the /jobs endpoint instead of /login. Note that we still pass the OAPI Key and OAPI Secret with every request.

    curl --header "X-Hybrik-Compliance: 20171201" \
    --header "X-Hybrik-Sapiauth: vFfVGj6FKmFiNqvfEB....HXyp-1Z2-XIGBXJyp9A" \
    --header "Content-Type: application/json" \
    --user OAPI_KEY:OAPI_SECRET \
    --data '{"name":"Hybrik API Example#1 - simple transcode","payload":{"elements":[{"uid":"source_file","kind":"source","payload":{"kind":"asset_url","payload":{"storage_provider":"s3","url":"s3://hybrik-examples/public/sources/sample1.mp4"}}},{"uid":"transcode_task","kind":"transcode","task":{"retry_method":"fail"},"payload":{"location":{"storage_provider":"s3","path":"s3://hybrik-examples/public/output/transcode/example1"},"targets":[{"file_pattern":"{source_basename}.mp4","existing_files":"replace","container":{"kind":"mp4"},"video":{"codec":"h264","width":640,"height":360,"frame_rate":23.976,"bitrate_kb":600},"audio":[{"codec":"heaac_v2","channels":2,"sample_rate":44100,"bitrate_kb":128}]}]}}],"connections":[{"from":[{"element":"source_file"}],"to":{"success":[{"element":"transcode_task"}]}}]}}' \
    
    -X POST https://api-demo.hybrik.com/v1/jobs
    

    If the job was submitted successfully, Hybrik will return a Job ID:

    {"id":"2849867"}
    

    Step 3: Check Job Status

    Using the Job ID, we can query the API for the status of the job we’ve submitted. We supply a list of fields we want the response to contain (URL-encoded, since this is a GET request) and call the /jobs endpoint using the pattern /jobs/{job_id}/info.

    curl --header "X-Hybrik-Compliance: 20171201" \
    --header "X-Hybrik-Sapiauth: vFfVGj6FKmFiNqvfEB....HXyp-1Z2-XIGBXJyp9A" \
    --header "Content-Type: application/json" \
    --user OAPI_KEY:OAPI_SECRET
    
    --data-urlencode 'fields=["id","name","status","progress"]' \
    -G https://api-demo.hybrik.com/v1/jobs/2849867/info
    

    Hybrik will return an object containing the requested fields:

    {
        "id": "2849867",
        "name": "Hybrik API Example#1 - simple transcode",
        "status": "queued",
        "progress": 1
    }