Developer Docs
یہ صفحہ production استعمال کے لیے API key flow، سیکیورٹی rules، endpoint catalog، اور testing standards واضح کرتا ہے۔ Production API base URL: https://api.sarafa.pk
API access workspace لوڈ ہو رہا ہے...
اپنی API key کے ساتھ production API host (https://api.sarafa.pk) پر live request چلا کر status، rate-limit headers، اور 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 | نہیں | JWT token حاصل کریں |
| POST | /api/v1/api-keys/ | Bearer JWT | API key بنائیں |
| GET | /api/v1/api-keys/ | Bearer JWT | API keys کی فہرست |
| PATCH | /api/v1/api-keys/{key_id}/access | Bearer JWT | Domain اور platform access اپ ڈیٹ کریں |
| POST | /api/v1/api-keys/{key_id}/revoke | Bearer JWT | key revoke کریں |
| GET | /api/v1/api-keys/{key_id}/usage?days=30 | Bearer JWT | روزانہ usage رپورٹ |
| GET | /api/v1/public-rates/gold/cities/{location_slug} | X-API-Key | Single-city سونے کی قیمت |
| GET | /api/v1/public-rates/gold/cities?slugs={karachi,lahore} | X-API-Key | Multi-city سونے کی قیمتیں |
| GET | /api/v1/public-rates/silver/cities/{location_slug} | X-API-Key | Single-city چاندی کی قیمت |
| GET | /api/v1/public-rates/silver/cities?slugs={karachi,lahore} | X-API-Key | Multi-city چاندی کی قیمتیں |
# 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 یا API key |
| 403 | Key revoked/disabled/forbidden |
| 404 | City یا key resource نہیں ملا |
| 429 | روزانہ limit exceed ہو گئی |
{ "detail": "message" }