# Huggingface Trends (`shadowell/huggingface-trends`) Actor

- **URL**: https://apify.com/shadowell/huggingface-trends.md
- **Developed by:** [FENG JIE](https://apify.com/shadowell) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

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 Model Trends

Trending models, datasets and spaces from the **official Hugging Face Hub API** (`/api/models?sort=trendingScore`), grouped by task (`pipeline_tag`) and library, with likes / downloads / trending-score / rank changes measured against daily snapshots.

Companion to [GitHub Trends](https://apify.com/shadowell/github-trends) in the "AI open-source trends" series.

### Modes

- **query** (default): fetches the live top N repos (default 500) and outputs
  - `category` rows: per task / library (plus `all`): repo count, total trending score, downloads, likes, and — when a baseline snapshot exists — `likesGained`, `downloadsChange`, `trendingScoreChange`, `newRepos`.
  - `repo` rows: top N per category with `id`, `author` (org/user prefix of the id), `task`, `library`, `license`, `trendingScore`, `downloads`, `likes`, `rank`, and change fields (`prevRank`, `rankChange`, `likesGained`, `downloadsChange`, `trendingScoreChange`, `isNew`).
- **snapshot**: schedule daily. Stores the top 1,000 trending repos per type in the named KV store `huggingface-trends-snapshots` as `snap-YYYY-MM-DD` (UTC). Snapshot rows are never charged.

Change fields appear once a snapshot from N–2N days ago exists (1d window: the day after the first snapshot; 7d: after 7 days).
`downloads` is Hugging Face's rolling 30-day count, so `downloadsChange` is the change of that rolling count.

### Notes

- No login, proxy or scraping: public Hub API only. Optional `hfToken` only raises rate limits (anonymous: 500 API requests / 5 min; a default run uses 1 request).
- Retries with backoff on 429 / 5xx (honours the `RateLimit` header), dedup by repo id.
- Repo-level public metadata only; no user profile data.
- Pricing (when pay-per-event is enabled): `query-start` per query run and `model-row` per repo row; category and snapshot rows are free.

# Actor input Schema

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

query: live trending ranking from the official Hub API, grouped by task and library, with changes vs a stored snapshot when available. snapshot: scheduled daily job that stores the current top trending repos (free, no dataset rows charged).

## `repoType` (type: `string`):

What to rank. Datasets are grouped by task_categories tags; spaces by SDK (as 'library').

## `window` (type: `string`):

Compare to the snapshot taken this many days ago (latest one between N and 2N days ago). 'none' = live ranking only.

## `groupBy` (type: `array`):

Any of 'task' (pipeline_tag) and 'library'. An 'all' group is always included.

## `topN` (type: `integer`):

Repo rows per category.

## `maxCategories` (type: `integer`):

Keep the categories with the highest total trending score.

## `pipelineTags` (type: `array`):

e.g. text-generation, image-text-to-text, text-to-image. Empty = all.

## `libraries` (type: `array`):

e.g. transformers, diffusers, gguf, mlx. Empty = all.

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

Optional substring filter on repo id (Hub 'search' param).

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

Optional: only repos of this author or organization, e.g. deepseek-ai.

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

Hub API sort order for fetching.

## `fetchLimit` (type: `integer`):

How many repos to pull from the Hub API (1,000 per request) before grouping.

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

Drop repos with fewer likes.

## `includeCategoryRows` (type: `boolean`):

Free aggregate rows per category (counts, sums, changes).

## `hfToken` (type: `string`):

Optional read token, only to raise rate limits (anonymous: 500 API requests / 5 min).

## `snapshotTypes` (type: `array`):

Snapshot mode: any of models, datasets, spaces.

## `snapshotLimit` (type: `integer`):

Snapshot mode: top N trending repos stored per type.

## `snapshotStoreName` (type: `string`):

Named key-value store for daily snapshots (snap-YYYY-MM-DD, UTC).

## Actor input object example

```json
{
  "mode": "query",
  "repoType": "models",
  "window": "7d",
  "groupBy": [
    "task",
    "library"
  ],
  "topN": 10,
  "maxCategories": 15,
  "sort": "trendingScore",
  "fetchLimit": 500,
  "minLikes": 0,
  "includeCategoryRows": true,
  "snapshotTypes": [
    "models"
  ],
  "snapshotLimit": 1000,
  "snapshotStoreName": "huggingface-trends-snapshots"
}
```

# Actor output Schema

## `trends` (type: `string`):

No description

## `summary` (type: `string`):

No description

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("shadowell/huggingface-trends").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("shadowell/huggingface-trends").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 '{}' |
apify call shadowell/huggingface-trends --silent --output-dataset

```

## MCP server setup

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

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/NpWtwC0rxub9YCsvO/builds/OpX4GAjajuxosbKSn/openapi.json
