-
-
Save fabianvf/4164749c838b2bca2b52 to your computer and use it in GitHub Desktop.
How to get data from the OSF elasticsearch endpoint
This file contains 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 | |
response = requests.get('https://osf.io/api/v1/search/', params={ | |
'q': 'test AND category:project' # Full lucene syntax accepted: http://lucene.apache.org/core/2_9_4/queryparsersyntax.html | |
}) | |
results = response.json() |
This file contains 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 json | |
import requests | |
data = json.dumps({ | |
'query': { | |
'match_all': {} # Accepts the full elasticsearch DSL: http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html | |
} | |
}) | |
headers = { | |
'Content-type': 'application/json' | |
} | |
response = requests.post('https://osf.io/api/v1/search/', data=data, headers=headers) | |
results = response.json() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment