Skip to content

Want to receive user name and bio when using 'Search users' API #115229

Discussion options

You must be logged in to vote

When searching user on Github app, it seems it directly fetches name and bio info. Wonder if I can't to do so?

Yes, you can achieve this by using the GraphQL API rather than the Rest API.

The GraphQL API12 allows you to make a single specific request and receive exactly what you ask for.

query ($query: String = "user:ashtom") {
  search(query: $query, type: USER, first: 100) {
    nodes {
      ... on User {
        bio
        login
      }
    }
  }
}
{
  "data": {
    "search": {
      "nodes": [
        {
          "bio": "CEO @github",
          "login": "ashtom"
        }
      ]
    }
  }
}

Footnotes

  1. About the GraphQL API - GitHub Docs

  2. GitHub - ByteByteGoHq/system-design-10…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by seenewmax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API and Webhooks Discussions and conversations related to APIs or Webhooks Question
2 participants