// Example using your key
fetch('https://hispmd.moh.gov.et/app/api/v1.php?table=moh_indicators&action=list', {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
})
Using Your API Key
Include your API key in requests either as:
URL Parameter:
GET https://hispmd.moh.gov.et/app/api/v1.php?table=moh_indicators&action=list&apikey=YOUR_API_KEY
Never commit API keys to version control - Add them to your .gitignore file
Use environment variables - Store keys in server environment variables, not in code
Rotate keys regularly - Change your keys every 90 days
Restrict key usage - Only use keys for their intended purpose
Monitor usage - Check your API usage logs for suspicious activity
Troubleshooting
Key not working?
Ensure you've copied the entire key without extra spaces
Check if your account is active (verify your email)
Try generating a new key in your profile if issues persist
Contact support if you see "Invalid API Key" errors
Regenerating Your Key
If your key is compromised or not working:
Go to your profile at https://hispmd.moh.gov.et/app/userinfo.php
Navigate to the "Keys" tab
Click "Regenerate Key"
Update all your applications with the new key
Code Examples
JavaScript Examples
Basic Fetch Request
Example of a simple GET request to fetch indicator data:
// Example: Fetching Main HIS Indicator Data
fetch('https://hispmd.moh.gov.et/api/dash/hispmd_data.php')
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
console.log('API Response:', data);
// Process your data here
})
.catch(error => {
console.error('Error fetching data:', error);
});
Authenticated Request
Example showing both URL parameter and header authentication methods:
// Example: Fetching Indicators with API Key
const apiKey = 'YOUR_API_KEY'; // Replace with your actual key
// Option 1: API Key in URL
fetch('https://hispmd.moh.gov.et/app/api/v1.php?table=moh_indicators&action=list?apikey=' + encodeURIComponent(apiKey))
.then(response => response.json())
.then(data => console.log(data));
// Option 2: API Key in Headers (recommended)
fetch('https://hispmd.moh.gov.et/app/api/v1.php?table=moh_indicators&action=list', {
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data));
Error Handling
Comprehensive error handling for API requests:
// Enhanced error handling example
async function fetchData() {
try {
const response = await fetch('https://hispmd.moh.gov.et/app/api/v1.php?table=moh_indicators&action=list?apikey=YOUR_API_KEY');
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.error?.message || `HTTP error! status: ${response.status}`);
}
const data = await response.json();
if (data.status === 'error') {
console.error('API Error:', data.error);
// Show user-friendly error message
showErrorMessage(data.error.message);
} else {
console.log('API Success:', data);
// Process successful response
processData(data.data);
}
} catch (error) {
console.error('Request Failed:', error);
// Show user-friendly error message
showErrorMessage(error.message);
}
}
// Helper function to display errors to users
function showErrorMessage(message) {
const errorElement = document.createElement('div');
errorElement.className = 'api-error';
errorElement.innerHTML = `
${message}
`;
document.body.appendChild(errorElement);
setTimeout(() => errorElement.remove(), 5000);
}
PHP Examples
Basic cURL Request
Simple example using PHP's cURL library:
// Example: Fetching Main HIS Indicator Data in PHP
$apiUrl = 'https://hispmd.moh.gov.et/api/dash/hispmd_data.php';
// Initialize cURL session
$ch = curl_init($apiUrl);
// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Accept: application/json'
]);
// Execute and close cURL session
$response = curl_exec($ch);
if (curl_errno($ch)) {
// Handle cURL error
echo 'Error:' . curl_error($ch);
} else {
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$data = json_decode($response, true);
if ($httpCode >= 400) {
// Handle API error
echo "API Error: " . ($data['error']['message'] ?? "HTTP status $httpCode");
} else {
// Process successful response
print_r($data);
}
}
curl_close($ch);
Authenticated Request
Making authenticated requests with API key:
// Example: Fetching Indicators with API Key in PHP
$apiKey = 'YOUR_API_KEY'; // Replace with your actual key
$apiUrl = 'https://hispmd.moh.gov.et/app/api/v1.php?table=moh_indicators&action=list';
// Initialize cURL session
$ch = curl_init();
// Set URL and options
curl_setopt($ch, CURLOPT_URL, $apiUrl . '?apikey=' . urlencode($apiKey));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Alternatively with Authorization header:
// curl_setopt($ch, CURLOPT_URL, $apiUrl);
// curl_setopt($ch, CURLOPT_HTTPHEADER, [
// 'Authorization: Bearer ' . $apiKey,
// 'Accept: application/json'
// ]);
// Execute the request
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode !== 200) {
$errorData = json_decode($response, true);
echo "API Request Failed with status: $httpCode\n";
echo "Error: " . ($errorData['error']['message'] ?? 'Unknown error');
} else {
$data = json_decode($response, true);
// Process the data
print_r($data);
}
// Close cURL session
curl_close($ch);
Python Examples
Basic Requests Example
Simple example using Python's requests library:
# Example: Fetching Main HIS Indicator Data in Python
import requests
url = "https://hispmd.moh.gov.et/api/dash/hispmd_data.php"
try:
response = requests.get(url)
response.raise_for_status() # Raises an HTTPError for bad responses
data = response.json()
print("API Response:", data)
except requests.exceptions.RequestException as e:
print(f"Request Failed: {e}")
except ValueError as e:
print(f"Failed to decode JSON: {e}")
Authenticated Request
Making authenticated requests with API key:
# Example with API Key in Python
import requests
api_key = "YOUR_API_KEY" # Replace with your actual key
url = "https://hispmd.moh.gov.et/app/api/v1.php?table=moh_indicators&action=list"
# Option 1: API Key in URL (not recommended for production)
# response = requests.get(f"{url}?apikey={api_key}")
# Option 2: API Key in Headers (recommended)
headers = {
"Authorization": f"Bearer {api_key}",
"Accept": "application/json"
}
try:
response = requests.get(url, headers=headers)
response.raise_for_status()
data = response.json()
if data.get("status") == "error":
print(f"API Error: {data.get('error', {}).get('message', 'Unknown error')}")
else:
print("API Success:", data)
except requests.exceptions.RequestException as e:
print(f"Request Failed: {e}")
Integration Examples
Dashboard Integration
Example of displaying API data in a web dashboard:
// Example: Displaying data in a dashboard
async function loadDashboard() {
try {
const response = await fetch('https://hispmd.moh.gov.et/api/dash/hispmd_data.php');
const data = await response.json();
if (!response.ok) {
throw new Error(data.error?.message || 'Failed to load data');
}
const dashboard = document.getElementById('dashboard');
dashboard.innerHTML = ''; // Clear previous content
// Create cards for each indicator
data.forEach(indicator => {
const card = document.createElement('div');
card.className = 'dashboard-card';
// Calculate progress percentage
const progress = (indicator.value / indicator.target) * 100;
const progressClass = progress >= 90 ? 'high' :
progress >= 70 ? 'medium' : 'low';
card.innerHTML = `
Generating automated reports with data from multiple endpoints:
// Example: Generating automated reports
const API_KEY = 'YOUR_API_KEY'; // In production, use environment variables
async function generateMonthlyReport() {
try {
// Fetch data from multiple endpoints in parallel
const [indicators, regions, reportingRates] = await Promise.all([
fetchData('https://hispmd.moh.gov.et/app/api/v1.php?table=moh_indicators&action=list'),
fetchData('https://hispmd.moh.gov.et/app/api/v1.php?table=moh_regions&action=list'),
fetchData('https://hispmd.moh.gov.et/app/api/v1.php?table=dhis2_reporting_rates&action=list')
]);
// Generate report HTML
const reportDate = new Date().toLocaleDateString();
const reportHTML = `
HISPMD Monthly Report - ${reportDate}
HISPMD Monthly Report
Generated on: ${reportDate}
Key Indicators
${generateIndicatorTable(indicators)}
Reporting Rates by Region
${generateReportingRatesChart(reportingRates, regions)}
`;
// Save or send the report
saveReport(reportHTML);
} catch (error) {
console.error('Report generation failed:', error);
// Send error notification
sendErrorNotification(error);
}
}
// Helper function to fetch data with API key
async function fetchData(endpoint) {
const response = await fetch(`${endpoint}?apikey=${API_KEY}`);
if (!response.ok) {
throw new Error(`Failed to fetch ${endpoint}: ${response.status}`);
}
return await response.json();
}
// Run report generation
generateMonthlyReport();
Support Center
Contact Our Team
Our dedicated support team is available to assist you with any questions or issues regarding the HISPMD API.
Support Hours: Monday-Friday, 8:30 AM - 5:30 PM EAT (GMT+3)
Fill out the form below and our team will respond as soon as possible.
Frequently Asked Questions
The API is currently limited to 100 requests per minute per API key. If you need higher limits for your application, please contact support to discuss your requirements.
Please use the support form above to report any bugs or issues. For fastest resolution, include:
The endpoint you were calling
The exact error message
The request parameters you used
Any relevant screenshots or code snippets
API Documentation
Overview
The HISPMD API provides programmatic access to health indicators, facility data, and reporting metrics from Ethiopia's Health Information System. This RESTful API returns JSON responses and supports standard HTTP methods.
Key Features:
Real-time access to health indicators and performance metrics
Standardized JSON responses for easy integration
Secure authentication via API keys
Comprehensive documentation with examples
Rate limiting for fair usage (100 requests/minute)
Authentication
Most endpoints require an API key for authentication. Include your key in requests either as:
URL Parameter:
GET https://hispmd.moh.gov.et/app/api/v1.php?table=moh_indicators&action=list&apikey=YOUR_API_KEY