Skip to content

Latest commit

 

History

History
28 lines (22 loc) · 921 Bytes

graphql-search-topics.md

File metadata and controls

28 lines (22 loc) · 921 Bytes

Searching for repositories by topic using the GitHub GraphQL API

I wanted to use the GitHub GraphQL API to return all of the repositories on the https://github.com/topics/git-scraping page.

At first glance there isn't a GraphQL field for that page - but it turns out you can access it using a GitHub search:

topic:git-scraping sort:updated-desc

An oddity of GitHub search is that sort order can be defined using tokens that form part of the search query!

Here's a GraphQL query tested here that returns the most recent 100 git-scraping tagged repos, sorted by most recently updated.

{
  search(query: "topic:git-scraping sort:updated-desc", type: REPOSITORY, first: 100) {
    repositoryCount
    nodes {
      ... on Repository {
        nameWithOwner
        description
        updatedAt
        createdAt
        diskUsage
      }
    }
  }
}