Embed URL Generation Made Easy With Python Script

Creating an embed URL is a multistep process that can easily be botched along the way. Finding where the mistake was made can be tricky, and the generation of multiple embed URLs can be a painful process to repeat. With a simple python script we can create a program that generates the embed URL for us by just entering the json blob. 

import hashlib
import hmac
import urllib
import json
import ast

api_key = 'abc-123456'

json_input = raw_input('input your json encoded dashbard:')
to_dict = ast.literal_eval(json_input)
json_data = json.dumps(to_dict)

encoded_json = (urllib.urlencode({"data": json_data})).split("=")[1]

url = "/api/embedded_dashboard?data=" + encoded_json
sig = hmac.new(api_key, url, hashlib.sha256).hexdigest()

print "https://www.periscopedata.com" + url + "&signature=" + sig

Happy Periscoping 🙂

1reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • The above example is the fastest way to generate the direct link to the embedded dashboard. However, in some cases, the resulting URL will be too long for the web browser to parse. In those situations, you'll need to let the Periscope API create the url for you. Consider the following example:

    import json
    import requests
    payload = {"dashboard":MyDashboardID}
    site_name = 'my-site-name'
    api_key = 'my-site-api-key'
    url = 'https://app.periscopedata.com/api/v1/shared_dashboard/create'
    headers = {'HTTP-X-PARTNER-AUTH': site_name + ":" + api_key}
    data = json.dumps(payload)
    response = requests.post(url, headers=headers, data=data)
        print('Couldn''t generate url: ' + response.text)

    Declare three variables payload, site_name, and api_key and copy paste the rest. Payoad should be a valid json object as defined here. You can validate yours at a site like this one: https://jsonlint.com/ . Site name and dashboard id can be found in your url bar like in the image below:


    And lastly, admins can find the api key via Billing & Authentication in Periscope Settings.

    Reply Like 3
reply to topic
Like2 Follow
  • 1 mth agoLast active
  • 1Replies
  • 962Views
  • 2 Following