Skip to content

How to get an order by ID

The Brew Ha Ha API includes an endpoint that allows client applications to retrieve their order from the database.

In this guide, you’ll make a GET request to the /orders/ endpoint to retrieve an order.

Before you begin

Before you make a GET request, ensure that you have an access token. For instructions on requesting an access token, see Request a JSON Web Token.

Make a GET request

  1. Open a terminal and run the following command:

    get_order.sh
    curl -H "Authorization: Bearer <your_token>" http://127.0.0.1:8000/api/orders/13/

    The API returns a 200 OK and returns the order with the selected ID:

    get_order_response.sh
    {
    "id": 13,
    "payment_method": "Credit",
    "order_date": "2025-01-11T03:17:47.746025Z",
    "status": "in progress",
    "order_items": [
    {
    "product_id": 2,
    "quantity": 1,
    "product_name": "blueberry muffin"
    }
    ]
    }

You can use the data from the GET request in your application. For example, you could display the order date, list of products, and order ID to the user.

What to do next

See GET /orders/ for a full list of request parameters and response schemas.