API Reference
Base URL’lar
| Maqsad | URL |
|---|---|
| Authorize (brauzer redirect) | https://id.sfere.pro/oauth |
| API | https://api.id.sfere.pro |
Authorize
Foydalanuvchini yo’naltirish uchun brauzer manzili (server endpoint emas).
GET https://id.sfere.pro/oauth| Parametr | Majburiy | Tavsif |
|---|---|---|
client_id | ✅ | Client ID |
redirect_uri | ✅ | Ro’yxatdan o’tgan callback (URL-encoded) |
response_type | ✅ | Har doim code |
Muvaffaqiyatda ProID redirect_uriga qaytadi:
{redirect_uri}?code=AUTHORIZATION_CODEcode — bir martalik, ~10 daqiqa amal qiladi.
Token almashinuvi
POST https://api.id.sfere.pro/api/v2/oauth/tokenContent-Type: application/x-www-form-urlencodedRequest body:
| Parametr | Type | Majburiy | Tavsif |
|---|---|---|---|
grant_type | string | ✅ | authorization_code |
client_id | string | ✅ | Client ID |
client_secret | string | ✅ | Client Secret (maxfiy) |
redirect_uri | string | ✅ | Authorize’dagi bilan aynan bir xil |
code | string | ✅ | Authorize’dan olingan kod |
Javob 200 OK:
{ "token_type": "Bearer", "expires_in": 864000, "access_token": "42|Xr8kQ...token..."}expires_in — soniyalarda (864000 = ~10 kun).
Foydalanuvchi ma’lumoti
GET https://api.id.sfere.pro/api/userAuthorization: Bearer ACCESS_TOKENJavob 200 OK:
{ "id": 128, "name": "Ali", "surname": "Valiyev", "phone_number": "998991234567", "email": "ali@example.com", "avatar_full_url": "https://api.id.sfere.pro/storage/avatars/abc.png", "date_of_birth": "1998-05-12", "gender": "male", "avatar": "https://api.id.sfere.pro/storage/avatars/abc.png", "is_admin": 0}| Maydon | Type | Izoh |
|---|---|---|
id | integer | Foydalanuvchi ID |
name / surname | string | Ism / familiya |
phone_number | string | 998XXXXXXXXX formatida |
email | string | null | Email (bo’lmasligi mumkin) |
avatar_full_url | string | null | Avatar to’liq URL |
date_of_birth | string | null | YYYY-MM-DD |
gender | string | null | male / female |
is_admin | integer | 1 — admin, 0 — oddiy |
Rate limit
Auth va OAuth endpointlari cheklangan. Limitdan oshsa 429 Too Many Requests.
| Endpoint | Limit |
|---|---|
POST /api/v2/oauth/token | 120 / daqiqa (client_id bo’yicha) |
| Authorize / login oqimi | 30 / daqiqa (IP bo’yicha) |
| OTP yuborish | 3 / daqiqa (telefon bo’yicha) |