> ## Documentation Index
> Fetch the complete documentation index at: https://docs.scrapegraphai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 🌟 GitHub Trending

> Monitor trending repositories and developers

<img style={{ borderRadius: '0.5rem' }} src="https://mintcdn.com/scrapegraphaiinc-9e950277/4qVtSM5IjLHD2i2B/cookbook/images/github-banner.png?fit=max&auto=format&n=4qVtSM5IjLHD2i2B&q=85&s=15c5c4a0e960cee6a0d7e202b7bb0d80" width="1584" height="396" data-path="cookbook/images/github-banner.png" />

[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ScrapeGraphAI/scrapegraph-py/blob/main/cookbook/github-trending/scrapegraph_sdk.ipynb) [![View on GitHub](https://img.shields.io/badge/GitHub-View_Notebook-181717?logo=github)](https://github.com/ScrapeGraphAI/scrapegraph-py/blob/main/cookbook/github-trending/scrapegraph_sdk.ipynb)

Learn how to extract trending repository information from GitHub using ScrapeGraphAI's Extract service. This example demonstrates how to gather repository statistics, descriptions, and popularity metrics.

## The Goal

We'll extract the following repository information:

| Field       | Description                         |
| ----------- | ----------------------------------- |
| Name        | Repository name (owner/repo format) |
| Description | Repository description              |
| Stars       | Total star count                    |
| Forks       | Total fork count                    |
| Today Stars | Stars gained today                  |
| Language    | Primary programming language        |

## Code Example

```python theme={null}
from pydantic import BaseModel, Field
from typing import List
from scrapegraph_py import ScrapeGraphAI

# Schema for Trending Repositories
class RepositorySchema(BaseModel):
    name: str = Field(description="Name of the repository (e.g., 'owner/repo')")
    description: str = Field(description="Description of the repository")
    stars: int = Field(description="Star count of the repository")
    forks: int = Field(description="Fork count of the repository")
    today_stars: int = Field(description="Stars gained today")
    language: str = Field(description="Programming language used")

# Schema that contains a list of repositories
class ListRepositoriesSchema(BaseModel):
    repositories: List[RepositorySchema] = Field(description="List of github trending repositories")

sgai = ScrapeGraphAI()  # reads SGAI_API_KEY from env

res = sgai.extract(
    "Extract trending repository information",
    url="https://github.com/trending",
    schema=ListRepositoriesSchema.model_json_schema(),
)

if res.status == "success":
    print(res.data.json_data)
```

## Example Output

```json theme={null}
{
    "repositories": [
        {
            "name": "microsoft/copilot-cli",
            "description": "CLI tool for GitHub Copilot",
            "stars": 2891,
            "forks": 147,
            "today_stars": 523,
            "language": "TypeScript"
        },
        {
            "name": "openai/whisper",
            "description": "Robust Speech Recognition via Large-Scale Weak Supervision",
            "stars": 54321,
            "forks": 5432,
            "today_stars": 321,
            "language": "Python"
        },
        {
            "name": "langchain-ai/langchain",
            "description": "Building applications with LLMs through composability",
            "stars": 12345,
            "forks": 1234,
            "today_stars": 234,
            "language": "Python"
        }
    ]
}
```

<CardGroup cols={2}>
  <Card title="Extract" icon="robot" href="/services/extract">
    Learn more about our AI-powered extraction service
  </Card>

  <Card title="Python SDK" icon="python" href="/sdks/python">
    Explore our Python SDK documentation
  </Card>
</CardGroup>

***

<Note>
  Have a suggestion for a new example? [Contact us](mailto:contact@scrapegraphai.com) with your use case or contribute directly on [GitHub](https://github.com/ScrapeGraphAI/scrapegraph-sdk).
</Note>
