The GitHub API enables developers to programmatically interact with GitHub's platform, allowing automation of tasks like managing repositories, issues, pull requests, and user data. It offers two main versions: the REST API v3 (widely used) and the GraphQL API v4, which provides more flexibility for complex queries.

Key Features

  • REST API: Follows standard HTTP methods and is ideal for straightforward interactions. For example, fetching user data:

    fetch('https://api.github.com/users/octocat')
      .then(response => response.json())
      .then(data => console.log(data));
  • GraphQL API: Allows precise data retrieval with custom queries, reducing over-fetching. It’s particularly useful for complex data needs.

Authentication

Documentation & Resources

Pricing & Limits

  • Free tier: Unlimited public API calls; rate-limited for private repositories and authenticated users (60 requests/hour without token, 5,000/hour with token).

  • Enterprise: Higher limits and advanced features via GitHub Enterprise Cloud or Server.

Use Cases

  • Automate repository creation and branch management.

  • Sync code from external tools (e.g., LeetCode to GitHub).

  • Build CI/CD integrations, monitoring dashboards, or profile stats generators.

For full details, refer to the GitHub REST API documentation.

🌐
GitHub
docs.github.com › en › rest
GitHub REST API documentation - GitHub Docs
Create integrations, retrieve data, and automate your workflows with the GitHub REST API.
Home
Get started, troubleshoot, and make the most of GitHub. Documentation for new users, developers, administrators, and all of GitHub's products.
Quickstart
Learn how to get started with the GitHub REST API.
Authenticating
You can authenticate to the REST API to access more endpoints and have a higher rate limit.
Getting started
Some common HTTP methods are GET, POST, DELETE, and PATCH. The REST API reference documentation provides the HTTP method for every endpoint. For example, the HTTP method for the "List repository issues" endpoint is GET." Where possible, the GitHub REST API strives to use an appropriate HTTP ...
🌐
GitHub
github.com › public-apis › public-apis
GitHub - public-apis/public-apis: A collective list of free APIs · GitHub
A collective list of free APIs. Contribute to public-apis/public-apis development by creating an account on GitHub.
Starred by 411K users
Forked by 44.4K users
Languages   Python 96.8% | Shell 3.2%
Discussions

