Code examples
Python and Javascript examples
Native query
import requests
API_TOKEN = "API_TOKEN" # Replace with your actual token
RESOURCE_ID = "45036735-305b-42ae-9aef-b941d6dcb6d6"
URL = "https://data.humdata.org/api/3/action/datastore_search"
headers = {
"Authorization": API_TOKEN,
"Content-Type": "application/json"
}
response = requests.post(
URL,
headers=headers,
json={
"resource_id": RESOURCE_ID,
"filters": {"location_code": "AFG"},
"limit": 5
}
).json()
# Native query: Get first 5 records where location is 'AFG'
print("Total results:", response["result"]["total"])
for record in response["result"]["records"]:
print(record)Last updated
Was this helpful?
