How to get a product by ID
The Brew Ha Ha API includes an endpoint that allows client applications to GET
a product by ID.
In this guide, you’ll make a GET
request to the /products/
endpoint to get a specific product in the database.
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
-
Open a terminal and run the following command:
get_request_id.sh curl -H "Authorization: Bearer <your_token>" http://127.0.0.1:8000/api/products/3/The API returns a
200 OK
and returns the product with the selected ID:get_request_id_response.sh {"id": 3,"product_name": "cortado","temperature": "hot","caffeine_amount": 130,"price": 4.0,"description": "Made with beans picked from the coast of Spain","quantity": 5}
You can use the data from the GET
request in your application. For example, you could display details about a specific product in your application.
What to do next
See GET /products/ for a full list of request parameters and response schemas.