> ## Documentation Index
> Fetch the complete documentation index at: https://docs.scrapebadger.com/llms.txt
> Use this file to discover all available pages before exploring further.

# List Categories

> Browse Gumtree's category tree. A node's slug is the category value /search takes.

Browse Gumtree's category tree one level at a time. Each child's `slug` is the
value [`/search`](/api-reference/endpoint/gumtree/search) and
[`/search/filters`](/api-reference/endpoint/gumtree/search-filters) take as
`category`.

**Credits:** 1

## Authorization

<ParamField header="X-API-Key" type="string" required>
  Your ScrapeBadger API key.
</ParamField>

## Query Parameters

<ParamField query="parent_id" type="integer" default="1">
  Category id to list the children of. `1` (the default) is the root — all
  categories. Then drill down by `id`, e.g. `2551` for Motors.
</ParamField>

## Response

<ResponseField name="id" type="integer">The parent category id.</ResponseField>
<ResponseField name="name" type="string">e.g. `Motors`.</ResponseField>
<ResponseField name="slug" type="string">e.g. `cars-vans-motorbikes`.</ResponseField>
<ResponseField name="result_count" type="integer">Number of children.</ResponseField>

<ResponseField name="children" type="TreeNode[]">
  Child categories.

  <Expandable title="TreeNode">
    <ResponseField name="id" type="integer">Pass as `parent_id` to go one level deeper.</ResponseField>

    <ResponseField name="name" type="string" />

    <ResponseField name="slug" type="string">The `/search` `category` value.</ResponseField>

    <ResponseField name="has_children" type="boolean" />
  </Expandable>
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://scrapebadger.com/v1/gumtree/categories?parent_id=2551" \
    -H "X-API-Key: YOUR_API_KEY"
  ```

  ```javascript Node.js theme={null}
  const res = await fetch(
    "https://scrapebadger.com/v1/gumtree/categories?" +
      new URLSearchParams({ parent_id: "2551" }),
    { headers: { "X-API-Key": process.env.SCRAPEBADGER_API_KEY } },
  );
  const { children } = await res.json();
  ```

  ```python Python theme={null}
  import requests

  res = requests.get(
      "https://scrapebadger.com/v1/gumtree/categories",
      headers={"X-API-Key": "YOUR_API_KEY"},
      params={"parent_id": 2551},
  )
  children = res.json()["children"]
  ```
</CodeGroup>

```json Response theme={null}
{
  "id": 2551,
  "name": "Motors",
  "slug": "cars-vans-motorbikes",
  "result_count": 12,
  "children": [
    { "id": 11986, "name": "Other Categories", "slug": "other-vehicle-categories", "has_children": false },
    { "id": 9311, "name": "Cars", "slug": "cars", "has_children": false },
    { "id": 10442, "name": "Motorbikes & Scooters", "slug": "motorbikes-scooters", "has_children": false },
    { "id": 94, "name": "Vans", "slug": "vans", "has_children": false }
  ]
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.