Developer Docs
This page defines the production API key flow, security rules, endpoint catalog, and testing standards. Production API base URL: https://api.sarafa.pk
Loading API access workspace...
Test your API key with a real request against the production API host (https://api.sarafa.pk) and inspect status, rate-limit headers, and response payload.
cURL
curl -X GET "https://api.sarafa.pk/api/v1/public-rates/gold/cities/karachi" \ -H "X-API-Key: YOUR_API_KEY" \ -H "X-Client-Platform: server"
Production API Base URL: https://api.sarafa.pk
| Method | Path | Auth | Purpose |
|---|---|---|---|
| POST | /api/v1/auth/v2/login | No | Get JWT token |
| POST | /api/v1/api-keys/ | Bearer JWT | Create API key |
| GET | /api/v1/api-keys/ | Bearer JWT | List API keys |
| PATCH | /api/v1/api-keys/{key_id}/access | Bearer JWT | Update domains and platform access |
| POST | /api/v1/api-keys/{key_id}/revoke | Bearer JWT | Revoke key |
| GET | /api/v1/api-keys/{key_id}/usage?days=30 | Bearer JWT | Daily usage report |
| GET | /api/v1/public-rates/gold/cities/{location_slug} | X-API-Key | Single-city gold rate |
| GET | /api/v1/public-rates/gold/cities?slugs={karachi,lahore} | X-API-Key | Multi-city gold rates |
| GET | /api/v1/public-rates/silver/cities/{location_slug} | X-API-Key | Single-city silver rate |
| GET | /api/v1/public-rates/silver/cities?slugs={karachi,lahore} | X-API-Key | Multi-city silver rates |
# 1) Login (Get JWT)
curl -X POST "https://api.sarafa.pk/api/v1/auth/v2/login" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=03001234567&password=YourPassword"
# 2) Create API key
curl -X POST "https://api.sarafa.pk/api/v1/api-keys/" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"Backend Server Key"}'
# 3) Call city gold rate
curl -X GET "https://api.sarafa.pk/api/v1/public-rates/gold/cities/karachi" \
-H "X-API-Key: YOUR_API_KEY" \
-H "X-Client-Platform: server"
# 4) Call city silver rate
curl -X GET "https://api.sarafa.pk/api/v1/public-rates/silver/cities/lahore" \
-H "X-API-Key: YOUR_API_KEY" \
-H "X-Client-Platform: server"
# 5) Call multi-city gold rates
curl -X GET "https://api.sarafa.pk/api/v1/public-rates/gold/cities?slugs=karachi,lahore,islamabad" \
-H "X-API-Key: YOUR_API_KEY" \
-H "X-Client-Platform: mobile"
# 6) Call multi-city silver rates
curl -X GET "https://api.sarafa.pk/api/v1/public-rates/silver/cities?slugs=karachi,lahore,islamabad" \
-H "X-API-Key: YOUR_API_KEY" \
-H "X-Client-Platform: mobile"
# 7) Web origin-restricted request
curl -X GET "https://api.sarafa.pk/api/v1/public-rates/gold/cities/karachi" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Origin: https://app.example.com"| Status | Meaning |
|---|---|
| 401 | Missing/invalid auth or API key |
| 403 | Key revoked/disabled/forbidden |
| 404 | City or key resource not found |
| 429 | Daily limit exceeded |
{ "detail": "message" }