API Reference
Complete REST API endpoint documentation
The pycli REST API lets you create, retrieve, list, and cancel orders programmatically over HTTP. Use these endpoints to integrate order management into your own applications or automate workflows that would otherwise require manual interaction through the CLI.
Parameters vary by endpoint. See the per-endpoint tables below.
GET /orders/{order_id} — Fetch a single order
| Parameter | Type | Required | Description |
|---|---|---|---|
order_id | integer | Yes | The unique numeric ID of the order to retrieve. Passed as a path segment. |
POST /orders — Create an order
Send a JSON body with the following fields:
| Parameter | Type | Required | Description |
|---|---|---|---|
amount | integer | Yes | The order amount, expressed as a whole number (e.g., in the smallest unit of the currency). |
currency | string | Yes | The ISO 4217 currency code for the order (e.g., "USD", "EUR"). |
note | string | No | An optional free-text note to attach to the order. Omit or set to null if not needed. |
GET /orders — List orders
| Parameter | Type | Required | Description |
|---|---|---|---|
status | string | No | Filter orders by status. Defaults to "paid" if omitted. |
limit | integer | No | Maximum number of orders to return. Defaults to 20 if omitted. |
DELETE /orders/{order_id} — Cancel an order
| Parameter | Type | Required | Description |
|---|---|---|---|
order_id | integer | Yes | The unique numeric ID of the order to cancel. Passed as a path segment. |
All successful responses use HTTP 200 OK and return JSON.
GET /orders/{order_id}
Returns a single order object:
{
"id": 42,
"amount": 100,
"currency": "USD",
"status": "paid"
}
| Field | Type | Description |
|---|---|---|
id | integer | The order's unique identifier. |
amount | integer | The order amount. |
currency | string | The currency code for the order. |
status | string | The current status of the order (e.g., "paid", "pending", "canceled"). |
POST /orders
Returns the newly created order object with an assigned id and a status of "pending":
{
"id": 1,
"amount": 250,
"currency": "EUR",
"status": "pending"
}
GET /orders
Returns a JSON object containing the applied filter parameters and an array of matching orders:
{
"status": "paid",
"limit": 20,
"orders": []
}
| Field | Type | Description |
|---|---|---|
status | string | The status filter that was applied. |
limit | integer | The limit that was applied. |
orders | array | The list of matching order objects. |
DELETE /orders/{order_id}
Returns a confirmation object showing the order ID and its updated status:
{
"id": 42,
"status": "canceled"
}
The API returns standard HTTP error codes when a request cannot be completed.
| Error | HTTP Status | When it occurs |
|---|---|---|
| Validation Error | 422 Unprocessable Entity | The request body or parameters fail validation — for example, sending a string where an integer is required, or omitting a required field such as amount or currency in POST /orders. The response body includes a detail array describing each validation failure. |
| Not Found | 404 Not Found | The requested order_id does not exist. |
| Method Not Allowed | 405 Method Not Allowed | You used an HTTP method that is not supported for the given endpoint (e.g., PUT /orders). |
| Internal Server Error | 500 Internal Server Error | An unexpected server-side error occurred. Retry the request or contact support if the issue persists. |
The examples below use curl. Replace https://api.example.com with your actual base URL.
Fetch a single order by ID
curl -X GET https://api.example.com/orders/42
Expected response:
{
"id": 42,
"amount": 100,
"currency": "USD",
"status": "paid"
}
Create a new order
curl -X POST https://api.example.com/orders \
-H "Content-Type: application/json" \
-d '{"amount": 250, "currency": "EUR", "note": "Rush delivery"}'
Expected response:
{
"id": 1,
"amount": 250,
"currency": "EUR",
"status": "pending"
}
Create an order without an optional note
curl -X POST https://api.example.com/orders \
-H "Content-Type: application/json" \
-d '{"amount": 500, "currency": "USD"}'
Expected response:
{
"id": 1,
"amount": 500,
"currency": "USD",
"status": "pending"
}
List orders filtered by status
curl -X GET "https://api.example.com/orders?status=pending&limit=5"
Expected response:
{
"status": "pending",
"limit": 5,
"orders": []
}
Cancel an order
curl -X DELETE https://api.example.com/orders/42
Expected response:
{
"id": 42,
"status": "canceled"
}
Example of a validation error (missing required field)
curl -X POST https://api.example.com/orders \
-H "Content-Type: application/json" \
-d '{"currency": "USD"}'
Expected response (422 Unprocessable Entity):
{
"detail": [
{
"loc": ["body", "amount"],
"msg": "field required",
"type": "value_error.missing"
}
]
}
amountis an integer. The API represents monetary amounts as whole numbers. Decide on a convention with your team — for example, storing cents rather than dollars — and apply it consistently across all requests. Sending a floating-point value (e.g.,9.99) will result in a422validation error.- Query parameter defaults. When you call
GET /orderswithout specifyingstatusorlimit, the API automatically appliesstatus=paidandlimit=20. Always pass these parameters explicitly in production code to avoid unintended filtering behavior. noteis truly optional. You may omit thenotefield entirely from thePOST /ordersrequest body, or include it with anullvalue — both are valid.- Path parameters must be integers. Both
GET /orders/{order_id}andDELETE /orders/{order_id}requireorder_idto be a valid integer. Passing a non-numeric value (e.g.,/orders/abc) will result in a422validation error. - Authentication. The source code does not define any authentication mechanism. Consult your deployment configuration or contact your infrastructure team to determine what authentication headers or tokens (if any) are required in your environment.
DELETEis not reversible. Canceling an order viaDELETE /orders/{order_id}sets its status to"canceled". There is no undo endpoint — verify the correctorder_idbefore sending this request.