# Hugging Face Hub API — Models, Datasets, Spaces (`lmhsolutions/huggingface-hub-scraper`) Actor

Scrape Hugging Face Hub models, datasets, and Spaces via the official public API. Downloads, likes, trending score, licenses, gated status, tasks, files, and health signals. No API key.

- **URL**: https://apify.com/lmhsolutions/huggingface-hub-scraper.md
- **Developed by:** [LMH Solutions](https://apify.com/lmhsolutions) (community)
- **Categories:** AI, Developer tools, Automation
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 hub items

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?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

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

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Hugging Face Hub Scraper — Models, Datasets & Spaces API

**SEO title:** Hugging Face Hub Scraper | Models, Datasets & Spaces Downloads, Likes & Licenses\
**SEO description:** Scrape Hugging Face models, datasets, and Spaces via the official Hub API. Get downloads, likes, trending score, licenses, gated flags, tasks, files, and a health score — no API key.

One Actor for the whole Hub. Search or look up **models, datasets, and Spaces** from the public Hugging Face Hub REST API and export clean JSON/CSV for AI research, competitive monitoring, RAG source discovery, and agent tooling.

### Why this beats typical Store competitors

Most Hub Actors cover **models only** (or split models/datasets into separate paid Actors) and stop at raw metadata. This one:

- Scrapes **models + datasets + Spaces in a single run**
- Adds a **healthScore** (popularity + freshness − gated penalty)
- Parses **licenses**, **pipeline/task tags**, **languages**, **file counts**, architectures, safetensors totals, Space SDK/title
- Supports **exact repo ID enrichment** plus Hub list pagination via `Link` cursors
- Uses the **official public API** — no browser, no proxies, no key required for public repos

### Example input

```json
{
  "resourceTypes": ["models", "datasets", "spaces"],
  "search": "llama",
  "sort": "downloads",
  "direction": "-1",
  "maxResultsPerType": 10,
  "includeFull": true,
  "includeConfig": true
}
```

### Example output (truncated)

```json
{
  "resourceType": "model",
  "id": "meta-llama/Llama-3.1-8B-Instruct",
  "author": "meta-llama",
  "downloads": 1234567,
  "likes": 8900,
  "trendingScore": 12,
  "pipelineTag": "text-generation",
  "libraryName": "transformers",
  "license": "llama3.1",
  "gated": "auto",
  "fileCount": 18,
  "hubUrl": "https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct",
  "healthScore": 84.2,
  "source": "huggingface.co"
}
```

### Suggested pay-per-event pricing

| Event | Suggested price |
| --- | --- |
| Actor start | $0.0005 |
| Per Hub item (model / dataset / Space) | **$0.002 – $0.005** |

At $0.003/item and 100k paid rows/month → ~$300 revenue → ~$240 after Apify’s 20%, minus tiny HTTP compute.

### Data source & limits

- API docs: https://huggingface.co/docs/hub/en/api
- Public list endpoints paginate with `Link: rel="next"` cursors; this Actor follows them until `maxResultsPerType`.
- Subject to Hugging Face rate limits; for heavy production traffic consider an optional HF token later (not required for this Actor).
- Not affiliated with Hugging Face.

### Changelog

- **1.0.0** — Unified models/datasets/Spaces scraper with health scores and Store-ready schema.

### Use cases

- **AI researchers & founders** — track downloads/likes for models in a task or library; spot rising GGUF / multimodal repos.
- **ML platform teams** — inventory gated vs open models and licenses before adopting Hub deps.
- **Competitive intel** — watch Spaces and datasets for a search query on a schedule.
- **Apify MCP / agents** — field-level dataset metadata helps agents pick `hubUrl`, `downloads`, and `healthScore`.

**Buyer task:** `ai-lab-hf-trending-models`.
**Examples:** https://github.com/LMH-Solutions/apify-open-data-actors (examples/hf_trend_watch.py)

# Actor input Schema

## `resourceTypes` (type: `array`):

Which Hub resources to scrape. Competitors usually cover only models — this Actor does models, datasets, and Spaces in one run.

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

Substring search across repo names and authors (e.g. llama, whisper, squad).

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

Limit to one author or org (e.g. meta-llama, openai, huggingface).

## `filter` (type: `string`):

Hub tag filter such as text-generation, license:mit, or task_categories:question-answering.

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

Sort field. trendingScore is great for discovery; downloads for popularity.

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

Use -1 for descending (most popular / newest first).

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

Optional exact Hub repo IDs to enrich (e.g. openai/gpt-oss-120b). When set, search is still run unless skipSearch is true.

## `skipSearch` (type: `boolean`):

If true and repoIds are provided, only fetch those exact repos.

## `maxResultsPerType` (type: `integer`):

Cap per resource type (models / datasets / spaces). Total rows ≈ this × number of types.

## `includeFull` (type: `boolean`):

Pass full=true to the Hub list API (tags, siblings/files, richer cards).

## `includeConfig` (type: `boolean`):

Also request config for models (architectures, model_type).

## Actor input object example

```json
{
  "resourceTypes": [
    "models",
    "datasets",
    "spaces"
  ],
  "search": "llama",
  "sort": "downloads",
  "direction": "-1",
  "repoIds": [],
  "skipSearch": false,
  "maxResultsPerType": 10,
  "includeFull": true,
  "includeConfig": true
}
```

# Actor output Schema

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

Items written to the default dataset via Actor.push_data().

# 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 = {
    "resourceTypes": [
        "models",
        "datasets",
        "spaces"
    ],
    "search": "llama",
    "sort": "downloads",
    "direction": "-1",
    "repoIds": [],
    "maxResultsPerType": 10,
    "includeFull": true,
    "includeConfig": true
};

// Run the Actor and wait for it to finish
const run = await client.actor("lmhsolutions/huggingface-hub-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 = {
    "resourceTypes": [
        "models",
        "datasets",
        "spaces",
    ],
    "search": "llama",
    "sort": "downloads",
    "direction": "-1",
    "repoIds": [],
    "maxResultsPerType": 10,
    "includeFull": True,
    "includeConfig": True,
}

# Run the Actor and wait for it to finish
run = client.actor("lmhsolutions/huggingface-hub-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 '{
  "resourceTypes": [
    "models",
    "datasets",
    "spaces"
  ],
  "search": "llama",
  "sort": "downloads",
  "direction": "-1",
  "repoIds": [],
  "maxResultsPerType": 10,
  "includeFull": true,
  "includeConfig": true
}' |
apify call lmhsolutions/huggingface-hub-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,lmhsolutions/huggingface-hub-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/0ePL3kqvOmykgtZPy/builds/h8MrW4FeJqz1Pepf0/openapi.json
