Page Contents

    Python Code for a GET Request

    CMS API requests can be scripted using any language. Here we offer you a script written in Python, which you can use for getting videos or as a model for your own script.


    REST APIs like the Brightcove platform APIs can be used with any language. The Python script included here is just one sample to show you how requests are put together. There is another sample of POST requests to create and ingest a video here.


    Python script

    The gist below shows the script. Note that to use it, you will need to supply your own values for the following:

    • ***ACCOUNT ID HERE**** (line 7)
    • ***CLIENT ID HERE**** (line 8)
    • ***CLIENT SECRET HERE**** (line 9)
          #!/usr/bin/env python3
          import sys
          import requests
          import json
          pub_id = "***ACCOUNT ID HERE****"
          client_id = "***CLIENT ID HERE****"
          client_secret = "***CLIENT SECRET HERE****"
          access_token_url = ""
          profiles_base_url = "{pub_id}"
          def get_access_token():
              access_token = None
              r =, params="grant_type=client_credentials", auth=(client_id, client_secret), verify=False)
              if r.status_code == 200:
                  access_token = r.json().get('access_token')
              return access_token
          def get_video():
              access_token = get_access_token()
              headers = { 'Authorization': 'Bearer ' + access_token, "Content-Type": "application/json" }
              url = ("{pubid}/videos/").format(pubid=pub_id)
              r = requests.get(url, headers=headers)
              return r.json()
          v = get_video()

    Page last updated on 28 Sep 2020