Complete API Documentation for Developers
curl -H "Authorization: Bearer YOUR_API_KEY" \
http://meditrakapp.com/api/v1/invoices/
{
"success": true,
"invoices": [
{
"invoice_id": "INV-2025-001",
"patient_name": "John Doe",
"total_amount": 1500.00,
"status": "approved",
"service_date": "2025-01-15"
}
],
"pagination": {
"page": 1,
"total_count": 45
}
}
All API requests require authentication using your API key in the Authorization header.
Authorization: Bearer YOUR_API_KEY
http://meditrakapp.com/api/v1/
Retrieve a paginated list of all invoices for your healthcare facility.
| Parameter | Type | Required | Description |
|---|---|---|---|
page |
integer | No | Page number (default: 1) |
limit |
integer | No | Results per page (default: 50, max: 100) |
status |
string | No | Filter by status: draft, submitted, approved, rejected, paid |
date_from |
date | No | Start date (YYYY-MM-DD) |
date_to |
date | No | End date (YYYY-MM-DD) |
curl -H "Authorization: Bearer YOUR_API_KEY" \
"http://meditrakapp.com/api/v1/invoices/?status=approved&limit=100"
Retrieve detailed information about a specific invoice.
curl -H "Authorization: Bearer YOUR_API_KEY" \
http://meditrakapp.com/api/v1/invoices/INV-2025-001/
Get statistical information about your invoices.
| Parameter | Type | Required | Description |
|---|---|---|---|
date_from |
date | No | Start date for statistics |
date_to |
date | No | End date for statistics |
curl -H "Authorization: Bearer YOUR_API_KEY" \
"http://meditrakapp.com/api/v1/invoices/stats/?date_from=2025-01-01&date_to=2025-12-31"
{
"success": true,
"statistics": {
"total_invoices": 150,
"total_amount": 125000.00,
"average_amount": 833.33,
"by_status": {
"approved": {"count": 80, "amount": 75000.00},
"paid": {"count": 35, "amount": 27500.00}
}
}
}
Export multiple invoices at once with flexible filtering.
{
"invoice_ids": ["INV-001", "INV-002"], // optional
"date_from": "2025-01-01", // optional
"date_to": "2025-01-31", // optional
"status": "approved" // optional
}
{} exports all invoices (up to 1000).
curl -X POST \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"status":"approved","date_from":"2025-01-01"}' \
http://meditrakapp.com/api/v1/invoices/export/bulk/
const MEDITRAK_API_KEY = 'your_api_key_here';
const BASE_URL = 'http://meditrakapp.com/api/v1';
async function getInvoices() {
const response = await fetch(`${BASE_URL}/invoices/`, {
headers: {
'Authorization': `Bearer ${MEDITRAK_API_KEY}`
}
});
const data = await response.json();
console.log(`Found ${data.invoices.length} invoices`);
return data.invoices;
}
async function getStatistics(dateFrom, dateTo) {
const url = new URL(`${BASE_URL}/invoices/stats/`);
url.searchParams.append('date_from', dateFrom);
url.searchParams.append('date_to', dateTo);
const response = await fetch(url, {
headers: {
'Authorization': `Bearer ${MEDITRAK_API_KEY}`
}
});
const data = await response.json();
return data.statistics;
}
// Usage
getInvoices().then(invoices => {
invoices.forEach(invoice => {
console.log(`${invoice.invoice_id}: $${invoice.total_amount}`);
});
});
import requests
MEDITRAK_API_KEY = 'your_api_key_here'
BASE_URL = 'http://meditrakapp.com/api/v1'
class MediTrakAPI:
def __init__(self, api_key):
self.api_key = api_key
self.session = requests.Session()
self.session.headers.update({
'Authorization': f'Bearer {api_key}'
})
def get_invoices(self, status=None, limit=50):
"""Get list of invoices"""
params = {'limit': limit}
if status:
params['status'] = status
response = self.session.get(
f'{BASE_URL}/invoices/',
params=params
)
response.raise_for_status()
return response.json()['invoices']
def get_statistics(self, date_from=None, date_to=None):
"""Get invoice statistics"""
params = {}
if date_from:
params['date_from'] = date_from
if date_to:
params['date_to'] = date_to
response = self.session.get(
f'{BASE_URL}/invoices/stats/',
params=params
)
response.raise_for_status()
return response.json()['statistics']
# Usage
api = MediTrakAPI(MEDITRAK_API_KEY)
invoices = api.get_invoices(status='approved', limit=100)
print(f"Found {len(invoices)} approved invoices")
apiKey = $apiKey;
$this->baseUrl = $baseUrl;
}
public function getInvoices($params = []) {
$url = $this->baseUrl . '/invoices/';
if (!empty($params)) {
$url .= '?' . http_build_query($params);
}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $this->apiKey
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
}
// Usage
$api = new MediTrakAPI('your_api_key_here');
$invoices = $api->getInvoices(['status' => 'approved', 'limit' => 100]);
echo "Found " . count($invoices['invoices']) . " invoices\n";
?>
{
"success": false,
"error": "Invalid or expired API key",
"code": "INVALID_API_KEY"
}
Solution: Check your API key is correct and active.
{
"success": false,
"error": "Invalid date format",
"code": "INVALID_PARAMETER"
}
Solution: Verify request parameters match required format.
{
"success": false,
"error": "Invoice not found",
"code": "INVOICE_NOT_FOUND"
}
Solution: Check invoice ID exists and you have access.
Want MediTrak to import invoices from your system? Your API needs to provide these two endpoints with the data structure below.
List all invoices with optional filtering by date range, status, or update time.
Get a single invoice by ID.
{
"id": "INV-001", // ✅ Required: Unique invoice ID
"invoice_number": "INV-2025-001", // ✅ Required: Invoice number
"invoice_date": "2025-01-15", // ✅ Required: YYYY-MM-DD
"total_amount": 1250.00, // ✅ Required: Decimal (2 places)
"status": "paid", // ✅ Required: paid/unpaid/pending
"facility": "CFB Medical Hospital", // 📝 Recommended
"patient": {
"name": "John Doe", // ✅ Required
"policy_number": "POL-456789" // ✅ Required: Must exist in MediTrak
},
"items": [ // ✅ Required: At least 1 item
{
"category": "consultation", // ✅ Required: See categories below
"description": "General Consultation", // ✅ Required
"quantity": 1, // ✅ Required
"unit_price": 450.00, // ✅ Required
"total": 450.00 // ✅ Required: quantity × unit_price
},
{
"category": "laboratory",
"description": "Full Blood Count",
"quantity": 2,
"unit_price": 400.00,
"total": 800.00
}
]
}
Use these category values for items[].category:
| Category | Description Examples |
|---|---|
consultation | General Consultation, Specialist Consultation, Follow-up |
laboratory | Full Blood Count, Malaria Test, HIV Test, Urinalysis |
radiology | X-Ray, Ultrasound, MRI Scan, CT Scan |
pharmacy | Antibiotics, Pain Medication, Insulin |
emergency | Emergency Room Fee, Trauma Care |
surgery | Minor Surgery, Wound Care, Sutures |
dental | Tooth Extraction, Cleaning, Root Canal |
physiotherapy | Physiotherapy Session, Rehabilitation |
obstetrics | Prenatal Care, Ultrasound, Delivery |
optical | Eye Exam, Glasses, Contact Lenses |
patient.policy_number field must match an existing policy in MediTrak. Contact our integration team to synchronize policy numbers before starting imports.
Use these test credentials to verify your API:
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://your-api.com/api/invoices"
We'll test the connection and provide feedback on data structure compliance.
Get your API key and start integrating MediTrak into your application today!
Get Your API Key Try API Playground