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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To test GitHub user information, send a GET request to https://api.github.com/users/{username} for a public profile, or to https://api.github.com/user when you need the profile belonging to an access token. Send Accept: application/vnd.github+json and GitHub’s version header, then assert the status code, JSON shape, and rate-limit headers. A successful public lookup returns HTTP 200; an unknown handle should return 404. Authenticated calls can additionally return 401 or 403. The walkthrough below shows the same checks in cURL and Postman, explains token requirements, and gives a recovery path for rate limits and common failures.

What is the difference between GitHub’s two user endpoints?

The endpoint you choose depends on whether the test names a GitHub handle or identifies the caller with a token. Public profile tests use the handle in the URL. Authenticated profile tests use the token owner and do not put a username in the path.

Use case Method and path Authentication Typical result
Look up a known public account GET https://api.github.com/users/{username} Not required when requesting only public resources HTTP 200 with the account’s publicly available information
Look up the caller’s account GET https://api.github.com/user Bearer token required HTTP 200 for a valid, authorized token; the response represents the token owner

GitHub describes /users/{username} as providing publicly available information about someone with a GitHub account. The {username} value is the account handle, not a display name. A request without authentication is valid only for public resources; adding a token does not turn this endpoint into a general private-data query.

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

/user is caller-specific. 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 also supported for this endpoint. The token is therefore part of the test fixture, not a value to commit in a repository.

#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.

What should a GitHub user API test prove?

A useful test checks protocol behavior and a small set of durable fields rather than comparing an entire profile that can change over time. Start with one known public handle, one intentionally nonexistent handle, and (if your application uses caller data) one valid token plus invalid or missing-token cases.

Positive public case

  • The request uses GET and the expected URL.
  • The response status is 200.
  • The response is JSON.
  • The body contains login, id, html_url, and type with the expected basic data types.
  • Optional profile values, such as name or public_repos, are checked only when your application needs them and when they are present.

Negative public case

Use a deliberately nonexistent handle and assert HTTP 404. This confirms that your client distinguishes “the account is not found” from a transport failure or an empty response. Do not use a real account that could be renamed or deleted as your negative fixture.

Authenticated cases

  • A valid token sent to /user should produce 200 and a profile for that token owner.
  • A missing, malformed, expired, or otherwise unacceptable credential can produce 401, depending on the documented endpoint behavior.
  • A request that is authenticated but not permitted, or that triggers another documented policy, can produce 403.

Keep assertions focused on the contract your code consumes. A test that requires every field in a profile to match a saved fixture will fail for harmless profile edits and will not tell you whether the endpoint contract broke.

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

How do I test GET /users/{username} with cURL?

Use a known public handle for the positive test and an intentionally nonexistent handle for the negative test. The following commands include the media-type and version headers used in GitHub’s versioned examples.

1. Send a public lookup

  1. Choose a handle that is publicly visible and stable enough for a test fixture.
  2. Run the request, replacing octocat with that handle:
curl --request GET 
  --url https://api.github.com/users/octocat 
  --header 'Accept: application/vnd.github+json' 
  --header 'X-GitHub-Api-Version: 2026-03-10'

The JSON response should describe the requested account. For a contract test, parse the response rather than matching formatted text. Confirm that login, id, html_url, and type exist and have the types your application expects. Profile fields such as name can be absent, so treat them as nullable or optional unless your own contract says otherwise.

2. Check the HTTP result and headers

Use cURL’s header output when diagnosing a failure:

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.
curl --include --silent --show-error 
  --request GET 
  --url https://api.github.com/users/octocat 
  --header 'Accept: application/vnd.github+json' 
  --header 'X-GitHub-Api-Version: 2026-03-10'

--include prints the status line and response headers before the JSON body. Record the rate-limit headers in test diagnostics, but avoid writing a token or private response body to shared logs.

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

3. Verify the not-found branch

Send the same request with a handle that you intentionally know does not exist:

curl --include --silent --show-error 
  --request GET 
  --url https://api.github.com/users/this-user-should-not-exist-in-tests 
  --header 'Accept: application/vnd.github+json' 
  --header 'X-GitHub-Api-Version: 2026-03-10'

Your test should expect 404 for this fixture. If it unexpectedly returns 200, the fixture has become a real account and must be replaced; do not weaken the assertion.

How do I test the public endpoint in Postman?

Postman can represent the same request without changing the API contract. Save the request in a collection so the positive and negative cases share headers and diagnostics.

  1. Create a new request and select GET.
  2. Enter https://api.github.com/users/{{username}} as the URL. Define username as an environment or collection variable rather than editing the URL for every case.
  3. On the Headers tab, add Accept with value application/vnd.github+json.
  4. Add X-GitHub-Api-Version with value 2026-03-10, matching the versioned examples.
  5. Leave authorization unset for a public-data test. This makes it clear that the case exercises unauthenticated access.
  6. Send the request and inspect the status, response headers, and JSON body.
  7. Duplicate the request for the negative case and set username to your intentionally nonexistent fixture. Keep the expected status at 404.

