---
title: "Hugging Face API: model, dataset, Space search as JSON"
description: "Hugging Face API for model, dataset and Space search, and model and dataset details with downloads and licences as JSON. 1 credit per successful call."
url: https://perceptlayer.com/apis/huggingface
---

[APIs](https://perceptlayer.com/apis) / [Apps and media](https://perceptlayer.com/verticals/apps) / Hugging Face

1 credit per call 5 endpoints 9 datapoints 

# Hugging Face API

Hugging Face API for model, dataset and Space search, and model and dataset details with downloads and licences as JSON. 1 credit per successful call.

[Get a free API key](https://perceptlayer.com/signup) Run it below

Hugging Face

GET /v1/huggingface/models-search?query=llama&sort=downloads&limit=10 

```
{
  "success": true,
  "data": {
    "count": 10,
    "items": [
      {
        "id": "meta-llama/Llama-3.1-8B-Instruct",
        "author": "meta-llama",
        "task": "text-generation",
        "library": "transformers",
        "downloads": 3761846,
        "likes": 9241,
        "tags": [
          "transformers",
          "safetensors",
          "llama"
        ],
        "created_at": "2024-07-18T08:56:00.000Z",
        "url": "https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct"
      },
      {
        "id": "meta-llama/Llama-3.2-1B-Instruct",
        "author": "meta-llama",
        "task": "text-generation",
        "library": "transformers",
        "downloads": 1375502,
        "likes": 2060,
        "tags": [
          "transformers",
          "safetensors",
          "llama"
        ],
        "created_at": "2024-09-18T15:12:47.000Z",
        "url": "https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct"
      },
      {
        "id": "meta-llama/Llama-3.2-1B",
        "author": "meta-llama",
        "task": "text-generation",
        "library": "transformers",
        "downloads": 784116,
        "likes": 2835,
        "tags": [
          "transformers",
          "safetensors",
          "llama"
        ],
        "created_at": "2024-09-18T15:03:14.000Z",
        "url": "https://huggingface.co/meta-llama/Llama-3.2-1B"
      }
    ]
  },
  "meta": {
    "request_id": "req_5705d2131b524107ae8a3a3398ddab8d",
    "credits_charged": 1,
    "credits_remaining": 1999
  }
}
```

200 OK JSON X-Credits-Used: 1

Recorded from our API and shortened.

Sample data

## What one call returns

A recorded run of `models-search`: the fields and shapes you will get, shortened to 3 items.

| # | id string | author string | task string | library string | downloads integer | likes integer | tags string\[\] | created\_at string | url url |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 1 | meta-llama/Llama-3.1-8B-Instruct | meta-llama | text-generation | transformers | 3761846 | 9241 | \[3 items\] | 2024-07-18T08:56:00.000Z | https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct |
| 2 | meta-llama/Llama-3.2-1B-Instruct | meta-llama | text-generation | transformers | 1375502 | 2060 | \[3 items\] | 2024-09-18T15:12:47.000Z | https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct |
| 3 | meta-llama/Llama-3.2-1B | meta-llama | text-generation | transformers | 784116 | 2835 | \[3 items\] | 2024-09-18T15:03:14.000Z | https://huggingface.co/meta-llama/Llama-3.2-1B |

Recorded from our API · 3 items shown · 9 datapoints per item GET /v1/huggingface/models-search?query=llama&sort=downloads&limit=10

9 datapoints

### Identity

-   id string

### Contact

-   url url

### Other

-   author string
-   task string
-   library string
-   downloads integer
-   likes integer
-   tags string\[\]
-   created\_at string

Playground

## Run this API

cURL shell 

```
curl "https://api.perceptlayer.com/v1/huggingface/models-search?query=llama&sort=downloads&limit=10" \
  -H "X-API-Key: $API_KEY"
```

Hugging Face · 5 endpoints

## Endpoints

Every endpoint takes the same key. Open one for its parameters, the fields it returns and an example request.

| Endpoint | Required parameters | Returns | Cost |
| --- | --- | --- | --- |
| [GET `/v1/huggingface/dataset`](https://perceptlayer.com/apis/huggingface/dataset) | `id` | `id` `author` `description` `downloads` `likes` `gated` +13 more | 1 credit |
| [GET `/v1/huggingface/datasets-search`](https://perceptlayer.com/apis/huggingface/datasets-search) | none +4 optional | `id` `author` `description` `downloads` `likes` `gated` +4 more | 1 credit |
| [GET `/v1/huggingface/model`](https://perceptlayer.com/apis/huggingface/model) | `id` | `id` `author` `task` `library` `downloads` `likes` +18 more | 1 credit |
| [GET `/v1/huggingface/models-search`](https://perceptlayer.com/apis/huggingface/models-search) | none +6 optional | `id` `author` `task` `library` `downloads` `likes` +3 more | 1 credit |
| [GET `/v1/huggingface/spaces-search`](https://perceptlayer.com/apis/huggingface/spaces-search) | none +4 optional | `id` `author` `sdk` `likes` `tags` `created_at` +1 more | 1 credit |

Overview

## About the Hugging Face API

## What you can get

The Hugging Face API returns Hugging Face Hub data on models, datasets and Spaces as JSON through 5 endpoints. Ids take the form owner/name.

-   **Models:** `models-search` takes an optional `query`, with `author`, `task` (for example text-generation), `library` (for example transformers, diffusers or gguf), `sort` (downloads, likes, trending, last\_modified or created) and `limit` (1 to 100). `model` takes an `id`.
-   **Datasets:** `datasets-search` takes an optional `query`, with `author`, `sort` and `limit`. `dataset` takes an `id`.
-   **Spaces:** `spaces-search` takes an optional `query`, with `author`, `sort` (likes, trending, last\_modified or created) and `limit`.

The recorded `models-search` for "llama" sorted by downloads returns `items`, each with `id`, `author`, `task`, `library`, `downloads`, `likes`, `tags`, `created_at` and `url`. The first result, `meta-llama/Llama-3.1-8B-Instruct`, had 3,761,846 downloads and 9,241 likes. `model` adds `license`, `gated`, `languages`, `base_models`, `parameters` (8,030,261,248 for that model), `parameters_by_dtype`, `architectures`, `model_type`, `storage_bytes`, `file_count`, `files` and the Spaces that use it ( `spaces_count` and `spaces`).

## How a call works

Search, then look up: `GET /v1/huggingface/models-search?query=llama&sort=downloads&limit=10` with your key in the `X-API-Key` header returns each model's `id`; `model` takes that `id`, for example `GET /v1/huggingface/model?id=meta-llama/Llama-3.1-8B-Instruct`. Dataset ids from `datasets-search` go to `dataset` the same way. Searches have no page parameter: raise `limit` to 100 and narrow with `author`, `task` or `library`. Answers come from a cache for up to an hour, so downloads and likes can be up to an hour old. Every successful call costs 1 credit; failed calls cost nothing.

Apps and media JSON REST MCP

### More apps and media APIs

[Apple App Store](https://perceptlayer.com/apis/apple-app-store) [Apple Podcasts](https://perceptlayer.com/apis/apple-podcasts) [arXiv](https://perceptlayer.com/apis/arxiv) [Audible](https://perceptlayer.com/apis/audible) [Bandcamp](https://perceptlayer.com/apis/bandcamp) [Chrome Web Store](https://perceptlayer.com/apis/chrome-web-store) [CISA KEV](https://perceptlayer.com/apis/cisa-kev) [ClinicalTrials.gov](https://perceptlayer.com/apis/clinicaltrials) [Coursera](https://perceptlayer.com/apis/coursera) [crates.io](https://perceptlayer.com/apis/crates-io) [Crossref](https://perceptlayer.com/apis/crossref) [Discogs](https://perceptlayer.com/apis/discogs)

Use cases

### Shortlist open models for a task and library, ranked by downloads or likes

`Use the Hugging Face API to shortlist open models for a task and library, ranked by downloads or likes` 

### Compare parameter counts, licences and architectures before picking a model

`Use the Hugging Face API to compare parameter counts, licences and architectures before picking a model` 

### Trace a fine-tune to its base model with \`base\_models\`

`` Use the Hugging Face API to trace a fine-tune to its base model with `base_models` `` 

### Find training and evaluation datasets by name, with licence, languages and size category

`Use the Hugging Face API to find training and evaluation datasets by name, with licence, languages and size category` 

FAQ

## Questions

**How much does the Hugging Face API cost?**

Each successful call costs one credit, and each search is one call. New accounts get free credits to start, and credit packs bring the price down as you scale.

**Do gated models return their details?**

Yes. Gated models still return their metadata, with \`gated\` showing the access mode: \`manual\` for \`meta-llama/Llama-3.1-8B-Instruct\` in the recording. You get the model's details and file list, not the model weights.

**What does \`dataset\` return?**

The dataset card's opening text as \`description\`, plus \`pretty\_name\`, \`license\`, \`task\_categories\`, \`languages\`, \`size\_categories\`, \`downloads\`, \`likes\`, \`storage\_bytes\` and \`files\`. In the recording, \`rajpurkar/squad\` had 169,573 downloads, licence \`cc-by-sa-4.0\` and size category \`10K<n<100K\`.

**Do I need a Hugging Face account?**

No. You call this Hugging Face API with your Perceptlayer key in the \`X-API-Key\` header, with no Hugging Face login or token.

**Is this the official Hugging Face API?**

No. Perceptlayer is an independent service and is not affiliated with Hugging Face. It returns Hugging Face data as JSON with a Perceptlayer key, so there is no Hugging Face developer account, app review or partner approval to get first. It only reads data: if Hugging Face has an official API and you need to act on your own Hugging Face account, such as posting, managing orders or reading private data, use that one.

**Should I build a Hugging Face scraper instead?**

You can, but a Hugging Face scraper is code you maintain: page changes break it, requests get blocked, and Hugging Face's terms govern how you collect data. The Hugging Face API gives you 5 endpoints of named JSON fields for 1 credit per successful call, and failed calls cost nothing. A scraper makes sense only for data these endpoints don't return, so check the response in the playground on this page first.

## Try the Hugging Face API with 100 free credits

No credit card. Failed calls are never billed.

[Get a free API key](https://perceptlayer.com/signup) [Read the docs](https://docs.perceptlayer.com)
