Pagination, Sorting, and Filtering for Orders

Add these parameters to the path to specify which orders will be returned in the response and how they will be organized. These parameters help you efficiently search and navigate through your order data.

GET /api/orders/

Returns a list of orders with support for pagination, sorting, and filtering.

Query Parameters

Pagination Parameters

Parameter Default value Description
page 1 The response to GET /api/orders/ is a page with a limited number of orders. This parameter determines the number of the page that will be sent in the response.
items_per_page 10 Determines the number of orders on a page.

Sorting Parameters

Parameter Default value Description
sort_by date Determines the parameter by which the orders are sorted in the response.
sort_order desc Determines the sorting order:
asc—ascending
desc—descending

Filtering Parameters

Parameter Default value Description
status Searches only for the orders with the specified status. Status names and functions are configured by store owners and may vary from store to store.

These default order statuses can be edited, but can't be deleted:
P—processed
C—complete
O—open
F—failed
D—declined
B—backordered
I—cancelled
Y—awaiting call
user_id Searches only for the orders placed by the customer with the specified user ID.
company_id Searches only for the orders placed on the specific vendor.
email Searches only for the orders placed by the customer with the specified email.
invoice_id Searches only for the orders with the specified invoice ID.
credit_memo_id Searches only for the orders with the specified credit memo ID.
Tip: When searching for multiple orders placed by different customers, you can use a comma-separated list of user IDs with the user_id parameter like: user_id=123,456,789

Examples

Basic Filtering with Status

GET /api/orders/?page=5&items_per_page=5&status=C

Response is an array with 5 orders from the 5th page of the list of complete orders.

Filtering by Customer

GET /api/orders/?email=customer@example.com&company_id=2

Response is an array with 10 orders placed by the customer with the specified email with the vendor with company_id=2.

Response Format

Let's examine a sample request to understand the response structure:

GET /api/orders/?items_per_page=2

If the request is successful, you'll receive HTTP/1.1 200 OK. The response is JSON with the following structure:

{
  "orders": [
    {
      "order_id": "97",
      "issuer_id": null,
      "user_id": "3",
      "is_parent_order": "N",
      "parent_order_id": "0",
      "company_id": "1",
      "timestamp": "1456917981",
      "firstname": "George",
      "lastname": "Nills",
      "email": "customer1@example.com",
      "phone": "+1 646-386-3600",
      "status": "O",
      "total": "677.95",
      "invoice_id": null,
      "credit_memo_id": null,
      "points": null
    },
    {
      "order_id": "96",
      "issuer_id": null,
      "user_id": "3",
      "is_parent_order": "N",
      "parent_order_id": "0",
      "company_id": "1",
      "timestamp": "1456917981",
      "firstname": "Customer",
      "lastname": "Customer",
      "email": "customer2@example.com",
      "phone": "",
      "status": "C",
      "total": "972.00",
      "invoice_id": null,
      "credit_memo_id": null,
      "points": null
    }
  ],
  "params": {
    "page": 1,
    "items_per_page": "2",
    "ajax_custom": "1",
    "include_incompleted": false,
    "sort_order": "desc",
    "sort_by": "date",
    "sort_order_rev": "asc",
    "total_items": "64"
  }
}
Note: The params object in the response includes pagination metadata, such as the current page, items per page, and total number of items available. The total_items field is particularly useful for implementing pagination controls in your application.