Pagination
Long lists come in pages. Send page, from 1, and the answer has total, all there are, and page_size, how many fit on a page.
GET /market/items | 60 |
|---|---|
GET /market/items/{slug}/lots | 30 |
GET /stalls/{steam_id} | 30 |
GET /stall | 60 |
import os
import requests
API = "https://api.rockvel.store/v1"
KEY = {"Authorization": f"Bearer {os.environ['ROCKVEL_KEY']}"}
page, cards = 1, []
while True:
answer = requests.get(f"{API}/market/items", headers=KEY, params={"category": "rifles", "page": page}).json()
cards += answer["items"]
if page * answer["page_size"] >= answer["total"]:
break
page += 1Deals
The list of deals works differently: it brings all deals under way and the newest finished ones. more says older ones are left, and finished asks for more of them.