# Hugging Face repository file tree API

Get Hugging Face Repo File Tree data via REST or OpenAny MCP—with pay-per-use pricing and no subscription. Powered by Apish, pass parameters such as id, output, and retrieve structured data including repository identifier, total file count reported, file size in bytes, download url, and next cursor to estimate storage and bandwidth upfront, locate specific export formats, and check file security and provenance.

Documentation: https://openany.si/hugging-face/hugging-face-repository-file-tree-api/8da07f3c-1178-433c-8b79-32bc7b25501e/
API ID: 8da07f3c-1178-433c-8b79-32bc7b25501e
Provider: apish
Contract revision: 3
Method: GET
Endpoint: https://api.openany.si/v1/agent-apis/apish/huggingface/v1/model/files
Page update time: 2026-12-03T02:43:38.267Z
Access: OpenAny REST
OpenAny MCP: availability is not supplied by this REST contract. Check get_api on the configured OpenAny MCP server before execution.
Request content type: none
Execution mode: sync
Authentication: Authorization: Bearer $OPENANY_API_KEY

## Billing
Price: $0.002 / billing credit
API-key calls use your shared balance. Review the published billing rules before making a paid request.
Price source: OpenAny public API contract.
Contract update time: 2026-12-03T02:43:37.475Z. This is not a price-change timestamp.
```json
{
  "currency": "USD",
  "mode": "rules",
  "parameters": [],
  "policy_version": 2,
  "sale": {
    "addons": [],
    "base_price_micro_usd": "0",
    "max_cost_micro_usd": "2000",
    "quantities": [
      {
        "id": "upstream_credits",
        "label": "Actual API.SH credits consumed",
        "max_quantity": "1",
        "measure": "value",
        "pointer": "/credits_used",
        "price_micro_usd": "2000",
        "quantity_scale": 0,
        "source": "response",
        "unit": "credit",
        "unit_quantity": "1"
      }
    ],
    "rounding": "ceil",
    "variants": []
  }
}
```

## Usage and limits
## Hugging Face Repo File Tree API

Pass required id (owner/name or huggingface.co link) with optional type (default model), revision (branch, tag or commit, default main), path (subfolder such as onnx), recursive (default true) and cursor. Each entry exposes path, type, byte size, LFS/security flags, last\_commit and direct download\_url.

## What You Can Build

- **Estimate storage and bandwidth upfront**: Sum items\[\].size or read total\_size before pulling multi-gigabyte safetensors or Parquet shards.
- **Locate specific export formats**: Pass path=onnx or inspect items\[\].path and items\[\].lfs to find quantized weights or dataset splits.
- **Check file security and provenance**: Inspect items\[\].security, items\[\].oid and items\[\].last\_commit before integrating artifacts.

## Returned Data

| Field | Meaning |
| --- | --- |
| `id` | Repository identifier (owner/name) |
| `type` | Repository type: model, dataset or space |
| `revision` | Branch, tag or commit revision listed |
| `files_count` | Total file count reported |
| `total_size` | Aggregate byte size of listed files |
| `items[].path` | Repository-relative file or directory path |
| `items[].type` | Entry kind such as file or directory |
| `items[].size` | File size in bytes |
| `items[].download_url` | Direct download link for the file at this revision |
| `next_cursor` | Opaque cursor for the next page, or null on the last page |

## Request parameters
```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Hugging Face repository file tree API request inputs",
  "$comment": "Declared input types grouped by HTTP location. Path, query and header values describe decoded inputs and are serialized as text on the wire; body is the payload. This is not an exhaustive provider contract or a schema for the raw HTTP request.",
  "type": "object",
  "properties": {
    "path": {
      "type": "object",
      "properties": {}
    },
    "query": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Repo id (owner/name) or huggingface.co link."
        },
        "type": {
          "type": "string",
          "description": "Repo type (default model; taken from a pasted link).",
          "enum": [
            "model",
            "dataset",
            "space"
          ]
        },
        "revision": {
          "type": "string",
          "description": "Branch, tag or commit (default main)."
        },
        "path": {
          "type": "string",
          "description": "Only this folder, e.g. onnx."
        },
        "recursive": {
          "type": "string",
          "description": "Include sub-folders (default true).",
          "enum": [
            "true",
            "false"
          ]
        },
        "cursor": {
          "type": "string",
          "description": "next_cursor from the previous page."
        },
        "raw": {
          "type": "string",
          "description": "0 leaves out the bulky `raw` source blocks (often 10-30x smaller).",
          "enum": [
            "0",
            "1"
          ]
        },
        "fields": {
          "type": "string",
          "description": "Comma-separated fields to return, e.g. `posts.id,posts.title`. Call metadata is always included."
        },
        "fresh": {
          "type": "string",
          "description": "1 skips the 24-hour cache and fetches live.",
          "enum": [
            "1"
          ]
        },
        "output": {
          "type": "string",
          "description": "JSON only for this OpenAny product. Omit output or use json; CSV and NDJSON exports are not exposed.",
          "enum": [
            "json"
          ]
        },
        "records": {
          "type": "string",
          "description": "Native CSV/NDJSON record selector; it has no effect on this JSON-only product."
        }
      },
      "required": [
        "id"
      ]
    },
    "headers": {
      "type": "object",
      "properties": {}
    }
  },
  "required": [
    "path",
    "query",
    "headers"
  ]
}
```

## Response fields
Source: Inferred from examples; not an exhaustive provider schema.
```json
{
  "type": "object",
  "properties": {
    "cached": {
      "type": "boolean"
    },
    "count": {
      "type": "integer"
    },
    "credits_used": {
      "type": "integer"
    },
    "files_count": {
      "type": "integer"
    },
    "id": {
      "type": "string"
    },
    "items": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "download_url": {
                "anyOf": [
                  {
                    "type": "null"
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              "last_commit": {
                "type": "object",
                "properties": {
                  "date": {
                    "type": "string"
                  },
                  "id": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  }
                }
              },
              "lfs": {
                "type": "null"
              },
              "oid": {
                "type": "string"
              },
              "path": {
                "type": "string"
              },
              "security": {
                "type": "null"
              },
              "size": {
                "type": "integer"
              },
              "type": {
                "type": "string"
              },
              "url": {
                "type": "string"
              },
              "xet_hash": {
                "type": "null"
              }
            }
          },
          {
            "type": "string"
          }
        ]
      }
    },
    "next_cursor": {
      "type": "null"
    },
    "path": {
      "type": "null"
    },
    "revision": {
      "type": "string"
    },
    "total_size": {
      "type": "integer"
    },
    "type": {
      "type": "string"
    }
  }
}
```

## Request example
Scenario: Official example · Official documentation response · Supplier-tr
```bash
curl \
  'https://api.openany.si/v1/agent-apis/apish/huggingface/v1/model/files?id=openai-community%2Fgpt2&output=json' \
  -X GET \
  -H "Authorization: Bearer $OPENANY_API_KEY" \
  -H 'Content-Type: application/json'
```

## Response example
Example from the provider's documentation. Field values in your results will differ.
Sample response · Documented HTTP 200
```json
{
  "cached": false,
  "count": 27,
  "credits_used": 1,
  "files_count": 26,
  "id": "openai-community/gpt2",
  "items": [
    {
      "download_url": null,
      "last_commit": {
        "date": "2023-06-30T02:19:43.000Z",
        "id": "11c5a3d5811f50298f278a704980280950aedb10",
        "title": "Adding ONNX file of this model (#60)"
      },
      "lfs": null,
      "oid": "d03ec5ec179df58241d27d55f92a674f5f44197f",
      "path": "onnx",
      "security": null,
      "size": 0,
      "type": "directory",
      "url": "https://huggingface.co/openai-community/gpt2/tree/main/onnx",
      "xet_hash": null
    },
    {
      "download_url": "https://huggingface.co/openai-community/gpt2/resolve/main/.gitattributes",
      "last_commit": {
        "date": "2022-09-29T15:22:02.000Z",
        "id": "909a290700bd99135e67c64eefc166960b67cfd2",
        "title": "Convert weights to .safetensors (#6)"
      },
      "lfs": null,
      "oid": "602b71f15d40ed68c5f96330e3f3175a76a32126",
      "path": ".gitattributes",
      "security": null,
      "size": 445,
      "type": "file",
      "url": "https://huggingface.co/openai-community/gpt2/blob/main/.gitattributes",
      "xet_hash": null
    },
    "… 25 more"
  ],
  "next_cursor": null,
  "path": null,
  "revision": "main",
  "total_size": 5632417295,
  "type": "model"
}
```

## Error handling
400: Check the request fields.
401 / 403: Verify credentials and access permissions.
402: Inspect payment requirements and balance.
429: Respect returned retry guidance.
5xx: Inspect the error and usage record before retrying a paid operation.

## Common questions
### Can I list files in datasets and Spaces as well as models?
Yes. Set type to dataset or space, or pass a full huggingface.co URL in id to infer the repository type.

### How do I restrict the listing to a single folder?
Pass the folder path in path (for example onnx), and set recursive=false if you do not want nested subdirectories.

### Can I inspect files at a specific tag, branch or commit hash?
Yes. Pass the branch, tag or commit hash in revision (defaults to main).

### Does this API download the actual file bytes?
No. It returns file metadata, sizes, hashes and direct download_url links in JSON.

### How do I paginate repositories with many files?
Pass the returned next_cursor into cursor on subsequent calls until next_cursor is null.

### How do caching and field selection work?
Output is JSON only. Pass fresh=1 to skip the 24-hour cache, raw=0 to omit raw blocks, or fields to select specific keys.

## Available implementations
- apish: https://openany.si/hugging-face/hugging-face-repository-file-tree-api/8da07f3c-1178-433c-8b79-32bc7b25501e/

Integration guide: https://openany.si/docs/
Agent setup: https://openany.si/SKILL.md
