# Hugging Face models + datasets - search, metadata (Hub API) (`retrainmap/huggingface-models`) Actor

Hugging Face Hub scraper on the public API: search models or datasets by term, task, library, license, language or author; one row each - id, author, task, library, license, downloads, likes, last modified, tags, gated, URL. No token needed. $5 per 1,000 rows + $0.10 per run.

- **URL**: https://apify.com/retrainmap/huggingface-models.md
- **Developed by:** [RetrainMap Team](https://apify.com/retrainmap) (community)
- **Categories:**
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 records

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Hugging Face models + datasets - search, metadata (Hub API)

**Returns:** one row per Hugging Face model or dataset: id, author, name, task (pipeline tag / task category), library, license, languages, downloads (30-day), likes, trending score, last modified, created, gated/private flags, file count, tags, description (datasets), Hub URL.
**Input:** `{ "kind": "models", "search": "llama", "task": "text-generation", "license": "apache-2.0", "sort": "downloads", "max_records": 100 }` — all optional; empty `{}` returns the 100 most-downloaded models.
**Price:** $5.00 per 1,000 rows ($0.005 per row) plus $0.10 per run. Pay per event; no subscription.

Search the Hugging Face Hub — models or datasets — by term, task, library, license,
language, author or any Hub tag, sorted by downloads, likes, recency or trending score, and
get a flat, normalised row per repo, ready for CSV or JSON: model landscape tables, license
audits, "what is popular for task X", dataset inventories. No token needed: it reads the
public `huggingface.co/api` endpoints the Hub website uses. An optional read token raises the
Hub's rate limits.

**The default input (models matching `llama`, most downloaded first, 100 rows) succeeds
within 5 minutes and returns rows** — Apify auto-tests it daily.

### Data source and status

| | |
|---|---|
| Publisher | Hugging Face, Inc. — the Hub (https://huggingface.co) |
| API | `GET /api/models` and `GET /api/datasets` with `search`, `author`, `filter` (comma-separated ANDed tags), `sort`, `direction=-1`, `limit=100`, `full=true`. Public, no key. Documentation: https://huggingface.co/docs/hub/api |
| What this Actor reads | Plain GET requests, at most one per `request_interval_ms` (default 500 ms); paging follows the API's `Link: rel="next"` cursor header |
| Refresh cadence | Live on every run — `downloads` is the Hub's rolling 30-day figure, `likes` and `last_modified` are current; `fetched_at` on each row is the fetch time |
| Terms | Hugging Face Terms of Service and Hub API guidelines apply (https://huggingface.co/terms-of-service). Repo metadata is public; model and dataset *contents* carry their own licenses (the `license` column) — this Actor never downloads files |
| Known caveats | The API gives no total match count; `task` is empty for models without a pipeline tag; `license` comes from `cardData.license` or the `license:` tag and is empty when the author set none; datasets have no `library` (the `format:` tag is used instead) and carry a `description` (first 500 chars of the card); `gated` is `false`, `true`, `"auto"` or `"manual"`; `search` is a substring match on the repo id, not full-text |

Honesty note: the rows are the Hub API's own fields renamed and flattened — nothing is
inferred, summarised or classified by this Actor, and a run stops with an error rather than
guess when the API's shape changes.

Identification: the requests carry a product-token User-Agent and the operator's contact
address in the standard `From:` header (RFC 9110 §10.1.2).

### Input

| Field | Type | Meaning |
|---|---|---|
| `kind` | `models` / `datasets` | Which catalogue (default models) |
| `search` | string | Substring on the repo id, e.g. `llama`, `whisper`, `squad` |
| `task` | string | Models: pipeline tag (`text-generation`, `text-classification`, ...). Datasets: task category (`question-answering`, ...) |
| `library` | string | `transformers`, `pytorch`, `safetensors`, `diffusers`, `gguf`, ... |
| `license` | string | `apache-2.0`, `mit`, `llama3`, `cc-by-4.0`, ... |
| `language` | string | ISO code, e.g. `en` |
| `author` | string | Hub user or organisation, e.g. `meta-llama` |
| `extra_filters` | array | Further Hub tags, ANDed |
| `sort` | string | `downloads` (default), `likes`, `lastModified`, `createdAt`, `trendingScore` |
| `max_records` | integer | Default 100, at most 20,000 |
| `max_tags` | integer | Tags kept per row (default 40; `tag_count` carries the total) |
| `hf_token` | secret string | Optional `hf_...` read token — raises rate limits, never logged |
| `request_interval_ms` | integer | Default 500 (floor 200) |
| `contact_email` | string | Sent in the `From:` header |

Example — the 30 most-liked English question-answering datasets under the MIT license:

```json
{ "kind": "datasets", "task": "question-answering", "license": "mit", "language": "en", "sort": "likes", "max_records": 30 }
```

### Output (dataset row)

`id`, `kind` (model / dataset), `author`, `name`, `task`, `library`, `license`, `languages`,
`downloads`, `likes`, `trending_score`, `last_modified`, `created_at`, `gated`, `private`,
`disabled`, `sha`, `file_count`, `tag_count`, `tags`, `description`, `url`, `api_url`,
`fetched_at`, `source`.

A run summary (filters, pages, requests, whether a token was used, whether the pay-per-event
budget stopped the run) is stored as `RUN_SUMMARY` in the run's key-value store.

### Pricing (pay per event)

| Event | Price |
|---|---|
| `run-start` — once per run | $0.10 |
| `record` — per row written | $0.005 |

The default run (100 rows) costs $0.60; 1,000 rows cost $5.10. Rows stop when your run's
maximum charge is reached; the run summary says so.

### Operator

Steelyard Ventures LLC (RetrainMap) — info@steelyardclinical.com. Not affiliated with Hugging
Face, Inc. The Actor writes only to its own dataset and key-value store; the optional token
is used for the Hub requests only and is never stored or logged.

# Actor input Schema

## `kind` (type: `string`):

Which Hub catalogue to search.

## `search` (type: `string`):

Substring match on the repo id, e.g. llama, bert, whisper, squad. Empty = no term filter.

## `task` (type: `string`):

Models: pipeline tag such as text-generation, text-classification, automatic-speech-recognition, image-classification. Datasets: task category such as question-answering, summarization.

## `library` (type: `string`):

Models: transformers, pytorch, safetensors, diffusers, gguf, sentence-transformers ... (a Hub tag).

## `license` (type: `string`):

e.g. apache-2.0, mit, llama3, cc-by-4.0 (matched as the license: tag).

## `language` (type: `string`):

ISO code such as en, de, ja (matched as the language: tag).

## `author` (type: `string`):

Hub user or org, e.g. meta-llama, google, openai.

## `extra_filters` (type: `array`):

Any further Hub tags, ANDed, e.g. region:us, arxiv:2307.09288, dataset:wikipedia, size\_categories:1M\<n<10M.

## `sort` (type: `string`):

Descending order key.

## `max_records` (type: `integer`):

Stop after this many rows have been written.

## `max_tags` (type: `integer`):

Keep at most this many tags per row (0 = none; tag\_count always carries the total).

## `hf_token` (type: `string`):

Optional read token (hf\_...) sent as Authorization: Bearer. Raises the Hub's rate limits; not needed for public data. Stored encrypted, never logged or written to the dataset.

## `request_interval_ms` (type: `integer`):

Politeness delay towards huggingface.co. Each request returns up to 100 rows; floor 200 ms.

## `contact_email` (type: `string`):

Sent in the standard From: request header so the data owner can reach the operator (RFC 9110 s10.1.2).

## Actor input object example

```json
{
  "kind": "models",
  "search": "llama",
  "sort": "downloads",
  "max_records": 100,
  "max_tags": 40,
  "request_interval_ms": 500,
  "contact_email": "info@steelyardclinical.com"
}
```

# Actor output Schema

## `results` (type: `string`):

Every matched model or dataset as one row: id, author, task, library, license, downloads, likes, last modified, tags, gated flag, URL.

## `results_csv` (type: `string`):

The same rows as a CSV file.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "search": "llama"
};

// Run the Actor and wait for it to finish
const run = await client.actor("retrainmap/huggingface-models").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "search": "llama" }

# Run the Actor and wait for it to finish
run = client.actor("retrainmap/huggingface-models").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "search": "llama"
}' |
apify call retrainmap/huggingface-models --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,retrainmap/huggingface-models"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/LTeWagXAcs8yfCfCx/builds/t48kWtd8lozAfZBAV/openapi.json
