# Hugging Face Trend & Delta Tracker (`wdurham/hf-trend-tracker`) Actor

Snapshot trending Hugging Face models, datasets and Spaces via the official Hub API and track downloads, likes and rank changes, new entrants and drop-outs between runs.

- **URL**: https://apify.com/wdurham/hf-trend-tracker.md
- **Developed by:** [William Durham](https://apify.com/wdurham) (community)
- **Categories:** AI, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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 Trend & Delta Tracker

Track what is rising on the Hugging Face Hub. Each run snapshots the top trending (or most downloaded / most liked) **models, datasets and Spaces**, compares them with the previous run and tells you what changed: downloads Δ, likes Δ, rank movement, **new entrants** and **dropped-out** repos.

It uses only the **official Hugging Face Hub JSON API** (`/api/models`, `/api/datasets`, `/api/spaces`). It does not scrape HTML, and public data needs no API key.

### What it does

- Fetches the top N repos per resource type, sorted by `trendingScore`, `downloads`, `likes`, `createdAt` or `lastModified`.
- Filters by task (`pipeline_tag`), library, license, author/org and search text, plus raw Hub tag filters.
- Always tracks a **watchlist** of repos you name, even when they are not in the top N.
- Saves each snapshot in a **named key-value store** (default `hf-trend-state`), so it survives between runs, and computes deltas against the last one.
- The **first run is a baseline**: delta fields are `null` and `is_baseline` is `true`.
- Optionally **POSTs a compact JSON summary** (top movers, new entrants, dropped out) to a webhook, with a minimum-delta threshold.
- Is polite to the API: a delay between requests, 30 s timeouts, and retries with exponential backoff on HTTP 429/5xx (honouring `Retry-After`).

### Use cases

- A daily "what's hot in open-source AI" feed for newsletters, Slack or Discord.
- Spot fast-rising models in one task, such as `text-to-image` or `text-generation`, before they go mainstream.
- Monitor your own org's repos (watchlist or `author`) for download and like growth.

### Input example

```json
{
  "resourceTypes": ["models", "datasets", "spaces"],
  "sort": "trendingScore",
  "limit": 50,
  "pipelineTag": "text-generation",
  "license": "apache-2.0",
  "watchlist": ["openai-community/gpt2", "datasets/HuggingFaceFW/fineweb", "spaces/huggingface/inference-playground"],
  "mode": "delta",
  "stateStoreName": "hf-trend-state",
  "minDeltaThreshold": 100,
  "webhookUrl": "https://example.com/hooks/hf-trends"
}
```

Watchlist ids without a prefix are treated as models. Use the `datasets/` or `spaces/` prefix for the other types. `pipelineTag` applies to models only.

### Output

One dataset item per repo:

```json
{
  "id": "deepseek-ai/DeepSeek-V4.1-Flash-1017",
  "type": "model",
  "url": "https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash-1017",
  "author": "deepseek-ai",
  "pipeline_tag": "image-text-to-text",
  "library": "transformers",
  "license": "mit",
  "downloads": 116770,
  "likes": 3544,
  "trendingScore": 918,
  "rank": 1,
  "prev_rank": 2,
  "rank_change": 1,
  "prev_downloads": 110000,
  "downloads_delta": 6770,
  "prev_likes": 3500,
  "likes_delta": 44,
  "prev_trendingScore": 900,
  "trendingScore_delta": 18,
  "is_new": false,
  "is_baseline": false,
  "source": "list",
  "created_at": "2026-10-17T02:40:38.000Z",
  "last_modified": "2026-10-17T05:46:55.000Z",
  "snapshot_at": "2026-10-29T08:00:00+00:00",
  "prev_snapshot_at": "2026-10-28T08:00:00+00:00"
}
```

(Values are illustrative.)

- `rank_change` is positive when a repo moved **up**.
- `is_new: true` means the repo was not in the previous snapshot.
- Repos that dropped out of the list are emitted as extra items with `dropped_out: true` and their previous values.
- `library` holds `library_name` for models and the Space SDK (`gradio`, `docker` and so on) for Spaces. Datasets have none.
- Spaces have no download counts, so their download fields are `null`.
- `source` is `list` or `watchlist`.

Each run also writes a `SUMMARY` record to the default key-value store. It has the same JSON shape as the webhook payload: counts, `top_movers`, `new_entrants` and `dropped_out`.

### Scheduling tip

Deltas only make sense over time. Create a **Schedule** in Apify Console (for example daily at 08:00) that runs a saved task with fixed input. Hub download counters are rolling 30-day values that update a few times a day, so daily or every 6 to 12 hours works best. Runs a few minutes apart usually show zero deltas.

If you track several configurations (different sorts or filters), give each its own `stateStoreName`. Otherwise they overwrite each other's baseline. The snapshot is also keyed by `sort`.

### Limitations

- `downloads` on the Hub is a rolling ~30-day count, not a lifetime total. A negative `downloads_delta` is normal.
- `trendingScore` is computed by Hugging Face. Its exact formula is not public.
- The license is read from the repo's `license:*` tag. Repos without that tag show `null`.
- The library filter is applied as a Hub tag filter. It may also match repos that only carry the tag.
- Private or gated repos need a token with access (`hfToken`). Missing watchlist repos are logged and skipped.
- The snapshot is saved only at the end of a run that completes. An aborted run leaves the previous baseline untouched.
- Webhooks fire only on non-baseline runs that have at least one mover above the threshold or a new entrant. Delivery is attempted once.

### Cost

The Actor makes a handful of light JSON API requests per run: one per resource type plus one per watchlist repo. A typical run takes well under a minute on the smallest memory setting (256 MB is enough).

# Actor input Schema

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

Which Hub resources to snapshot.

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

Ranking used for the list (descending). Note: Spaces have no downloads; sorting Spaces by downloads is not meaningful.

## `limit` (type: `integer`):

How many top items to fetch per resource type (1-1000).

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

e.g. text-generation, text-to-image. Applies to models only.

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

e.g. transformers, diffusers, gguf. Applied as a Hub tag filter for models and datasets.

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

e.g. mit, apache-2.0 (matched as license:<value> tag).

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

Only repos owned by this user or org, e.g. meta-llama.

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

Substring search on repo id.

## `extraFilters` (type: `array`):

Additional raw Hub `filter` values (tags), e.g. region:us, gguf.

## `watchlist` (type: `array`):

Explicit repo ids to always track. Models: org/name. Prefix datasets/ or spaces/ for those types, e.g. datasets/HuggingFaceFW/fineweb.

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

delta = compare with the stored previous snapshot and save the new one; snapshot = output current values only, without reading or writing state.

## `stateStoreName` (type: `string`):

Named key-value store holding the previous snapshot. Use different names for different tracking configurations.

## `minDeltaThreshold` (type: `integer`):

A repo counts as a 'top mover' only if |likes Δ|, |downloads Δ| or |rank change| reaches this value.

## `webhookUrl` (type: `string`):

Optional. A compact JSON summary (top movers, new entrants, dropped out) is POSTed here at the end of non-baseline runs when there is something to report.

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

Optional read token for higher rate limits. Not needed for public data.

## `requestDelaySecs` (type: `number`):

Politeness delay between API calls.

## `maxRetries` (type: `integer`):

Retries with exponential backoff on HTTP 429/5xx and network errors.

## Actor input object example

```json
{
  "resourceTypes": [
    "models",
    "datasets",
    "spaces"
  ],
  "sort": "trendingScore",
  "limit": 50,
  "watchlist": [
    "openai-community/gpt2"
  ],
  "mode": "delta",
  "stateStoreName": "hf-trend-state",
  "minDeltaThreshold": 0,
  "requestDelaySecs": 0.5,
  "maxRetries": 5
}
```

# Actor output Schema

## `results` (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 = {
    "resourceTypes": [
        "models",
        "datasets",
        "spaces"
    ],
    "watchlist": [
        "openai-community/gpt2"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("wdurham/hf-trend-tracker").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",
    ],
    "watchlist": ["openai-community/gpt2"],
}

# Run the Actor and wait for it to finish
run = client.actor("wdurham/hf-trend-tracker").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"
  ],
  "watchlist": [
    "openai-community/gpt2"
  ]
}' |
apify call wdurham/hf-trend-tracker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,wdurham/hf-trend-tracker"
        }
    }
}
```

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/Rbns7gGYlTlTOhpkb/builds/yboF2Fy58xlbOHsYZ/openapi.json
