Last active
January 4, 2017 14:44
-
-
Save mjlavin80/186a6395c5819dbe25a8a0e001d5acfd to your computer and use it in GitHub Desktop.
Get hypothes.is annotations for a particular URL using hypothes.is API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
# This script demonstrates how to query annotations for a particular URL using the hypothes.is API. An API key is required. | |
# The end result of this script is a Python dictionary with annotation data in it. Top save to csv or other format, further parsing would be required | |
KEY = "Your API key here" | |
URL = "Some URL Here" | |
#a dictionary containing necessary http headers | |
headers = { | |
"Host": "hypothes.is", | |
"Accept": "application/json", | |
"Authorization": "Bearer %s" % KEY | |
} | |
base_url = "https://hypothes.is/api/search" | |
search_url = "".join([base_url, "?uri=", URL]) | |
r = requests.get(search_url, headers=headers) | |
#data is a python dictionary | |
data = json.loads(r.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment