AfriData

API Documentation

Explore the API endpoints and their usage

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

GET /api/v1/datasets/

List all datasets with pagination and filtering

Query Parameters: search, category, format, sort, page
GET /api/v1/datasets/{id}/

Retrieve a specific dataset by ID

GET /api/v1/datasets/{id}/preview/

Get dataset preview with pagination

GET /api/v1/datasets/{id}/download/

Download dataset file

GET /api/v1/datasets/{id}/comments/

Get dataset comments with pagination

POST /api/v1/datasets/upload/

Upload a new dataset (authentication required)

POST /api/v1/comment/{id}/post/

Post a comment on a dataset (authentication required)

POST /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
Created: January 15, 2025 • Last used: 2 hours ago
afridata_***************_abc123 Active
Created: December 28, 2024 • Last used: 1 day ago

Generate New API Key

Create a new API key for your applications. Each key can be revoked independently.

You can have up to 10 active API keys at a time

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