> ## 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.

# Get HTS Code by Code

> Fetch a single HTS code with hierarchy, children, duty rates, units, and footnotes

Get a single HTS code with its full hierarchy and children. This endpoint is useful for exploring the code structure and understanding parent-child relationships.

## Parameters

| Parameter | Type   | Required | Description                          |
| --------- | ------ | -------- | ------------------------------------ |
| `code`    | string | Yes      | The HTS code (e.g., '8517.12.00.50') |

## Example Request

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

## Example Response

```json theme={null}
{
  "data": {
    "id": 12345,
    "code": "8517.12.00.50",
    "normalized_code": "8517120050",
    "description": "Telephone sets, including telephones for cellular networks or for other wireless networks",
    "indent": 3,
    "chapter": "85",
    "heading": "8517",
    "subheading": "851712",
    "rates": {
      "general": "Free",
      "special": "Free (A+,AU,BH,CA...)",
      "other": "Free"
    },
    "units": ["No."],
    "footnotes": [],
    "hierarchy": [
      {
        "code": "85",
        "description": "Electrical machinery and equipment and parts thereof"
      },
      {
        "code": "8517",
        "description": "Telephone sets, including telephones for cellular networks or for other wireless networks"
      }
    ],
    "children": []
  }
}
```

## Response Fields

* `hierarchy`: Array of parent codes in order from chapter to immediate parent
* `children`: Array of child codes (if any exist)
* `units`: Measurement units for the code
* `footnotes`: Footnotes and additional information

## Use Cases

* Explore code structure and relationships
* Build hierarchical navigation UIs
* Understand code context within the classification system
* Get complete code details including rates and units


## OpenAPI

````yaml GET /hts/{code}
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:
  /hts/{code}:
    get:
      summary: Get HTS Code by Code
      description: Returns a single HTS code with full hierarchy and children
      parameters:
        - name: code
          in: path
          required: true
          description: The HTS code (e.g., '8517.12.00.50')
          schema:
            type: string
      responses:
        '200':
          description: HTS Code detail with hierarchy
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HtsCodeDetailResponse'
        '400':
          description: Invalid code format
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: HTS code not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    HtsCodeDetailResponse:
      type: object
      properties:
        data:
          allOf:
            - $ref: '#/components/schemas/HsCode'
            - type: object
              properties:
                hierarchy:
                  type: array
                  items:
                    type: object
                    properties:
                      code:
                        type: string
                        nullable: true
                      description:
                        type: string
                children:
                  type: array
                  items:
                    $ref: '#/components/schemas/HsCode'
    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)
    HsCode:
      type: object
      required:
        - id
        - description
      properties:
        id:
          type: integer
          description: Internal ID
        code:
          type: string
          nullable: true
          description: HTS/HS Code (raw format)
        normalized_code:
          type: string
          nullable: true
          description: Normalized code (digits only)
        description:
          type: string
          description: Code description
        indent:
          type: integer
          description: Hierarchy indent level
        chapter:
          type: string
          nullable: true
          description: Chapter (2 digits)
        heading:
          type: string
          nullable: true
          description: Heading (4 digits)
        subheading:
          type: string
          nullable: true
          description: Subheading (6 digits)
        rates:
          type: object
          properties:
            general:
              type: string
              nullable: true
            special:
              type: string
              nullable: true
            other:
              type: string
              nullable: true
        units:
          type: array
          items:
            type: string
          description: Measurement units
        footnotes:
          type: array
          items:
            type: object
            properties:
              marker:
                type: string
                nullable: true
              value:
                type: string
          description: Code footnotes
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 'API key as Bearer token. Format: Bearer your_hts_api_key'

````