Skip to content

Instantly share code, notes, and snippets.

@Trafitto
Last active September 24, 2019 17:10
Show Gist options
  • Save Trafitto/e5f4398d5bffcac184539945d628882a to your computer and use it in GitHub Desktop.
Save Trafitto/e5f4398d5bffcac184539945d628882a to your computer and use it in GitHub Desktop.
import requests
BASE_URL = "http://bestemmie.org/api/{endpoint}"
'''
Optional params:
offset (default 50)
limit (default 50)
Response field:
count: total distinct count of bestemmie
next: the url to the next page
previous: the url to the previous page
results: array of bestemmie with the single count of how many time was inserted
Response example:
{
"count": 984,
"next": "http://bestemmie.org/api/bestemmie/?limit=50&offset=50",
"previous": null,
"results": [
{
"bestemmia": "DIO CANE",
"count": 2
},
...
]
}
'''
response = requests.get(BASE_URL.format(endpoint="bestemmie"))
response.raise_for_status()
print(response.json()['results'])
'''
[ {'count': 2, 'bestemmia': u'DIO CANE'}, ...]
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment