Exercise 1: Getting Information from GitHub
Now, instead of walking through GitHub’s many endpoints one by one, you’re going to solve a few challenges that will help reinforce the concepts we’ve explored in the previous lessons.
But don’t worry — before you begin, let’s review how to navigate GitHub’s API documentation to build requests in Postman.
The “Get Octocat” Endpoint
This endpoint is part of GitHub’s Meta category.
To find it, go to the GitHub API documentation:
https://docs.github.com/en/rest?apiVersion=2022-11-28
In the left sidebar, scroll down to:
Meta
|- Meta
| |- Get Octocat
GitHub’s documentation may seem intimidating at first, but with a closer look, it’s not that different from The Cat API’s documentation.
Here’s how to read it:
The left column explains what the endpoint does and what type of token it accepts.
- In our case, we’re using a Personal Access Token (classic), which gives us access to repositories and endpoints we have permission for.
- Fine-grained tokens are another type of GitHub token with more limited scopes. If a note says “This endpoint works with fine-grained tokens,” it means you can use it, but you may encounter restrictions.
The Parameters section (still in the left column) lists:
- Required headers
- Optional query parameters
- Path parameters
- Body fields (for
POST
/PATCH
requests)
The right column shows example requests in cURL, JavaScript, and GitHub CLI.
Even if you’re not using those, they can help you understand what values and formats are expected.At the very top, you’ll see the actual API endpoint. For this one, it’s:
GET/octocat
At the bottom, you’ll find sample responses and schemas — great for comparing against your own requests.
Translating GitHub Docs to Postman
Let’s build the request for /octocat
in Postman:
- Create a new
GET
request inside your GitHub collection. - Set the URL to:
{{gh_URL}}/octocat
- Under the Headers tab, add:
- Key:
accept
- Value:
application/vnd.github+json
- Under the Params tab, add:
- Key:
s
- Value: (any message you want — e.g.,
This is me, interacting with GitHub
)
- Make sure your GitHub environment is selected, then click Send.
You should see the Octocat in your response window!
Search Repositories
Now it’s your turn!
In this exercise, you’ll use Postman to send a request that searches for public GitHub repositories matching specific criteria.
You can find the endpoint documentation by navigating to:
Search
|- Search
| |- Search repositories
Once there, follow the documentation to write a request that:
- Searches for repositories matching the query:
tetris+language:python
- Sorts results by:
stars
- Orders them in:
descending
order (desc
)
Optional, but recommended:
- Return 30 results per page
- Get results from page 3
Use the information in the documentation to set the correct query parameters in Postman.
When you’re done, explore the response — it will include metadata like repository names, descriptions, star counts, and links to the original repos.
Check your work
If everything is set up correctly, your request should look something like this:
URL
{gh_URL}/search/repositories
Query Parameters
Key | Value |
---|---|
q |
tetris+language:python |
sort |
stars |
order |
desc |
per_page |
30 |
page |
3 |
Headers (optionals)
Key | Value |
---|---|
accept |
application/vnd.github+json |
Authorization |
Bearer {{gh_token}} |
Your response should include a JSON object with a key named items
— this is a list of repositories that match your search. You can scan through the names, star counts, and descriptions to explore what’s trending in the world of Python + Tetris 😄
If your response returns an error or doesn’t look like what’s expected:
- Double-check your query parameters
- Make sure you’re using
GET
as the request method - Confirm your token is still valid and your environment is active