In the request’s Tests script, assert the contract rather than a particular display name. A minimal Postman example is:

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 body = pm.response.json();
pm.test("required user fields are present", function () {
  pm.expect(body).to.have.property("login");
  pm.expect(body).to.have.property("id");
  pm.expect(body).to.have.property("html_url");
  pm.expect(body).to.have.property("type");
});

Use a separate test script for the negative request so that 404 is the expected outcome, not an accidental failure of the positive test. If the collection runs repeatedly, keep the known handle and the nonexistent handle in variables that can be changed without editing scripts.

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 I test the authenticated GET /user endpoint?

Send the token as a Bearer credential and verify that the returned profile belongs to that token owner. The endpoint does not take a username parameter, so a test that substitutes /users/{username} is testing a different behavior.

1. Prepare the credential safely

Create a token with the permissions required by your integration. OAuth app tokens and classic personal access tokens need read:user or the broader user scope for the private user response. Fine-grained personal access tokens and GitHub App user access tokens are supported as well. Store the value in a secret manager, CI secret, or a local environment variable. Never commit it, paste it into a public issue, or print it in diagnostic output.

2. Send the request with cURL

curl --request GET 
  --url https://api.github.com/user 
  --header 'Accept: application/vnd.github+json' 
  --header 'X-GitHub-Api-Version: 2026-03-10' 
  --header "Authorization: Bearer $GITHUB_TOKEN"

Replace $GITHUB_TOKEN through your shell’s secret mechanism. Do not put a literal token in a command that will be saved in shell history or pasted into a ticket. A successful response should be checked for the same durable identity fields, while the expected login should match the test account selected for the secret.

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.

3. Configure the request in Postman

  1. Set the method to GET and the URL to https://api.github.com/user.
  2. Keep the Accept and X-GitHub-Api-Version headers from the public request.
  3. On the Authorization tab, choose Bearer Token.
  4. Reference an environment variable such as {{github_token}}; mark the environment as private and avoid sharing its initial value.
  5. Send the request and assert 200, JSON, and the identity fields your application uses.

For a credential failure test, remove the token or use a deliberately invalid test credential and assert the documented unauthorized behavior. Do not repeatedly exercise invalid credentials against a shared account: it adds noise, can trigger protection mechanisms, and does not improve the contract test.

Which headers and response fields should tests assert?

Always send the explicit media-type header and the API-version header so that a future default change does not silently alter your test. Assert the response properties that are stable and meaningful to your application.

Item Recommended check Why it matters
Accept Exactly application/vnd.github+json Requests GitHub’s JSON representation explicitly
X-GitHub-Api-Version Use the version in the documented example: 2026-03-10 Makes version selection visible and reproducible
login Present and a string; for /user, compare with the fixture account Identifies the account handle
id Present and numeric in the decoded JSON value Provides a stable account identifier for application logic
html_url Present and a URL-shaped string Links the API object to its public profile page
type Present and a string Confirms the returned object type your client expects
name, public_repos Check when needed, but allow absence where the profile does not provide a value These are useful profile data, not universally required fields
Content type Verify that the response is JSON Prevents a client from treating an error document or proxy response as a user object

Do not make the test depend on field ordering, pretty-printing, or values that the account owner can edit. If your application maps additional fields, add targeted assertions for those fields and document whether null or missing values are accepted.

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

How should tests handle 404, 401, 403, and rate-limit responses?

Each status represents a different branch in client behavior. Keep the branches separate so a missing account is not reported as an authentication outage and a rate-limit response is not retried as if it were a permanent 404.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Status Likely meaning in this tutorial Test response
200 The requested user representation was returned Validate JSON and required fields
404 The handle in /users/{username} is unknown Use the intentional nonexistent fixture and stop treating it as a valid user
401 The authenticated request did not provide acceptable credentials Check token presence, format, expiry, and the account used by the test
403 The request is forbidden or has encountered a documented policy limit Inspect the response and rate-limit headers before deciding whether to retry
429 A rate-limit response can be returned for excessive requests Honor the reset information and back off instead of looping immediately

A proxy, corporate gateway, or test harness can also produce an HTML error or a connection failure before GitHub returns a status. Record the actual status line and content type so those failures are distinguishable from API assertions.

What are GitHub’s user API rate limits?

Unauthenticated requests for public data have a primary limit of 60 requests per hour. Authenticated requests generally have a personal limit of 5,000 requests per hour. These are budgets, not a guarantee that a test can run indefinitely without other protections.

