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

# Browse Categories

> Browse the HTS hierarchy as a tree by fetching children for a parent code

Browse the hierarchical tree structure of codes. Returns top-level chapters or children of a specified parent code.

## Parameters

| Parameter | Type    | Required | Description                                   |
| --------- | ------- | -------- | --------------------------------------------- |
| `parent`  | string  | No       | Parent code to get children of (e.g., '8517') |
| `depth`   | integer | No       | How many levels deep (default: 1, max: 3)     |

## Example Request

Get top-level chapters:

```bash theme={null}
curl -X GET "https://htsapi.com/v1/categories" \
  -H "Authorization: Bearer your_hts_api_key"
```

Get children of a specific code:

```bash theme={null}
curl -X GET "https://htsapi.com/v1/categories?parent=8517&depth=1" \
  -H "Authorization: Bearer your_hts_api_key"
```

## Example Response

```json theme={null}
{
  "data": [
    {
      "id": 1234,
      "code": "8517",
      "normalized_code": "8517",
      "description": "Telephone sets, including telephones for cellular networks or for other wireless networks",
      "indent": 0,
      "has_children": true
    },
    {
      "id": 1235,
      "code": "8518",
      "normalized_code": "8518",
      "description": "Microphones and stands therefor; loudspeakers, whether or not mounted in their enclosures",
      "indent": 0,
      "has_children": true
    }
  ]
}
```

## Response Fields

* `has_children`: Boolean indicating if the code has child codes
* `indent`: Hierarchy level (0 = top level)

## Use Cases

* Build tree navigation interfaces
* Explore code hierarchies
* Display category structures
* Implement breadcrumb navigation


## OpenAPI

````yaml GET /categories
openapi: 3.0.1
info:
  title: HTS API
  description: >-
    An API for HTS and HS Codes - Enabling supply chain organizations to scale
    with reliable data
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://htsapi.com/v1
security:
  - bearerAuth: []
paths:
  /categories:
    get:
      summary: Browse Categories
      description: Browse hierarchical tree structure of codes
      parameters:
        - name: parent
          in: query
          description: Parent code to get children of
          schema:
            type: string
            maxLength: 50
        - name: depth
          in: query
          description: 'How many levels deep (default: 1, max: 3)'
          schema:
            type: integer
            minimum: 1
            maximum: 3
            default: 1
      responses:
        '200':
          description: Category tree
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CategoriesResponse'
        '404':
          description: Parent code not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CategoriesResponse:
      type: object
      properties:
        data:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
              code:
                type: string
                nullable: true
              normalized_code:
                type: string
                nullable: true
              description:
                type: string
              indent:
                type: integer
              has_children:
                type: boolean
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        message:
          type: string
        retry_after:
          type: integer
          description: Seconds to wait before retrying (for 429 errors)
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 'API key as Bearer token. Format: Bearer your_hts_api_key'

````