# HuggingFace Models Scraper (`purethought/huggingface-models-scraper`) Actor

Fetches AI model listings from the HuggingFace Hub API. Returns model ID, author, task, downloads, likes, tags, and URL.

- **URL**: https://apify.com/purethought/huggingface-models-scraper.md
- **Developed by:** [Ganesh B](https://apify.com/purethought) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 results

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

## HuggingFace Models Scraper

Fetches AI model listings from the [HuggingFace Hub API](https://huggingface.co/docs/hub/api). Returns model ID, author, task, downloads, likes, tags, and direct URL — ready for dataset export.

### What it does

- Queries the public HuggingFace Hub REST API (no auth required)
- Filters by ML task (e.g. `text-generation`, `image-classification`, `translation`)
- Sorts by downloads, likes, or last-modified date
- Paginates automatically until `maxItems` is reached
- Outputs one record per model to the Apify dataset

### Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `task` | string | `text-generation` | ML task filter (pipeline tag). Leave empty for all tasks. |
| `sortBy` | string | `downloads` | Sort field: `downloads`, `likes`, or `lastModified`. |
| `maxItems` | integer | `100` | Max models to return. Set to `0` for unlimited. |

### Output

Each record contains:

| Field | Description |
|-------|-------------|
| `model_id` | Full model identifier (e.g. `meta-llama/Llama-2-7b`) |
| `author` | Organization or user who published the model |
| `task` | Primary ML task (pipeline_tag) |
| `downloads` | Total download count |
| `likes` | Number of likes |
| `last_modified` | ISO 8601 date of last update |
| `tags` | Comma-separated model tags |
| `url` | Link to the model page on HuggingFace |
| `scrapedAt` | ISO 8601 timestamp of when the record was fetched |

### Quick Start

1. Find the actor in [Apify Store](https://apify.com/purethought)
2. Click **Try for free** and set your inputs
3. Click **Start** and wait for the run to finish
4. Download results as JSON, CSV, or via the API

### Sample Output

Each item in the dataset looks like this:

```json
{
  "model_id": "meta-llama/Llama-3.1-8B-Instruct",
  "author": "meta-llama",
  "task": "text-generation",
  "downloads": 18432100,
  "likes": 24830,
  "last_modified": "2024-10-02T14:22:00.000Z",
  "tags": "transformers, llama, text-generation, pytorch, safetensors",
  "url": "https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct",
  "scrapedAt": "2024-11-01T10:00:00.000Z"
}
```

### Example use cases

- Track the most-downloaded models in a given ML category
- Monitor new model releases in your area of interest
- Build a research index of available models by task

### API

This actor uses the public [HuggingFace Hub API](https://huggingface.co/docs/hub/api#get-apimodels):

```
GET https://huggingface.co/api/models?limit=100&sort=downloads&direction=-1&filter=text-generation&p=0
```

No authentication is required for public model listings.

# Actor input Schema

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

Filter by ML task (e.g. text-generation, image-classification, translation). Leave empty for all tasks.

## `sortBy` (type: `string`):

Sort models by: downloads, likes, or lastModified.

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

Maximum number of models to return. Set to 0 for unlimited.

## Actor input object example

```json
{
  "task": "text-generation",
  "sortBy": "downloads",
  "maxItems": 100
}
```

# Actor output Schema

## `dataset` (type: `string`):

Scraped HuggingFace model records with model ID, author, task, downloads, likes, and tags

# 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 = {
    "task": "text-generation",
    "sortBy": "downloads",
    "maxItems": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("purethought/huggingface-models-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 = {
    "task": "text-generation",
    "sortBy": "downloads",
    "maxItems": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("purethought/huggingface-models-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 '{
  "task": "text-generation",
  "sortBy": "downloads",
  "maxItems": 100
}' |
apify call purethought/huggingface-models-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,purethought/huggingface-models-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/BcUfMuZO40NV8XodK/builds/6Ho04rVmmEgKp3Ajw/openapi.json