Request mode Primary limit Practical testing implication
Unauthenticated public request 60 requests per hour Reuse fixtures, avoid per-assertion calls, and do not run tight polling loops
Authenticated personal request Generally 5,000 requests per hour Use a dedicated test credential and still control concurrency and retries
Secondary concurrency guidance 100 maximum concurrent requests Cap parallel workers and queue excess work rather than opening unbounded connections

Inspect x-ratelimit-limit, x-ratelimit-remaining, x-ratelimit-reset, and related headers on every diagnostic response. The reset value tells you when the primary window can be used again. When a request receives 403 or 429 because of rate limiting, follow GitHub’s guidance: wait for the indicated period, reduce concurrency, and retry with backoff. A retry loop that immediately repeats the same request can extend the outage and consume more budget.

Designing a rate-limit-safe test run

  • Run one positive and one negative request per test suite, not once per assertion.
  • Cache a response when testing downstream parsing that does not require a fresh API call.
  • Keep concurrent workers below the documented secondary limit and set a finite retry count.
  • Log status and rate-limit metadata, but redact authorization headers and private response data.
  • Fail with a clear “rate limited” diagnostic rather than labeling the API contract broken when the remaining budget is zero.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How can I troubleshoot a failing GitHub user API test?

Start by comparing the exact method, URL, headers, credential mode, and expected status. Most failures become obvious when those five values are printed without secrets.

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

The public request returns 404 unexpectedly

  • Check that the path uses the account’s login handle, not its display name.
  • Check URL encoding if the handle is being built dynamically.
  • Confirm that the positive fixture has not been renamed, deleted, or replaced.
  • Send the same URL once with headers included so you can rule out a proxy rewriting the request.

The authenticated request returns 401

  • Confirm that the Authorization header is exactly Bearer <TOKEN> and is attached to /user.
  • Verify that the secret variable is populated in the environment that actually runs the test.
  • Check whether the token is expired, revoked, or copied with whitespace.
  • For OAuth app or classic personal access tokens, verify the read:user or broader user scope required for the private user response.

The request returns 403 or 429

Read the rate-limit headers before changing the endpoint. If the remaining budget is exhausted, pause until the reset time and apply exponential or otherwise increasing backoff. If the headers do not indicate exhaustion, inspect the response body and your account or application policy; do not assume every 403 is a transient network error.

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 parses but fields are missing

Distinguish required identity fields from optional profile data. A missing name is not equivalent to a missing login; update the client schema or assertion according to what your application actually needs.

What should a maintainable test suite look like?

Keep endpoint selection, credentials, fixtures, and assertions explicit. A small suite can provide strong coverage without consuming the rate budget.

  1. Public contract test: call /users/{username} without authentication and assert 200, JSON, and the four required identity fields.
  2. Not-found test: call the intentionally nonexistent handle and assert 404.
  3. Authenticated contract test: call /user with a secret token and assert 200 plus the expected test account identity.
  4. Unauthorized test: run a controlled call without an acceptable credential and assert the documented 401 behavior.
  5. Diagnostics: capture status, content type, and rate-limit headers while redacting tokens and private payloads.
  6. Backoff policy: stop or delay on rate-limit 403 or 429; never retry in a tight loop.

Separate these cases in your collection or CI job. That way a public fixture can run on every change without exposing a secret, while the authenticated case runs only in an environment that has the required credential. Keep the API-version header in one shared request definition so upgrading it is a deliberate change reviewed alongside assertion updates.

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

Is authentication required to test public GitHub user information?

No. GitHub explicitly allows the public user endpoint without authentication when the request asks only for public resources. Authentication is required for the caller-specific /user response and can increase the primary request budget, but it also introduces secret management, scope, expiry, and permission failure modes.

Use the unauthenticated case when you are testing public-profile lookup. Add the authenticated case only when your product depends on the token owner’s identity or private user response; otherwise, a token can hide defects in the public access path and needlessly consume a credential’s rate budget.

Frequently Asked Questions

Can I use an email address instead of a GitHub username in the user endpoint?

No. The public route expects the account’s login handle in the {username} path parameter. A display name or email address is not a substitute for that path value.

Why does my authenticated test return a different account than expected?

GET /user describes the owner of the token that was sent, not the person named in a URL. Check which secret your environment variable resolves to and compare the returned login with the account intended for the test.

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

Should I save complete GitHub user responses as golden files?

Usually not. Profile values can change and optional fields can be absent, so contract tests are more durable when they validate required identity fields and types. Keep a narrowly scoped fixture only for application-specific mappings that truly require exact values.

How do I prevent a CI job from leaking a GitHub token?

Store the token in the CI system’s secret store, inject it at runtime, and redact authorization headers and response bodies in logs. Use a separate test credential with only the permissions needed for the endpoint, and revoke it when the job no longer needs it.

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.