Last active
September 24, 2019 17:10
-
-
Save Trafitto/e5f4398d5bffcac184539945d628882a to your computer and use it in GitHub Desktop.
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 | |
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