Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active November 1, 2024 23:27
Show Gist options
  • Select an option

  • Save wilmoore/709e688e9d8acd167ce7c778c2adb699 to your computer and use it in GitHub Desktop.

Select an option

Save wilmoore/709e688e9d8acd167ce7c778c2adb699 to your computer and use it in GitHub Desktop.
Software Engineering :: Source Control :: VCS :: Git :: Managed Hosting Platform :: GitHub :: Gist :: API :: Reference :: List gists for the authenticated user

Software Engineering :: Source Control :: VCS :: Git :: Managed Hosting Platform :: GitHub :: Gist :: API :: Reference :: List gists for the authenticated user

⪼ Made with 💜 by Polyglot.

Lists the authenticated user's gists or if called anonymously, this endpoint returns all public gists:

curl
❯ curl -sH "Authorization: token $GIST_API_TOKEN" https://api.github.com/gists | jq '.' | less

API

  • url: https://api.github.com/gists
  • method: GET

Parameters

  • page: 1
  • per_page: 100

Headers

  • Accept: application/vnd.github+json
  • Authorization: Bearer {process.env.GIST_API_TOKEN}
  • X-Github-Api-Version: 2022-11-28

Code

curl --request GET \
  --url 'https://api.github.com/gists?per_page=100' \
  --header 'Accept: application/vnd.github+json' \
  --header 'Authorization: Bearer {{process.env.GIST_API_TOKEN}}' \
  --header 'X-GitHub-Api-Version: 2022-11-28'
meta {
  name: List gists for the authenticated user
  type: http
  seq: 1
}

get {
  url: https://api.github.com/gists?per_page=100&page=1
  body: none
  auth: bearer
}

params:query {
  per_page: 100
  page: 1
}

headers {
  Accept: application/vnd.github+json
  X-GitHub-Api-Version: 2022-11-28
}

auth:bearer {
  token: {{process.env.GIST_API_TOKEN}}
}

Response

[
  {
    "url": "https://api.github.com/gists/a1b2c3d4e5f6g7h8i9j0",
    "forks_url": "https://api.github.com/gists/a1b2c3d4e5f6g7h8i9j0/forks",
    "commits_url": "https://api.github.com/gists/a1b2c3d4e5f6g7h8i9j0/commits",
    "id": "a1b2c3d4e5f6g7h8i9j0",
    "node_id": "G_kwDOABc0FACA1YjNiM2Q0ZTVmNmI3aDhiOTYwZDAz",
    "git_pull_url": "https://gist.github.com/a1b2c3d4e5f6g7h8i9j0.git",
    "git_push_url": "https://gist.github.com/a1b2c3d4e5f6g7h8i9j0.git",
    "html_url": "https://gist.github.com/johndoe/a1b2c3d4e5f6g7h8i9j0",
    "files": {
      "readme.md": {
        "filename": "readme.md",
        "type": "text/markdown",
        "language": "Markdown",
        "raw_url": "https://gist.githubusercontent.com/johndoe/a1b2c3d4e5f6g7h8i9j0/raw/d2f45e3f4e9a79db1d8c4d9d2d3e3d4e/readme.md",
        "size": 1087
      }
    },
    "public": false,
    "created_at": "2024-10-22T18:02:04Z",
    "updated_at": "2024-10-22T18:13:29Z",
    "description": "The Anatomy of a GitHub Gist API Request",
    "comments": 0,
    "user": null,
    "comments_url": "https://api.github.com/gists/a1b2c3d4e5f6g7h8i9j0/comments",
    "owner": {
      "login": "johndoe",
      "id": 12345,
      "node_id": "MDQ6VXNlcjEyMzQ1",
      "avatar_url": "https://avatars.githubusercontent.com/u/12345?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/johndoe",
      "html_url": "https://github.com/johndoe",
      "followers_url": "https://api.github.com/users/johndoe/followers",
      "following_url": "https://api.github.com/users/johndoe/following{/other_user}",
      "gists_url": "https://api.github.com/users/johndoe/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/johndoe/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/johndoe/subscriptions",
      "organizations_url": "https://api.github.com/users/johndoe/orgs",
      "repos_url": "https://api.github.com/users/johndoe/repos",
      "events_url": "https://api.github.com/users/johndoe/events{/privacy}",
      "received_events_url": "https://api.github.com/users/johndoe/received_events",
      "type": "User",
      "user_view_type": "public",
      "site_admin": false
    },
    "truncated": false
  }
  ...
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment