List Categories
This guide explains how to retrieve a list of all categories using the Aara API. We'll start with an example using curl and follow it up with JavaScript examples utilizing the native fetch API.
Curl example
curl -X GET "https://api.aara.app/v1/categories" \ -H "AARA_API_KEY: YOUR_API_KEY" \ -H "UNIQUE_USER_ID: UNIQUE_USER_ID"
JavaScript example
const listCategories = async () => {
const response = await fetch("https://api.aara.app/v1/categories", {
method: "GET",
headers: {
AARA_API_KEY: "YOUR_API_KEY",
UNIQUE_USER_ID: "UNIQUE_USER_ID",
},
});
const data = await response.json();
console.log(data);
};
listCategories();
Instructions:
- Replace
YOUR_API_KEYandUNIQUE_USER_IDwith your actual credentials. - This API call will return a list of all available categories on the Aara platform.
Response
The response from the API will be a JSON object containing an array of categories, with each category including details like the category name, ID, and index.
Example Response
[
{
id: "abcdefghijklmn1234567890",
name: "Food",
index: 1,
},
{
id: "abcdefghijklmn1234567890",
name: "Drinks",
index: 2,
},
{
id: "abcdefghijklmn1234567890",
name: "Shopping",
index: 3,
},
];
This response shows a list of categories with details like the category ID, name, and index.