Skip to main content

gtrending

checks codecov docs status pypi version Python Requirements Code style: black

Fetch repositories and developers from GitHub trending.

from gtrending import fetch_repos


repos = fetch_repos(language="python")  # Returns a dictionary

for repo in repos:
    print(repo["fullname"])  # "user/repo" for each repo

or using the CLI

gtrending repos --language python

The above examples will fetch all the trending Python projects on GitHub trending today.

Skip to more CLI examples

Requirements

  • Python 3.8 or higher
  • Dependencies: requests and beautifulsoup

Installation

gtrending is published on PyPI, use your favorite package manager and add it as a dependency.

Pip:

pip3 install gtrending

Poetry:

poetry add gtrending

Pipx (to use gtrending CLI):

pipx install gtrending

You get the idea.

Usage

Documentation: Read the docs (online)

You can also download the PDF documentation build from the latest release or get it from read the docs' downloads.

fetch_repos()

Parameters:

  • language (str, optional): Filtering by language, eg: python
  • spoken_language_code (str, optional): The spoken language, eg: en for english
  • since (str, optional): The time range, choose from: [daily, weekly, monthly]. Defaults to "daily"

Example:

>>> fetch_repos(language="rust", since="weekly")
[
  {
    'author': 'iced-rs',
    'avatar': 'https://github.com/iced-rs.png',
    'builtBy': [
      {
        'avatar': 'https://avatars.githubusercontent.com/u/518289',
        'href': 'https://github.com/hecrj',
        'username': 'hecrj'
      },
      {
        'avatar': 'https://avatars.githubusercontent.com/u/10239377',
        'href': 'https://github.com/tarkah',
        'username': 'tarkah'
      },
      {
        'avatar': 'https://avatars.githubusercontent.com/u/30560559',
        'href': 'https://github.com/derezzedex',
        'username': 'derezzedex'
      },
      {
        'avatar': 'https://avatars.githubusercontent.com/u/1562417',
        'href': 'https://github.com/clarkmoody',
        'username': 'clarkmoody'
      },
      {
        'avatar': 'https://avatars.githubusercontent.com/u/4241774',
        'href': 'https://github.com/bungoboingo',
        'username': 'bungoboingo'
      }
    ],
    'currentPeriodStars': 82,
    'description': 'A cross-platform GUI library for Rust, inspired by Elm',
    'forks': 776,
    'fullname': 'iced-rs/iced',
    'language': 'Rust',
    'languageColor': '#dea584',
    'name': 'iced',
    'stars': 17647,
    'url': 'https://github.com/iced-rs/iced'
  },
  ...
]

fetch_developers()

Parameters:

  • language (str, optional): The programming language, eg: python
  • since (str, optional): The time range, choose from [daily, weekly, monthly]. Defaults to "daily"
  • sponsorable (bool, optional): Whether to only search for developers with sponsor URLs. Defaults to False.

Example:

>>> fetch_developers(language="typescript", since="weekly")
[
  {
    'avatar': 'https://avatars.githubusercontent.com/u/2230985',
    'name': 'Connor Peet',
    'repo': {
      'description': 'A resilience and transient-fault-handling library '
                     'that allows developers to express policies such as '
                     'Backoff, Retry, Circuit Breaker, Tim…',
      'name': 'cockatiel',
      'url': 'https://github.com/connor4312/cockatiel',
      'descriptionUrl': ''
    },
    'sponsorUrl': None,
    'url': 'https://github.com/connor4312',
    'username': 'connor4312'
  },
  {
    'avatar': 'https://avatars.githubusercontent.com/u/13049130',
    'name': 'Robert Soriano',
    'repo': {
      'description': 'End-to-end typesafe APIs in Nuxt applications.',
      'name': 'trpc-nuxt',
      'url': 'https://github.com/wobsoriano/trpc-nuxt',
      'descriptionUrl': 'http://trpc-nuxt.vercel.app/'
    },
    'sponsorUrl': None,
    'url': 'https://github.com/wobsoriano',
    'username': 'wobsoriano'
  },
  ...
]

