Skip to content

Instantly share code, notes, and snippets.

@jezcope
Last active March 17, 2016 15:54
Show Gist options
  • Save jezcope/e01bc2e85adbba9d8981 to your computer and use it in GitHub Desktop.
Save jezcope/e01bc2e85adbba9d8981 to your computer and use it in GitHub Desktop.
Searching the figshare API from Python
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
token: In real life this contains my actual API token
@adrianp
Copy link

adrianp commented Mar 17, 2016

Here is the amended code which send the request payload as JSON:

import requests as rq
from pprint import pprint as pp

HEADERS = {'content-type': 'application/json'}

r = rq.post('https://api.figshare.com/v2/articles/search', data='{"search_for": "university of sheffield", "page_size":20}', headers=HEADERS)
print(r.status_code)
results = r.json()
pp(results)

Not that for accessing public data you don't need a token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment