Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › API testing

How to Test GitHub User Info APIs with cURL, Postman, and Automated Assertions

By Freedom251 Team · · 10 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Test GitHub user information with two endpoints: call GET https://api.github.com/users/{username} for a public profile, or call GET https://api.github.com/user to retrieve the profile belonging to an access token. A reliable test sends GitHub’s JSON media type and API-version headers, checks the expected status and JSON fields, exercises a nonexistent username, and records rate-limit headers. Public requests can work without authentication; caller-specific data requires a suitably scoped token.

Which GitHub endpoint should you test?

The endpoint determines both the data and the authentication expectation. Use the username route when the test is about a particular public account. Use /user when the test is about the person or installation represented by a token.

As an Amazon Associate I earn from qualifying purchases.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Use case Request Authentication Primary success assertion
Look up a public account GET https://api.github.com/users/{username} Not required when requesting public resources 200 and a profile object whose login matches the requested account
Look up the token owner GET https://api.github.com/user Bearer token required 200 and the authenticated user’s profile fields

GitHub describes the username route as providing publicly available information about someone with a GitHub account. The same documentation says it can be used without authentication when only public resources are requested. The authenticated route is different: it resolves the identity represented by the credential rather than a username in the URL.

What headers and test data do you need?

Send GitHub’s JSON media type and the version header used in GitHub’s versioned examples. Keep a known public handle for the positive case and a deliberately nonexistent handle for the negative case.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
  • Accept: application/vnd.github+json
  • X-GitHub-Api-Version: 2026-03-10
  • For /user, Authorization: Bearer <TOKEN>
  • A positive fixture: a public account that your test is allowed to query
  • A negative fixture: a username selected specifically because it does not exist

Do not hard-code a personal token in a script, collection, repository, or test output. Supply it through the test runner’s secret store or an environment variable, and redact authorization headers before saving diagnostics.

How do you test a public profile with cURL?

A cURL test needs only the URL and the two request headers. The following example uses octocat as a conventional public test handle; replace it with a handle you control or have selected as a stable fixture.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Set the username and request URL. The braces in the documented route are a placeholder, not part of the final URL.
    USERNAME=octocat
    URL="https://api.github.com/users/${USERNAME}"
  2. Send the request and save both headers and the JSON body for inspection:
    curl --include --silent --show-error 
      --header "Accept: application/vnd.github+json" 
      --header "X-GitHub-Api-Version: 2026-03-10" 
      "$URL"
  3. Confirm that the response status is 200, the body is JSON, and the object contains the fields your contract requires. The stable baseline in a user-info test is login, id, html_url, and type. Profile fields such as name or public_repos should be checked only when your application actually uses them.

For a machine-readable status check, ask cURL to print the status separately:

curl --silent --show-error --output response.json --write-out '%{http_code}n' 
  --header 'Accept: application/vnd.github+json' 
  --header 'X-GitHub-Api-Version: 2026-03-10' 
  'https://api.github.com/users/octocat'

A status of 200 proves that the request completed successfully; your assertions still need to verify that the returned object is the account your test requested and that values have the expected JSON types.

How do you test the same request in Postman?

Postman can exercise the public and authenticated routes without changing the request shape. Put the version and media-type headers in the request itself or in an environment shared by the collection.

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
  1. Create a new HTTP request and select GET.
  2. Enter https://api.github.com/users/{username} with a real test handle in place of {username}.
  3. Open the Headers tab and add Accept with value application/vnd.github+json, then add X-GitHub-Api-Version with value 2026-03-10.
  4. Send the request. In the response, check the status, JSON content type, and required fields.
  5. Duplicate the request, replace the path with an intentionally nonexistent handle, and make the expected status 404.
  6. For caller-specific testing, change the URL to https://api.github.com/user. In Authorization, choose a bearer-token method or add an Authorization header whose value is Bearer <TOKEN>. Store the token in a secret environment variable rather than a shared collection value.

Postman’s test script can assert the status and a few contract fields without snapshotting the entire response:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
pm.test("status is 200", function () {
  pm.response.to.have.status(200);
});

const user = pm.response.json();
pm.test("required user fields are present", function () {
  pm.expect(user).to.have.property("login").that.is.a("string");
  pm.expect(user).to.have.property("id").that.is.a("number");
  pm.expect(user).to.have.property("html_url").that.is.a("string");
  pm.expect(user).to.have.property("type").that.is.a("string");
});

What should an automated assertion check?

Assert the API contract, not every field in a profile that can change over time. A focused test catches a broken URL, content negotiation problem, malformed response, or unexpected account type while avoiding brittle failures caused by optional profile edits.

  • Transport: HTTP status is 200 for the positive case.
  • Representation: the response has a JSON content type and parses as an object.
  • Identity: login is present and, for the username route, corresponds to the requested handle.
  • Stable identifiers: id is present and numeric, html_url is present and string-valued, and type is present and string-valued.
  • Application fields: assert name, public_repos, or another profile value only if the consuming feature depends on it; allow an absent optional value when the API response does not provide it.

Do not use a full-body snapshot as the only check. Profile data can legitimately change, while the endpoint’s status, identity, and basic field types are the contract most clients need.

How do you test an unknown username and other failures?

Negative tests should distinguish a missing account from an authentication or throttling problem. Use a username that is intentionally nonexistent and assert 404 for that request.

Case Expected result What to verify
Known public username 200 JSON body and required identity fields
Intentionally nonexistent username 404 Your client surfaces “not found” instead of treating it as an empty profile
Missing, invalid, or unusable credential on an authenticated call 401 may occur The client reports an authentication failure and does not retry forever
Forbidden request or policy/rate condition 403 may occur The body and rate-limit headers are captured before deciding whether to retry
Rate-limited request 403 or 429, depending on the condition Backoff follows the response guidance rather than a tight loop

Keep the negative assertion tied to the fixture. If a previously nonexistent handle is later registered, the test will correctly stop being a valid 404 fixture and must be replaced.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

How do you test the authenticated GitHub user endpoint?

Call GET https://api.github.com/user with a bearer token and the same media-type and version headers. The response represents the token owner, so the test should compare it with an identity you expect from the test credential rather than with a username supplied in the URL.

curl --include --silent --show-error 
  --header "Accept: application/vnd.github+json" 
  --header "X-GitHub-Api-Version: 2026-03-10" 
  --header "Authorization: Bearer ${GITHUB_TOKEN}" 
  "https://api.github.com/user"

OAuth app tokens and classic personal access tokens need the read:user scope, or the broader user scope, for the private user response. Fine-grained personal access tokens and GitHub App user access tokens are supported for this endpoint. A token with the wrong scope is a credential/configuration failure, not a reason to weaken the assertion.

  1. Load the token from the CI secret manager or a local environment variable.
  2. Send GET /user with Authorization: Bearer <TOKEN>, Accept: application/vnd.github+json, and X-GitHub-Api-Version: 2026-03-10.
  3. Assert 200, parse the JSON, and verify login, id, html_url, and type.
  4. Check that the returned identity is the test account associated with the secret, without printing the token or sensitive profile values to logs.
  5. Run a separate failure test with an absent or deliberately invalid credential only in a safe test environment, and assert the documented error handling your client is expected to provide.

What is the difference between public and authenticated testing?

Dimension /users/{username} /user
Identity source Username in the path Bearer token owner
Unauthenticated use Allowed for public resources Not applicable; the request is caller-specific
Typical positive status 200 200
Useful negative case Unknown username returns 404 Missing or unusable authentication can return 401; authorization or policy conditions can return 403
Rate-limit baseline Unauthenticated requests: 60 requests per hour Authenticated personal requests generally: 5,000 requests per hour
Secret handling No token is needed for public data Token must be protected from source control, collections, and logs

The two routes should be separate test cases. A passing public lookup cannot prove that your token is valid, and a passing authenticated lookup cannot prove that arbitrary public usernames are handled correctly.

How do rate limits affect a test suite?

GitHub documents a primary limit of 60 requests per hour for unauthenticated requests. Authenticated requests generally have a personal limit of 5,000 requests per hour. These are budgets, not a guarantee that every test runner can issue requests indefinitely.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Record x-ratelimit-limit, x-ratelimit-remaining, and x-ratelimit-reset in sanitized diagnostics. Related rate-limit headers can add context when a request fails. When a 403 or 429 is caused by throttling, wait according to GitHub’s guidance and apply exponential backoff; never retry immediately in a tight loop.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

GitHub’s documented secondary-rate-limit figures include a maximum of 100 concurrent requests. A test runner that launches many profile lookups at once can therefore fail even when the hourly counter still has capacity. Limit concurrency, reuse a small fixture set, and separate contract tests from load testing.

How can you make the tests repeatable and safe?

  • Use controlled fixtures: keep one known public handle and one intentionally nonexistent handle, and review them when a test begins returning a different status.
  • Separate credentials by environment: use a least-privilege test token for CI and a different local token; do not commit either value.
  • Redact diagnostics: remove the authorization header and avoid dumping complete profile objects when they are not needed to diagnose the failure.
  • Respect budgets: do not run a public unauthenticated test once per case when one response can be shared by several local assertions.
  • Pin request headers: always send the documented media type and API version so a default change in a client library does not silently alter the response.
  • Test client branches: include success, unknown-user, authentication, authorization, and throttling handling rather than only testing the happy path.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why might a GitHub user test fail?

The response is 404 for a handle you expected to work

Check the final URL after substituting the path parameter. Confirm that the fixture account still exists and that the request is going to /users/{username}, not /user. A 404 is the correct result for an unknown username, so do not convert it to a generic network error.

The authenticated call returns 401

Verify that the Authorization value starts with Bearer, that the secret is present in the process running the test, and that the token has not expired or been revoked. Make sure the test is not accidentally sending the literal text <TOKEN>.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The call returns 403 or 429 after many tests

Inspect the rate-limit headers before retrying. Reduce concurrency, stop tight retries, and wait until the reset or retry guidance permits another attempt.

The fields your assertion expects are missing

Confirm that the test requires only contract fields relevant to the feature. Optional profile values can be absent or empty; do not make a test brittle by requiring every property in the response.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

The body cannot be parsed as expected JSON

Check that the request includes Accept: application/vnd.github+json, capture the response content type, and preserve the raw body in a redacted diagnostic. A status assertion alone can hide a representation or proxy problem.

What does a complete GitHub user-info test matrix look like?

A small matrix gives better coverage than repeatedly calling one successful URL.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Test Request setup Assertions
Public positive Known public handle, no token 200, JSON, required fields and expected login
Public negative Intentionally nonexistent handle, no token 404, client’s not-found branch
Authenticated positive /user with a correctly scoped bearer token 200, required fields, expected token owner
Authentication failure /user with missing or invalid credentials 401 handling without an endless retry
Throttling behavior Controlled run that observes rate headers or a safe simulated response in the client layer Backoff, diagnostics, and no tight retry loop

Run the public contract tests frequently, but schedule authenticated and throttling scenarios according to your credential and rate-limit policy. This keeps routine checks useful without spending the entire unauthenticated budget.

Frequently Asked Questions

Should a test compare the entire GitHub profile JSON?

Usually no. A full document comparison fails when a user edits a biography or another optional value, even though the API contract is healthy. Compare the identity and field types your application consumes, and reserve full snapshots for a deliberately versioned fixture.

What does a 200 response prove about user data?

It proves that GitHub accepted the request and returned a successful representation for that endpoint. It does not prove that the profile is current for your business workflow or that every optional field is populated, so application-level freshness and completeness checks remain separate.

Can a CI job test public profiles without storing a GitHub secret?

Yes. The username endpoint can be called without authentication when the test requests public resources. A secret is needed only for the caller-specific /user test or other operations that require authentication.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How should a test report a rate-limit failure to developers?

Report the HTTP status, endpoint category, and sanitized rate-limit headers, especially the remaining count and reset information. Mark it as a retryable infrastructure condition rather than as a missing-user assertion, and stop additional requests from the same run.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

API testingAutomationcurlGitHub APIPostmanRate LimitsREST API

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.