# HuggingFace Hub Scraper (`crawlerbros/huggingface-scraper`) Actor

Scrape Hugging Face Hub, search and fetch models, datasets, and spaces with full metadata: downloads, likes, license, pipeline tag, library, tags, files, and more. Pure HTTP, no auth required.

- **URL**: https://apify.com/crawlerbros/huggingface-scraper.md
- **Developed by:** [Crawler Bros](https://apify.com/crawlerbros) (community)
- **Categories:** AI, Developer tools, Automation
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## HuggingFace Hub Scraper

Scrape the [Hugging Face Hub](https://huggingface.co) — 1M+ machine-learning models, 200K+ datasets, 400K+ Spaces, and millions of user profiles. Search by query, fetch by repo ID or URL, list trending repos, or pull a user's overview. Pure HTTP via the official public Hub API at `huggingface.co/api/*`. No auth, no proxy, no cookies.

### What this actor does

- **7 modes:** `search`, `byModel`, `byDataset`, `bySpace`, `byUser`, `trending`, `byUrl`
- **Three entity catalogs:** models, datasets, spaces (search & trending pivot on `entityType`)
- **Filters:** pipeline tag, library, license, language, author/org, min downloads, min likes
- **Server-side sort:** trending score, downloads, likes, last modified, created at
- **URL auto-detection:** paste any `huggingface.co/<repo>` or `/datasets/<id>` or `/spaces/<id>` or `/users/<u>` URL — the actor figures out the kind
- **Optional `?full=true`:** include sibling files, cardData, config metadata
- **Empty fields are omitted** — every record only contains populated fields

### Output

The actor emits a flat record per repo / user. Fields you might see (omit-empty applies):

#### Common

- `recordType` — `model` / `dataset` / `space` / `user`
- `repoId` — full Hub identifier (e.g. `google-bert/bert-base-uncased`)
- `owner` — author / organization slug
- `sha`, `createdAt`, `lastModified`
- `downloads`, `likes`, `trendingScore`
- `license`, `tags`, `languages`
- `scrapedAt`

#### Model-only

- `modelName`, `modelType`, `architectures[]`
- `pipelineTag`, `libraryName`
- `trainedOnDatasets[]`, `arxivIds[]`
- `maskToken`, `fileCount`, `files[]`
- `modelUrl`

#### Dataset-only

- `datasetName`, `description`
- `taskCategories[]`, `taskIds[]`
- `modalities[]`, `formats[]`, `sizeCategories[]`
- `paperswithcodeId`, `fileCount`, `files[]`
- `datasetUrl`

#### Space-only

- `spaceName`, `sdk`, `runtimeStage`
- `title`, `emoji`, `host`, `subdomain`
- `fileCount`, `files[]`
- `spaceUrl`

#### User-only

- `username`, `fullName`, `avatarUrl`, `isPro`
- `numModels`, `numDatasets`, `numSpaces`
- `numFollowers`, `numFollowing`, `numLikes`, `numUpvotes`
- `numPapers`, `numDiscussions`
- `orgs[]`, `profileUrl`

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `mode` | enum | `search` | One of the 7 modes |
| `entityType` | enum | `models` | `models` / `datasets` / `spaces` (mode=search/trending) |
| `searchQuery` | string | `bert` | Free-text query |
| `repoIds` | array | – | Repo IDs or URLs (mode=byModel/byDataset/bySpace) |
| `username` | string | – | Username (mode=byUser) |
| `startUrls` | array | – | Hub URLs (mode=byUrl) — kind auto-detected |
| `pipelineTag` | enum | – | Filter models by task tag (43 options) |
| `libraryName` | enum | – | Filter models by library (17 options) |
| `authorFilter` | string | – | Constrain to org/author slug |
| `license` | enum | – | License filter (29 options) |
| `language` | string | – | 2-letter language code |
| `sort` | enum | – | `trendingScore` / `downloads` / `likes` / `lastModified` / `createdAt` |
| `direction` | enum | `desc` | `desc` or `asc` |
| `minDownloads` | integer | – | Drop records below this download count |
| `minLikes` | integer | – | Drop records below this like count |
| `includeFullDetails` | boolean | `false` | Pass `?full=true` for siblings/config |
| `maxItems` | integer | `50` | Hard cap (1–10000) |

### Examples

#### Search top BERT models

```json
{
  "mode": "search",
  "entityType": "models",
  "searchQuery": "bert",
  "sort": "downloads",
  "maxItems": 50
}
```

#### Trending text-generation models

```json
{
  "mode": "trending",
  "entityType": "models",
  "pipelineTag": "text-generation",
  "maxItems": 25
}
```

#### Lookup a specific dataset

```json
{
  "mode": "byDataset",
  "repoIds": ["rajpurkar/squad_v2"]
}
```

#### Lookup by URL (auto-detect)

```json
{
  "mode": "byUrl",
  "startUrls": [
    "https://huggingface.co/google-bert/bert-base-uncased",
    "https://huggingface.co/datasets/squad",
    "https://huggingface.co/spaces/lmarena-ai/chatbot-arena"
  ]
}
```

#### User profile

```json
{
  "mode": "byUser",
  "username": "julien-c"
}
```

### Reliability

- Direct calls to the official `huggingface.co/api/*` endpoints
- Exponential backoff retries on `429`, `500`–`504`
- Page size capped at 100 (the API hard cap); paginated via `?skip=N&limit=N`
- No proxy needed — works from datacenter IPs
- No cookies / API token required for read access

### Limitations

- Private repos require a user access token; this actor only exposes the public read API.
- The `language` and `license` filters are forwarded to the Hub API and applied server-side. The Hub's filtering is best-effort: some matching repos lack a `language:<code>` / `license:<id>` tag (the metadata lives in the model card). If you need strict tag-based filtering, post-filter the dataset on `languages[]` / `license`.
- The `?full=true` flag is rate-limited harder by the upstream; expect slower runs when enabled at large `maxItems`.
- Single-segment legacy repo IDs (e.g. `bert-base-uncased`) are auto-resolved by the API to their canonical owner-prefixed form (e.g. `google-bert/bert-base-uncased`).

### FAQ

**Do I need a Hugging Face account / API token?** No. The Hub's read API is public.

**How fresh is the data?** Real-time — every run hits the live API.

**Can I download model weights?** No. This actor exposes Hub *metadata* — repo info, files list, license, tags, etc. To download weights, use the [huggingface\_hub Python library](https://huggingface.co/docs/huggingface_hub) with the `repoId` from this actor's output.

**Why are some fields missing?** Empty / null fields are omitted — only populated fields appear in the output.

**Why does my license filter return fewer results than expected?** Many repos don't tag their license. Records without a `license:*` tag are excluded when the license filter is set.

# Actor input Schema

## `mode` (type: `string`):

What to fetch from the Hub. Use `search` for free-text discovery, `byModel`/`byDataset`/`bySpace` for specific repos, or `byUrl` to auto-detect from a Hugging Face URL.

## `entityType` (type: `string`):

Which Hub catalog to search or browse: models, datasets, or spaces.

## `searchQuery` (type: `string`):

Free-text search; matches repo name, description, and tags.

## `repoIds` (type: `array`):

Hub repo IDs like `bert-base-uncased`, `google-bert/bert-base-uncased`, or full URLs.

## `username` (type: `string`):

Hugging Face username (or organization name).

## `startUrls` (type: `array`):

Full huggingface.co URLs (model, dataset, space, or user pages).

## `pipelineTag` (type: `string`):

Filter models by their primary task tag (e.g. text-generation, image-classification). Applied as a server-side filter on `mode=search`/`trending`; otherwise post-filter.

## `libraryName` (type: `string`):

Filter models by their primary library / framework.

## `authorFilter` (type: `string`):

Constrain results to a specific author / org slug (e.g. `google`, `meta-llama`).

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

Filter to a specific license (post-fetch filter).

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

Filter records whose tags contain this 2-letter language code (e.g. `en`, `fr`, `zh`).

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

Server-side sort key. Leave blank for relevance-based sort.

## `direction` (type: `string`):

Direction for the `sort` key.

## `minDownloads` (type: `integer`):

Drop records with fewer downloads than this.

## `minLikes` (type: `integer`):

Drop records with fewer likes than this.

## `includeFullDetails` (type: `boolean`):

Request `?full=true` from the Hub API to include sibling files, cardData, config, and tags. Heavier payloads but richer records.

## `maxItems` (type: `integer`):

Hard cap on emitted records.

## Actor input object example

```json
{
  "mode": "search",
  "entityType": "models",
  "searchQuery": "bert",
  "repoIds": [],
  "startUrls": [],
  "pipelineTag": "",
  "libraryName": "",
  "license": "",
  "sort": "",
  "direction": "desc",
  "includeFullDetails": false,
  "maxItems": 50
}
```

# Actor output Schema

## `records` (type: `string`):

Dataset containing all scraped Hugging Face records.

# 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 = {
    "mode": "search",
    "entityType": "models",
    "searchQuery": "bert",
    "repoIds": [],
    "startUrls": [],
    "direction": "desc",
    "includeFullDetails": false,
    "maxItems": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("crawlerbros/huggingface-scraper").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 = {
    "mode": "search",
    "entityType": "models",
    "searchQuery": "bert",
    "repoIds": [],
    "startUrls": [],
    "direction": "desc",
    "includeFullDetails": False,
    "maxItems": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("crawlerbros/huggingface-scraper").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 '{
  "mode": "search",
  "entityType": "models",
  "searchQuery": "bert",
  "repoIds": [],
  "startUrls": [],
  "direction": "desc",
  "includeFullDetails": false,
  "maxItems": 50
}' |
apify call crawlerbros/huggingface-scraper --silent --output-dataset

```

## MCP server setup

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

```

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/j5KYM0hS4maMhLARz/builds/AQLTOZVthiw6aG2tP/openapi.json
