API Overview
The AfriData API provides programmatic access to African datasets, enabling developers to integrate our data repository into their applications, research workflows, and data analysis pipelines.
Base URL
https://afridata.com/api/v1/
Response Format
JSON
Rate Limit
1000 requests/hour
Authentication
AfriData API uses API key authentication. Include your API key in the Authorization header:
Authorization: Api-Key YOUR_API_KEY_HERE
Available Endpoints
Datasets
/api/v1/datasets/
List all datasets with pagination and filtering
/api/v1/datasets/{id}/
Retrieve a specific dataset by ID
/api/v1/datasets/{id}/preview/
Get dataset preview with pagination
/api/v1/datasets/{id}/download/
Download dataset file
/api/v1/datasets/{id}/comments/
Get dataset comments with pagination
/api/v1/datasets/upload/
Upload a new dataset (authentication required)
/api/v1/comment/{id}/post/
Post a comment on a dataset (authentication required)
/api/v1/comment/{id}/upvote/
Upvote a comment (authentication required)
Example Requests
Python (requests)
import requests
# Get all datasets
headers = {'Authorization': 'Api-Key YOUR_API_KEY'}
response = requests.get('https://afridata.com/api/v1/datasets/', headers=headers)
datasets = response.json()
# Filter datasets by category and search
params = {
'category': 'agriculture',
'search': 'kenya',
'sort': 'downloads'
}
response = requests.get('https://afridata.com/api/v1/datasets/',
headers=headers, params=params)
# Get dataset details
dataset_id = 1
response = requests.get(f'https://afridata.com/api/v1/datasets/{dataset_id}/',
headers=headers)
# Download dataset
response = requests.get(f'https://afridata.com/api/v1/datasets/{dataset_id}/download/',
headers=headers)
with open('dataset.csv', 'wb') as f:
f.write(response.content)
# Upload new dataset
files = {'file': open('mydata.csv', 'rb')}
data = {
'title': 'Kenya Population Census 2024',
'bio': 'Latest population data for Kenya',
'topics': 'demographics, kenya, population'
}
response = requests.post('https://afridata.com/api/v1/datasets/upload/',
headers=headers, files=files, data=data)
API Key Management
Welcome! You can manage your API keys below. Generate new keys or revoke existing ones as needed.
Your API Keys
afridata_***************_xyz789
Active
afridata_***************_abc123
Active
Generate New API Key
Create a new API key for your applications. Each key can be revoked independently.
API Key Best Practices
- Keep your API keys secret. Do not expose them in client-side code.
- Rotate your API keys regularly to minimize the impact of a compromised key.
- Use environment variables to store your API keys securely.
- Monitor your API key usage for any suspicious activity.
Usage Statistics
Requests Today
0
1000 remaining
This Month
0
+0% from last month
Popular Endpoint
/datasets/
0% of requests
API Key Usage
0
1000 remaining