Historical Orders API - RoyalGr4pe/stockx-sdk GitHub Wiki
📜 Historical Orders API
The Historical Orders API provides access to past sales orders on StockX, including completed, cancelled, returned, or failed transactions. This is useful for generating reports, tracking performance, and handling customer service workflows.
🔐 Authentication
Before using this API, make sure you've set up the SDK with your API credentials:
from stockx.connection import setup
setup({"api_key": "YOUR_API_KEY", "jwt": "YOUR_JWT_TOKEN"})
📘 Function
get_order_history(params: dict) -> dict
Fetch a paginated list of historical orders.
Parameters
Name | Type | Description |
---|---|---|
fromDate |
str | Start date to filter orders. Format: YYYY-MM-DD . |
toDate |
str | End date to filter orders. Format: YYYY-MM-DD . |
pageNumber |
int | Page number of results. Defaults to 1 . |
pageSize |
int | Number of results per page (1–100). Defaults to 10 . |
orderStatus |
str | Comma-separated list of statuses to filter. Valid values: "AUTHFAILED" , "DIDNOTSHIP" , "CANCELED" , "COMPLETED" , "RETURNED" |
productId |
str | StockX product ID to filter. |
variantId |
str | Variant ID of the product. |
inventoryTypes |
str | Comma-separated inventory types: "STANDARD" , "FLEX" . |
initiatedShipmentDisplayIds |
str | Shipment display IDs associated with Flex orders. |
⚠️ All list-type fields must be plain comma-separated strings. Do not use quotes or brackets.
✅ Example
from stockx.orders import get_order_history
import asyncio
async def main():
history = await get_order_history({
"fromDate": "2024-01-01",
"toDate": "2024-04-30",
"pageNumber": 1,
"pageSize": 20,
"orderStatus": "COMPLETED,RETURNED"
})
print(history)
asyncio.run(main())
📤 Use Cases
- Revenue reporting over a specific date range
- Analyzing cancellation and return rates
- Customer support and refund lookups
❗ Errors
- 401 Unauthorized – Check your API key and JWT.
- 400 Bad Request – Make sure all fields are formatted correctly.
- 500 Server Error – Retry or contact StockX if the issue persists.