# GitHub Repository Scraper (`cloud9_ai/github-scraper`) Actor

Scrape GitHub repositories, users, and trending projects via REST API. Extract repo names, stars, forks, languages, descriptions, and contributor data.

- **URL**: https://apify.com/cloud9_ai/github-scraper.md
- **Developed by:** [cloud9](https://apify.com/cloud9_ai) (community)
- **Categories:** AI, Automation
- **Features:** Limited permissions
- **Stats:** 35 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.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

## GitHub Scraper

Scrape GitHub repositories, users, and trending projects via the GitHub REST API.

### Features

- **3 Scraping Modes:**
  - `searchRepos`: Search for repositories by keywords
  - `searchUsers`: Search for GitHub users
  - `trending`: Get trending repositories (created in last 7 days, sorted by stars)

- **Filters:**
  - Programming language filter
  - Sort options: stars, forks, updated, best-match
  - Configurable max results (1-100)

- **No Authentication Required:** Uses GitHub's public REST API (60 requests/hour unauthenticated)

### Input Parameters

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `mode` | String | Yes | Scraping mode: `searchRepos`, `searchUsers`, or `trending` |
| `searchQuery` | String | No | Search keywords (not used for trending mode) |
| `language` | String | No | Filter by programming language (e.g., Python, JavaScript) |
| `sort` | String | No | Sort by: `stars`, `forks`, `updated`, or `best-match` |
| `maxResults` | Integer | No | Maximum results to scrape (1-100, default: 30) |
| `proxyConfiguration` | Object | No | Proxy settings for API requests |

### Example Input

#### Search Repositories

```json
{
  "mode": "searchRepos",
  "searchQuery": "machine learning",
  "language": "Python",
  "sort": "stars",
  "maxResults": 30
}
```

#### Search Users

```json
{
  "mode": "searchUsers",
  "searchQuery": "javascript developer",
  "maxResults": 20
}
```

#### Trending Repositories

```json
{
  "mode": "trending",
  "language": "TypeScript",
  "maxResults": 50
}
```

### Output Data

#### Repository Output

```json
{
  "name": "tensorflow",
  "fullName": "tensorflow/tensorflow",
  "description": "An Open Source Machine Learning Framework for Everyone",
  "url": "https://github.com/tensorflow/tensorflow",
  "stars": 185000,
  "forks": 74000,
  "language": "Python",
  "topics": ["machine-learning", "deep-learning", "tensorflow"],
  "owner": "tensorflow",
  "ownerUrl": "https://github.com/tensorflow",
  "createdAt": "2015-11-07T01:19:20Z",
  "updatedAt": "2024-02-14T12:34:56Z",
  "openIssues": 2500,
  "watchers": 185000,
  "defaultBranch": "master",
  "license": "Apache License 2.0",
  "homepage": "https://www.tensorflow.org"
}
```

#### User Output

```json
{
  "login": "torvalds",
  "url": "https://github.com/torvalds",
  "avatarUrl": "https://avatars.githubusercontent.com/u/1024025",
  "type": "User",
  "publicRepos": 6,
  "followers": 180000,
  "following": 0,
  "createdAt": "2011-09-03T15:26:22Z",
  "bio": "Creator of Linux and Git",
  "company": "Linux Foundation",
  "location": "Portland, OR",
  "blog": "https://torvalds-family.blogspot.com"
}
```

### Rate Limits

- **Unauthenticated API:** 60 requests per hour
- **Rate Limit Handling:** Automatic wait and retry if rate limit is hit
- **Request Delay:** 1.5 seconds between requests to avoid hitting limits

### Technical Details

- Uses GitHub REST API v3
- Built with Apify SDK 3.0 and Crawlee 3.0
- TypeScript for type safety
- `gotScraping` for HTTP requests with proxy support
- Multi-stage Docker build for optimized image size

### Local Development

```bash
## Install dependencies
npm install

## Build TypeScript
npm run build

## Run locally
npm start
```

### Deployment

Deploy to Apify platform:

```bash
apify push
```

### Use Cases

- Repository discovery and analysis
- Trending technology tracking
- Developer community research
- Open source project monitoring
- Programming language popularity tracking

### License

MIT

# Actor input Schema

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

Choose what to scrape: repositories, users, or trending projects

## `searchQuery` (type: `string`):

Search keywords (not used for 'trending' mode)

## `language` (type: `string`):

Filter by programming language (e.g., Python, JavaScript, Go). Leave empty for all languages.

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

How to sort the results

## `maxResults` (type: `integer`):

Maximum number of results to scrape

## `proxyConfiguration` (type: `object`):

Proxy settings for API requests

## Actor input object example

```json
{
  "mode": "searchRepos",
  "searchQuery": "machine learning",
  "sort": "stars",
  "maxResults": 5,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# 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 = {
    "maxResults": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("cloud9_ai/github-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 = { "maxResults": 5 }

# Run the Actor and wait for it to finish
run = client.actor("cloud9_ai/github-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 '{
  "maxResults": 5
}' |
apify call cloud9_ai/github-scraper --silent --output-dataset

```

## MCP server setup

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