Sahifalash
Ro'yxat endpointlari object: "list", data, has_more va next_cursor qaytaradi. Buyurtmalar cursor (starting_after) bilan sahifalanadi.
Ro'yxat formati#
Barcha ro'yxatlar bir xil konvertda qaytadi:
JSON
{
"object": "list",
"data": [ … ],
"has_more": true,
"next_cursor": "ord_test_15"
}Cursor sahifalash (buyurtmalar)#
GET /v1/orders eng yangilaridan boshlab qaytaradi. Keyingi sahifa uchun javobdagi next_cursor ni starting_after parametriga bering.has_more: false bo'lsa, oxirgi sahifa. limit — sahifa hajmi.
curl 'https://api.milliysavdo.uz/v1/orders?limit=2' \
-H "Authorization: Bearer $MILLIYSAVDO_API_KEY"{
"object": "list",
"data": [
{
"id": "ord_test_15",
"object": "order",
"mode": "test",
"status": "cancelled",
"phone": "+1231407863",
"sms_code": null,
"country": {
"id": 6,
"name": "United States",
"iso_code": null
},
"service": {
"code": "907",
"title": "Telegram"
},
"price": {
"amount": "3842.44",
"amount_cents": 384244,
"retail_amount": "4269.38",
"retail_amount_cents": 426938,
"discount_percent": "10.00",
"currency": "UZS"
},
"created_at": "2026-10-16T02:13:52.318700Z",
"expires_at": "2026-10-16T02:33:52.318700Z",
"completed_at": "2026-10-16T02:13:52.343024Z"
},
{
"id": "ord_test_14",
"object": "order",
"mode": "test",
"status": "sms_received",
"phone": "+1888582997",
"sms_code": "636841",
"country": {
"id": 6,
"name": "United States",
"iso_code": null
},
"service": {
"code": "907",
"title": "Telegram"
},
"price": {
"amount": "3842.44",
"amount_cents": 384244,
"retail_amount": "4269.38",
"retail_amount_cents": 426938,
"discount_percent": "10.00",
"currency": "UZS"
},
"created_at": "2026-10-16T02:13:52.251868Z",
"expires_at": "2026-10-16T02:33:52.251868Z",
"completed_at": "2026-10-16T02:13:52.301158Z"
}
],
"has_more": false,
"next_cursor": null
}Barcha buyurtmalarni o'qish
def iter_orders(status=None):
params = {"limit": 100}
if status:
params["status"] = status
while True:
page = requests.get(f"{API}/orders", headers=H, params=params, timeout=30).json()
yield from page["data"]
if not page["has_more"]:
break
params["starting_after"] = page["next_cursor"]Offset (katalog)#
GET /v1/services limit va offset parametrlarini qabul qiladi (katalog kichik va kam o'zgaradi). GET /v1/prices esa limit bilan cheklanadi.
curl 'https://api.milliysavdo.uz/v1/services?country_id=6&limit=2' \
-H "Authorization: Bearer $MILLIYSAVDO_API_KEY"{
"object": "list",
"data": [
{
"code": "907",
"title": "Telegram",
"category": "messenger",
"country_id": 6,
"logo_url": null,
"in_stock": 1239,
"available": true,
"price": {
"amount": "3842.44",
"amount_cents": 384244,
"retail_amount": "4269.38",
"retail_amount_cents": 426938,
"discount_percent": "10.00",
"currency": "UZS"
}
},
{
"code": "1012",
"title": "WhatsApp",
"category": "messenger",
"country_id": 6,
"logo_url": null,
"in_stock": 1240,
"available": true,
"price": {
"amount": "13832.78",
"amount_cents": 1383278,
"retail_amount": "15369.75",
"retail_amount_cents": 1536975,
"discount_percent": "10.00",
"currency": "UZS"
}
}
],
"has_more": true,
"next_cursor": "2"
}