How to get a file via GitHub APIs - Stack Overflow
I need to get the contents of a file hosted in a GitHub repo. I'd prefer to get a JSON response with metadata along with it. I've tried numerous URLs with cURL with to only get a response of {"mess... More on stackoverflow.com
🌐 stackoverflow.com
Creating release with api
Release asset upload - https://docs.github.com/en/free-pro-team@latest/rest/releases/assets?apiVersion=2022-11-28 I also recommend you try Bing Chat’s generative ai with a prompt “show me c# code to upload a release asset to github” https://www.bing.com/chat Side note… the GitHub CLI is another approach… https://cli.github.com/manual/gh_release More on reddit.com
🌐 r/github
1
1
April 10, 2023
Exposed API key
Git keeps history in a chain of commits, just because you removed the key in one commit doesn't mean that it was removed from a commit in the past. Avoid committing keys. If you do it in future, git rebase -i and drop/fixup the commits before you push. Now the key's pushed, treat it as compromised. If you link the repo, we can help more More on reddit.com
🌐 r/github
21
24
May 17, 2021
Help with Github API and Github GraphQL API
Hey there! Being someone that have spent a lot of time playing with the GH API, let me try to give you some help. Examples are shown using the gh cli and jq to make it easier, you can easily translate them to your use case. Find a file in a repository using substring: If you know the directory your file will be located at: gh api /repos/reposaur/reposaur/contents \ # Get all files in root | jq -r '.[] | select(.name | startswith("READ") or endswith(".mod"))' # Filter using jq If you don't know the directory your file is located at you'll have a bit more work to do. You can use either the Git Trees API or the Contents API (used above) to get all directories starting at root directory and navigate through them (with more requests) until you find the file(s) you want. 2. Query the tags of a repository To query all tags you can use the Git Database API : gh api /repos/reposaur/reposaur/git/matching-refs/tags Similarly if you want to get a single tag: gh api /repos/reposaur/reposaur/git/matching-refs/tags/v0.6.0 Or get all branches: gh api /repos/reposaur/reposaur/git/matching-refs/heads Is this helpful for your case? More on reddit.com
🌐 r/github
6
4
April 2, 2022
🌐
GitHub
docs.github.com › en › rest › using-the-rest-api › getting-started-with-the-rest-api
Getting started with the REST API - GitHub Docs
All API requests must include a valid User-Agent header. The User-Agent header identifies the user or application that is making the request. By default, GitHub CLI sends a valid User-Agent header. However, GitHub recommends using your GitHub username, or the name of your application, for the User-Agent header value.
🌐
GitHub
docs.github.com › en › rest › repos › contents
REST API endpoints for repository contents - GitHub Docs
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/repos/OWNER/REPO/contents/PATH \ -d '{"message":"my commit message","committer":{"name":"Monalisa Octocat","email":"octocat@github.com"},"content":"bXkgbmV3IGZpbGUgY29udGVudHM="}'
🌐
Free APIs
free-apis.github.io
Free APIs
An open-source collection of free APIs for web developers.
🌐
GitHub
github.blog › home › changelogs › rest api version 2026-03-10 is now available
REST API version 2026-03-10 is now available - GitHub Changelog
5 days ago - Previously, we introduced calendar-based versioning for our REST API, giving us a path to evolving our API while giving integrators plenty of time and clear guidance for upgrading. Now, we’re releasing calendar version 2026-03-10, the newest version of the GitHub REST API.
🌐
Medium
medium.com › analytics-vidhya › getting-started-with-github-api-dc7057e2834d
Getting Started with Github API. REST API v3 using Python | by Gaganpreet Kaur Kalsi | Analytics Vidhya | Medium
July 20, 2020 - In this article, learn how to use Github API to create, delete a repository; create an issue, comment, and close an issue and many more using python. Learn how to read API documentation and make GET, POST and DELETE requests. Also learn how to generate a token.
🌐
GitHub
github.com › topics › github-api
github-api · GitHub Topics · GitHub
The GitHub API provides endpoints for users to consume GitHub data as well as make changes on a user’s behalf. The latest version is v4, the GraphQL API.
Find elsewhere
🌐
GitHub Developer
octokit.github.io › routes › cache › api.github.com › v3 › index.html
GitHub API v3 | GitHub Developer Guide
June 21, 2023 - If you have any problems or requests, please contact GitHub Support or GitHub Premium Support. ... By default, all requests to https://api.github.com receive the v3 version of the REST API.
🌐
GitHub
docs.github.com › en › rest › users › users
REST API endpoints for users - GitHub Docs
Note: If your email is set to private and you send an email parameter as part of this request to update your profile, your privacy settings are still enforced: the email address will not be displayed on your public profile or via the API. This endpoint works with the following fine-grained token types: ... curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/user \ -d '{"blog":"https://github.com/blog","name":"monalisa octocat"}'
🌐
GitHub
docs.github.com › en › rest › releases › releases
REST API endpoints for releases - GitHub Docs
To get a list of Git tags, use the Repository Tags API. Information about published releases are available to everyone. Only users with push access will receive listings for draft releases. This endpoint works with the following fine-grained token types: ... This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested. ... curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/repos/OWNER/REPO/releases
🌐
GitHub
docs.github.com › en › rest › repos › repos
REST API endpoints for repositories - GitHub Docs
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/orgs/ORG/repos
🌐
GitHub
docs.github.com › en › rest › quickstart
Quickstart for GitHub REST API - GitHub Docs
For more information about secrets, see Using secrets in GitHub Actions. The following example workflow uses the List repository issues endpoint, and requests a list of issues in the octocat/Spoon-Knife repository. ... on: workflow_dispatch: jobs: use_api: runs-on: ubuntu-latest permissions: issues: read steps: - env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh api https://api.github.com/repos/octocat/Spoon-Knife/issues
🌐
LoginRadius
loginradius.com › home
Introduction to Github APIs
November 2, 2020 - Request type: POST API endpoint: /user/{repos} Required data: name · Example :- curl -H "Authorization: token ${token}" -d '{"name":"Github API Testing"}' https://api.github.com/user/repos
🌐
GitHub
docs.github.com › en › rest › about-the-rest-api › about-the-rest-api
About the REST API - GitHub Docs
Get oriented to the REST API documentation. ... You can use GitHub's API to build scripts and applications that automate processes, integrate with GitHub, and extend GitHub.
🌐
GitHub
githubstatus.com › api
GitHub Status - API
https://www.githubstatus.com/api/v2/summary.json Click for example
🌐
Latenode
latenode.com › home › blog › integration & api management › api integration best practices › what is github api and how to get a github api key: tutorial and examples
What is GitHub API and How to Get a GitHub API Key: Tutorial and Examples - Latenode Blog
February 12, 2026 - Key Takeaways: GitHub APIs enable developers to programmatically interact with GitHub's features, automate tasks, and integrate with external services using REST and GraphQL APIs.
Top answer
1 of 3
42

As the description (located at http://developer.github.com/v3/repos/contents/) says:

/repos/:owner/:repo/contents/:path

An ajax code will be:

$.ajax({
    url: readme_uri,
    dataType: 'jsonp',
    success: function(results)
    {
        var content = results.data.content;
    });

Replace the readme_uri by the proper /repos/:owner/:repo/contents/:path.

2 of 3
39

This GitHub API page provides the full reference. The API endpoint for reading a file:

https://api.github.com/repos/{username}/{repository_name}/contents/{file_path}
{
  "encoding": "base64",
  "size": 5362,
  "name": "README.md",
  "content": "encoded content ...",
  "sha": "3d21ec53a331a6f037a91c368710b99387d012c1",
  ...
}
  • Consider using a personal access token
    • Rate-limits (up to 60 per-hour for anonymous, up to 5,000 per-hour for authenticated) read more
    • Enable accessing files in private repos
  • The file content in the response is base64 encoded string

Using curl

Reading https://github.com/airbnb/javascript/blob/master/package.json using GitHub's API via curl:

curl -H 'Accept: application/vnd.github.v3.raw' https://api.github.com/repos/airbnb/javascript/contents/package.json
  • Make sure to pass header Accept: application/vnd.github.v3.raw to get raw file response (thanks jakub.g)

Using Python

Reading https://github.com/airbnb/javascript/blob/master/package.json using GitHub's API in Python:

import base64
import json
import requests
import os


def github_read_file(username, repository_name, file_path, github_token=None):
    headers = {}
    if github_token:
        headers['Authorization'] = f"token {github_token}"
        
    url = f'https://api.github.com/repos/{username}/{repository_name}/contents/{file_path}'
    r = requests.get(url, headers=headers)
    r.raise_for_status()
    data = r.json()
    file_content = data['content']
    file_content_encoding = data.get('encoding')
    if file_content_encoding == 'base64':
        file_content = base64.b64decode(file_content).decode()

    return file_content


def main():
    github_token = os.environ['GITHUB_TOKEN']
    username = 'airbnb'
    repository_name = 'javascript'
    file_path = 'package.json'
    file_content = github_read_file(username, repository_name, file_path, github_token=github_token)
    data = json.loads(file_content)
    print(data['name'])


if __name__ == '__main__':
    main()
  • Define an environment variable GITHUB_TOKEN before running
🌐
GitHub
docs2.lfe.io › v3
GitHub API v3
This describes the resources that make up the official GitHub API v3.
🌐
Public APIs
publicapis.io › home › development › github
GitHub API — Free Public API | Public APIs Directory
May 1, 2025 - Make use of GitHub repositories, code and user info programmatically Get API details, uptime stats, pricing info, and integration examples for GitHub.