languages_list()

A list of dictionaries with each name to its parameter value:

>>> languages_list()
[
  ...
  {
    "name": "Elm",
    "param": "elm"
  },
  {
    "name": "Emacs Lisp",
    "param": "emacs-lisp"
  },
  {
    "name": "EmberScript",
    "param": "emberscript"
  },
  {
    "name": "EQ",
    "param": "eq"
  },
  ...
]

spoken_languages_list()

>>> spoken_languages_list()
[
  ...
  {
    "code": "it"
    "name": [ "Italian" ],
  },
  {
    "code": "iu"
    "name": [ "Inuktitut" ],
  },
  {
    "code": "ja"
    "name": [ "Japanese" ],
  },
  {
    "code": "jv"
    "name": [ "Javanese" ],
  },
  {
    "code": "kl"
    "name": [ "Kalaallisut", "Greenlandic" ],
  },
  ...
]

check_language()

Validate the language parameter:

>>> check_language("python")
True
>>> check_language("Ruby")
True
>>> check_language("TeaScript")  # Does not exist
False
>>> check_language("")
False

check_spoken_language_code()

Validate the spoken language code parameter:

>>> check_spoken_language_code("es")
True
>>> check_spoken_language_code("FR")
True
>>> check_spoken_language_code("ZZ")  # Does not exist
False
>>> check_spoken_language_code("")
False

check_since()

Check if the time range is correct — it must be daily, weekly, or monthly — case-insensitive.


For more API usage details, go read the docs!


CLI

Usage:

gtrending [--json] <command> [<args>]

Examples

# Sort repos by stars
gtrending repos --sort stars

# See only python repositories
gtrending repos --language python

# See weekly trending repos
gtrending repos --since weekly --sort forks

# Print output in json format (-j/--json)
gtrending repos --json

# See trending rust developers
gtrending developers --language rust

# See available coding languages
gtrending langs

# See available spoken languages
gtrending spoken-langs

Getting help

# Help commands
gtrending --help
# or see available arguments for specific sub-command
gtrending developers --help

Usage with jq

# Show only fullname (user/repo) and total stars for each repo
# Still a json output
gtrending repos --json | jq '[.[] | {fullname, stars}]'

# Show only fullname for repos
# Not a json anymore
gtrending repos --json | jq '.[] | .fullname'

# Similarly for trending developers
# Show only username and repository url
gtrending developers -j | jq '[ .[] | {username, repo: .repo_url} ]'

# Show only developers with a sponsorUrl
gtrending developers -j | jq '[ map(select(.sponsorUrl != null)) | .[] | {username, repo_name: .repo.name} ]'

Uses

  • requests — Making API requests
  • BeautifulSoup - Scraping github.com/trending

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gtrending-0.5.1.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gtrending-0.5.1-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file gtrending-0.5.1.tar.gz.

File metadata

  • Download URL: gtrending-0.5.1.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.0 CPython/3.9.6 Darwin/22.1.0

File hashes

Hashes for gtrending-0.5.1.tar.gz
Algorithm Hash digest
SHA256 f82505a6e2425a18c772afce12bc92c2165180b5caa98de5feb7cea3b4b117c8
MD5 40d76c55e1b4d90b6e1796b2c526202d
BLAKE2b-256 3afe81e8906e8f159b2828c3d0b807f62d3c54a0f7737c6b7b1d70b3287364d9

See more details on using hashes here.

File details

Details for the file gtrending-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: gtrending-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.0 CPython/3.9.6 Darwin/22.1.0

File hashes

Hashes for gtrending-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 544bcd7feab2448b9522675918263292d0874f6fabc6f17aa82377fba71084a2
MD5 9e3333623d63ba264e751322d288962b
BLAKE2b-256 9711b9dc4abf1534cc33407ac1d8c3c36b22e0ced1a12a3dc019e2cb569b1c93

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 files

0.5.0

2 files

0.4.0

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page