# GitHub Trends (Official GitHub API snapshots) (`shadowell/github-trends`) Actor

- **URL**: https://apify.com/shadowell/github-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

## GitHub Trends (Official GitHub API snapshots)

"Google Trends for GitHub": which categories (AI agents, backend, frontend, DevOps, …) and which repositories gained the most stars and forks in a window, compared with the previous period.

Gains are **exact differences of `stargazers_count` / `forks_count`** between daily snapshots taken from the official GitHub API. No GH Archive event counts, no scraping of github.com.

### How it works

1. **Tracked universe** (rebuilt every `universeRefreshDays`, default 7): for each category, GitHub Search API queries per topic – `topic:X stars:>=universeMinStars` (top by stars) and `topic:X created:>DATE stars:>=50` (fast risers) – up to `maxReposPerCategory`. Previously tracked repos are kept so history continues. `extraRepos` are always tracked.
2. **`mode: snapshot`** (schedule daily, e.g. 00:30 UTC): fetches current stars, forks, language, topics and description for all tracked repos. With a token it uses GraphQL (`repository(owner,name)` aliases, `graphqlBatchSize` per query, default 50); without a token it falls back to REST, one request per repo. Stores `snap-YYYY-MM-DD` = `{full_name: [stars, forks]}` in the named store `github-trends-snapshots`, and metadata in `github-trends-meta`.
3. **`mode: query`**: gain = snapshot(end) − snapshot(baseline). Baseline = latest snapshot on/before the window start; end = latest snapshot on/before the window end. The previous period uses the snapshot before the baseline. If history is insufficient the Actor returns a `coverage` record with `historyDays` and `coverageNote` instead of numbers.

Deleted, private or inaccessible repos (GraphQL null / REST 404) are listed as `missingRepos` and excluded, never counted as negative gains. Renamed repos are kept under the tracked name (`renamedTo` in metadata). A real decrease in stars is reported as a negative gain.

### Rate limits and capacity (docs.github.com)

- REST: 60 requests/hour unauthenticated, 5,000/hour with a personal token.
- Search API: 10 requests/minute unauthenticated, 30/minute authenticated; max 1,000 results per query.
- GraphQL: token required; 5,000 points/hour per user; a query costs at least 1 point; secondary limit 2,000 points/minute.

Approximate capacity per hour of runtime: **without a token ~50 repos** (REST; a partial snapshot is stored and marked `complete: false` when the limit is reached). **With a token via REST up to ~4,900 repos; via GraphQL with 50 repos/query, thousands of repos for a few dozen to a few hundred points** (the actual point cost is read from `rateLimit.cost` and reported in `SUMMARY.apiCalls.graphqlPoints`).

### Categories

Built-in: AI Agents & LLM, Data & ML, Frontend, Backend, DevOps & Infra, Database, Security, Mobile, CLI Tools. Classification prefers repo topics; description/name matches need one strong term (e.g. "llm", "model context protocol") or two distinct weaker terms (e.g. "agent" + "openai"), with word boundaries. Custom categories: `{name, topics, keywords, languages}`; their keywords count as strong. A repo may belong to several categories.

### Output

- `type: "category"`: category, starsGained, forksGained, trackedRepos, repoCount, prevStarsGained, prevForksGained, starsChangePct, forksChangePct, historyDays, baselineDate, endDate, coverageNote.
- `type: "repo"`: category, rank, full_name, url, starsGained, forksGained, prevStarsGained, totalStars, language, description.
- `type: "coverage"` (insufficient history) and `type: "snapshot"` (snapshot mode).
- Key-value `SUMMARY`: snapshots used, coverage, missing repos, API usage.

Only repository-level data is stored and output; no user logins, emails or other personal data.

### Notes

- Trends only cover the tracked universe, not all of GitHub.
- History starts on the first snapshot run; a 7-day query needs about 8 daily snapshots, comparison with the previous 7 days about 15.
- Use within GitHub's Acceptable Use Policies and API terms.

# Actor input Schema

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

snapshot: scheduled daily job that records current stargazers_count/forks_count of all tracked repos. query: computes exact stars/forks gained per category between stored snapshots.

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

Query window ending today (UTC). 'custom' uses startDate/endDate.

## `startDate` (type: `string`):

Baseline UTC day (YYYY-MM-DD) for a custom window.

## `endDate` (type: `string`):

End UTC day (YYYY-MM-DD) for a custom window; default today.

## `comparePrevious` (type: `boolean`):

Also compute the previous equal-length period (needs older snapshots) and report change %.

## `categories` (type: `array`):

Only use these category names (built-in or custom). Empty = all.

## `customCategories` (type: `array`):

List of {"name", "topics": \[...], "keywords": \[...], "languages": \[...]}. Topics are also used to discover repos via the Search API.

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

Repo rows per category in query mode.

## `minStarsGained` (type: `integer`):

Repo rows need at least this many stars gained.

## `githubToken` (type: `string`):

Personal access token (no scopes needed for public data). Effectively required for snapshot mode: enables GraphQL batching and 5,000 points/requests per hour vs 60 REST requests/hour without.

## `maxReposPerCategory` (type: `integer`):

Cap on repos discovered per category when building the tracked universe.

## `universeMinStars` (type: `integer`):

Minimum total stars for the 'top by stars' search queries.

## `searchTopicsPerCategory` (type: `integer`):

How many of a category's topics are used as Search API queries.

## `risersCreatedWithinDays` (type: `integer`):

Also search repos created within this many days with >=50 stars (newly popular projects).

## `universeRefreshDays` (type: `integer`):

Rebuild the tracked universe via Search API when older than this.

## `forceUniverseRefresh` (type: `boolean`):

Rebuild the tracked universe on this run.

## `keepPreviouslyTracked` (type: `boolean`):

When rebuilding, keep repos tracked before so their history continues.

## `extraRepos` (type: `array`):

Additional owner/name repos to always snapshot.

## `graphqlBatchSize` (type: `integer`):

Repositories per GraphQL query (token only).

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

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

## `metaStoreName` (type: `string`):

Named key-value store for the tracked universe and repo metadata.

## Actor input object example

```json
{
  "mode": "query",
  "window": "7d",
  "comparePrevious": true,
  "topN": 10,
  "minStarsGained": 1,
  "maxReposPerCategory": 200,
  "universeMinStars": 100,
  "searchTopicsPerCategory": 3,
  "risersCreatedWithinDays": 90,
  "universeRefreshDays": 7,
  "forceUniverseRefresh": false,
  "keepPreviouslyTracked": true,
  "graphqlBatchSize": 50,
  "snapshotStoreName": "github-trends-snapshots",
  "metaStoreName": "github-trends-meta"
}
```

# 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/github-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/github-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/github-trends --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,shadowell/github-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/UFLqPnQW3LKWVBkzc/builds/AlwSZisevupwT6RTV/openapi.json
