15 Real-World API Examples: Online HTTP GET, POST & JSON Requests You Can Test
Inspect and test 15 real-world API online examples spanning public GET endpoints, authenticated POST requests, JSON payloads, HTTP status codes, webhooks, cURL, JavaScript fetch, and Python requests.
When you search for a practical API online example, you usually want more than an abstract diagram—you want real HTTP request headers, valid JSON payloads, realistic server responses, and copy-paste client code in cURL, JavaScript fetch(), and Python requests that you can run and inspect immediately.
Quick Summary: 15 Real-World API Examples by Method & Auth
The table below indexes all 15 practical REST API examples covered in this guide across public no-auth endpoints, authenticated CRUD operations, webhooks, and error responses:
| # | API Example Use Case | HTTP Method | Status Code | Auth Pattern |
|---|---|---|---|---|
| 1 | Live Weather Forecast (Open-Meteo) | GET | 200 OK | Public (No Key) |
| 2 | Foreign Exchange Rates (USD Base) | GET | 200 OK | Public (No Key) |
| 3 | GitHub Developer Profile Lookup | GET | 200 OK | Public / Optional Token |
| 4 | Create User Account (JSON Body) | POST | 201 Created | API Key Header |
| 5 | JWT Login & Token Issuance | POST | 200 OK | Credentials in Body |
| 6 | Stripe Payment Intent Creation | POST | 200 OK | Bearer Secret Key |
| 7 | Paginated Product Catalog Query | GET | 200 OK | Bearer JWT |
| 8 | Partial Profile Update | PATCH | 200 OK | Bearer JWT |
| 9 | Idempotent Resource Replacement | PUT | 200 OK | Bearer JWT |
| 10 | Delete Session / Revoke Token | DELETE | 204 No Content | Bearer JWT |
| 11 | AI Chat Completion Request | POST | 200 OK | x-api-key Header |
| 12 | IP Geolocation & ASN Lookup | GET | 200 OK | Public (Rate-Limited) |
| 13 | Signed Webhook Event Delivery | POST | 200 OK | HMAC-SHA256 Signature |
| 14 | Validation Error (RFC 7807) | POST | 422 Unprocessable | Bearer JWT |
| 15 | Rate Limit Throttling Response | GET | 429 Too Many Req | API Key Header |
Part 1: Public GET API Online Examples (Testable in Your Browser)
Public GET endpoints are the easiest way to test an API online example because they require no authentication headers—you can paste the URL directly into your browser, curl, or fetch().
1. Weather Forecast API Example (Open-Meteo)
Passes geographic coordinates (latitude and longitude) via URL query parameters and returns current temperature, wind speed, and WMO weather code in JSON:
GET https://api.open-meteo.com/v1/forecast?latitude=37.77&longitude=-122.41¤t_weather=true HTTP/1.1
Host: api.open-meteo.com
Accept: application/json
// HTTP/1.1 200 OK
{
"latitude": 37.77,
"longitude": -122.41,
"generationtime_ms": 0.42,
"utc_offset_seconds": 0,
"current_weather": {
"temperature": 16.4,
"windspeed": 12.8,
"winddirection": 285,
"weathercode": 3,
"is_day": 1,
"time": "2026-11-09T14:00"
}
}
2. Currency Exchange Rate API Example
E-commerce checkouts and fintech dashboards query currency conversion endpoints using a 3-letter ISO 4217 base currency path parameter (/v6/latest/USD):
GET https://open.er-api.com/v6/latest/USD HTTP/1.1
Host: open.er-api.com
Accept: application/json
// HTTP/1.1 200 OK
{
"result": "success",
"base_code": "USD",
"time_last_update_utc": "Mon, 09 Nov 2026 00:02:31 +0000",
"rates": {
"USD": 1,
"EUR": 0.924,
"GBP": 0.791,
"JPY": 154.20,
"INR": 84.15,
"CAD": 1.389
}
}
3. GitHub REST API User Profile Example
Demonstrates clean REST resource naming (/users/:username) and standard response metadata. Test this live in our GitHub REST API Sandbox:
GET https://api.github.com/users/octocat HTTP/1.1
Host: api.github.com
Accept: application/vnd.github+json
User-Agent: Cometflow-API-Inspector/1.0
// HTTP/1.1 200 OK
{
"login": "octocat",
"id": 583231,
"type": "User",
"name": "The Octocat",
"company": "@github",
"location": "San Francisco",
"public_repos": 8,
"followers": 14820,
"created_at": "2011-01-25T18:44:36Z"
}
Part 2: Authenticated POST, PATCH, PUT & DELETE REST API Examples
Production web applications spend most of their time creating, updating, and deleting records over HTTPS using JSON request bodies and authentication headers.
4. Create User Resource (POST Request & 201 Created Response)
When creating a new database record, the client sends POST with Content-Type: application/json, and the server responds with 201 Created plus a Location header pointing to the newly minted resource URI:
POST /api/v1/users HTTP/1.1
Host: api.acmecloud.dev
Content-Type: application/json
X-API-Key: ak_live_99104bc8a1
{
"email": "elena.rostova@acmecloud.dev",
"fullName": "Elena Rostova",
"role": "developer",
"organizationId": "org_4409"
}
// HTTP/1.1 201 Created
// Location: /api/v1/users/usr_88219
{
"id": "usr_88219",
"email": "elena.rostova@acmecloud.dev",
"fullName": "Elena Rostova",
"role": "developer",
"status": "pending_verification",
"createdAt": "2026-11-09T09:15:22Z"
}
5. JWT Authentication Login Example (POST /auth/login)
Exchanges user credentials for a short-lived signed JSON Web Token (accessToken) and expiration timestamp. (You can inspect Bearer JWT headers in our Bearer Token JWT Auth API Example.)
POST /api/v1/auth/login HTTP/1.1
Host: api.acmecloud.dev
Content-Type: application/json
{
"email": "elena.rostova@acmecloud.dev",
"password": "correct-horse-battery-staple"
}
// HTTP/1.1 200 OK
{
"tokenType": "Bearer",
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c3JfODgyMTkiLCJyb2xlIjoiZGV2ZWxvcGVyIiwiZXhwIjoxNzYyNjkxNzIyfQ.7Kp9x...",
"expiresIn": 3600,
"refreshToken": "rt_9f81c2b740e5"
}
6. Payment Intent Creation with Bearer Auth & Idempotency Key
Financial APIs use an Idempotency-Key header so network retries never charge a customer twice:
POST /v1/payment_intents HTTP/1.1
Host: api.stripe.com
Authorization: Bearer sk_test_51Nq9ExampleKey000
Idempotency-Key: idem_order_7741_attempt_1
Content-Type: application/json
{
"amount": 4900,
"currency": "usd",
"payment_method_types": ["card"],
"metadata": { "order_id": "ord_7741" }
}
// HTTP/1.1 200 OK
{
"id": "pi_3Qd81L2eZvKYlo2C0192",
"object": "payment_intent",
"amount": 4900,
"currency": "usd",
"status": "requires_payment_method",
"client_secret": "pi_3Qd81L2eZvKYlo2C0192_secret_9a8B7c"
}
7. Cursor-Paginated Product Catalog (GET with Query Filters)
GET /api/v1/products?category=hardware&limit=2&cursor=cur_102 HTTP/1.1
Host: api.acmecloud.dev
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
// HTTP/1.1 200 OK
{
"data": [
{ "id": "prd_103", "sku": "MECH-KB-80", "priceCents": 12900, "inStock": true },
{ "id": "prd_104", "sku": "USB4-DOCK-PRO", "priceCents": 18900, "inStock": true }
],
"pagination": {
"limit": 2,
"nextCursor": "cur_104",
"hasMore": true
}
}
8. Partial Resource Update (PATCH /api/v1/users/:id)
Unlike PUT (which replaces the entire record), PATCH modifies only the fields included in the JSON payload:
PATCH /api/v1/users/usr_88219 HTTP/1.1
Host: api.acmecloud.dev
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
Content-Type: application/json
{
"timezone": "America/New_York",
"marketingEmails": false
}
// HTTP/1.1 200 OK
{
"id": "usr_88219",
"timezone": "America/New_York",
"marketingEmails": false,
"updatedAt": "2026-11-09T09:24:10Z"
}
9. Full Resource Replacement (PUT /api/v1/webhooks/:id)
PUT /api/v1/webhooks/wh_551 HTTP/1.1
Host: api.acmecloud.dev
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
Content-Type: application/json
{
"targetUrl": "https://hooks.clientapp.io/events",
"events": ["order.created", "order.fulfilled"],
"active": true
}
// HTTP/1.1 200 OK
{
"id": "wh_551",
"targetUrl": "https://hooks.clientapp.io/events",
"events": ["order.created", "order.fulfilled"],
"active": true
}
10. Delete Resource Idempotently (DELETE → 204 No Content)
DELETE /api/v1/sessions/sess_90214 HTTP/1.1 Host: api.acmecloud.dev Authorization: Bearer eyJhbGciOiJIUzI1NiIs... // HTTP/1.1 204 No Content // (Empty response body confirms the session was permanently removed)
Part 3: AI, Geolocation, Webhooks & Error Handling API Examples
11. AI Structured Text Generation API Example
POST /v1/chat/completions HTTP/1.1
Host: api.inference.example.com
Authorization: Bearer sk_live_ai_8812
Content-Type: application/json
{
"model": "llm-fast-2026",
"temperature": 0.2,
"messages": [
{ "role": "system", "content": "Reply with concise JSON." },
{ "role": "user", "content": "Extract HTTP method and path from: GET /v1/orders" }
]
}
// HTTP/1.1 200 OK
{
"id": "chatcmpl_9921",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "{\"method\":\"GET\",\"path\":\"/v1/orders\"}" },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 29, "completion_tokens": 12, "total_tokens": 41 }
}
12. IP Geolocation & Network ASN Lookup (GET)
GET https://ipapi.co/8.8.8.8/json/ HTTP/1.1
Host: ipapi.co
Accept: application/json
// HTTP/1.1 200 OK
{
"ip": "8.8.8.8",
"city": "Mountain View",
"region": "California",
"country_name": "United States",
"timezone": "America/Los_Angeles",
"asn": "AS15169",
"org": "GOOGLE"
}
13. Incoming Signed Webhook Payload (POST with HMAC Signature)
POST /webhooks/billing HTTP/1.1
Host: your-server.example.com
Content-Type: application/json
X-Webhook-Signature: t=1762680000,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
{
"eventId": "evt_409182",
"type": "invoice.paid",
"createdAt": "2026-11-09T09:00:00Z",
"data": {
"invoiceId": "inv_7731",
"customerId": "cus_1920",
"amountPaidCents": 9900
}
}
14. Validation Error Response (HTTP 422 Unprocessable Content — RFC 7807)
Well-designed APIs return structured field-level diagnostics when request parameters fail validation:
HTTP/1.1 422 Unprocessable Content
Content-Type: application/problem+json
{
"type": "https://api.acmecloud.dev/errors/validation-failed",
"title": "Request Validation Failed",
"status": 422,
"detail": "One or more fields in the request body failed schema validation.",
"errors": [
{ "field": "email", "message": "Must be a valid RFC 5322 email address." },
{ "field": "age", "message": "Must be an integer greater than or equal to 18." }
]
}
15. Rate Limit Exceeded Response (HTTP 429 Too Many Requests)
HTTP/1.1 429 Too Many Requests
Retry-After: 30
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1762680030
Content-Type: application/json
{
"error": "rate_limit_exceeded",
"message": "Quota of 100 requests per minute exceeded. Retry after 30 seconds.",
"retryAfterSeconds": 30
}
Copy-Paste Client Code: cURL, JavaScript Fetch & Python Requests
Below is the same production API call implemented across the three most common developer environments, complete with headers, timeouts, and HTTP status error handling. You can convert any cURL command into fetch code automatically with our cURL to Fetch & Python Converter.
A. Terminal cURL Example
curl -i -X POST "https://api.acmecloud.dev/api/v1/users" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d '{
"email": "elena.rostova@acmecloud.dev",
"fullName": "Elena Rostova",
"role": "developer"
}'
B. JavaScript / TypeScript fetch() Example
async function createDeveloperUser(token) {
const response = await fetch("https://api.acmecloud.dev/api/v1/users", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${token}`
},
body: JSON.stringify({
email: "elena.rostova@acmecloud.dev",
fullName: "Elena Rostova",
role: "developer"
})
});
if (!response.ok) {
const errorBody = await response.json().catch(() => ({}));
throw new Error(`API Error ${response.status}: ${errorBody.message || response.statusText}`);
}
const data = await response.json();
console.log("Created user:", data.id);
return data;
}
C. Python requests Example
import requests
url = "https://api.acmecloud.dev/api/v1/users"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
payload = {
"email": "elena.rostova@acmecloud.dev",
"fullName": "Elena Rostova",
"role": "developer"
}
response = requests.post(url, json=payload, headers=headers, timeout=10)
response.raise_for_status()
print("Status:", response.status_code)
print("JSON payload:", response.json())
API Testing & Debugging Checklist
- Validate JSON Payloads First: A single trailing comma or unquoted key triggers
400 Bad Request. Paste raw payloads into the JSON Formatter & Validator before sending. - Inspect Status Codes & Response Headers: Check
Content-Type,X-RateLimit-Remaining, andRetry-Afterheaders—not just the JSON body. See our HTTP Status Codes Cheat Sheet. - Test Live Endpoints in the Browser: Try 33+ pre-configured endpoints with live request/response inspection in the Cometflow Interactive API Examples Hub.
Frequently Asked Questions
What is a simple API online example I can test in my browser right now?
You can test a public HTTP GET endpoint directly in your browser address bar or terminal without an API key using Open-Meteo (https://api.open-meteo.com/v1/forecast?latitude=37.77&longitude=-122.41¤t_weather=true) or the GitHub REST API (https://api.github.com/users/octocat). Both return live, structured JSON responses with HTTP 200 OK.
What is the difference between a GET and a POST REST API request example?
An HTTP GET request retrieves data from a server using URL path and query parameters (such as ?limit=10) without modifying server state and carries no request body. An HTTP POST request sends a structured payload (usually Content-Type: application/json) in the request body to create a new resource or trigger a server calculation, typically returning HTTP 201 Created or 200 OK.
How do I send an authenticated API request using a Bearer token?
Include the Authorization header in your HTTP request formatted as Authorization: Bearer <your_token>. Never pass secret API keys or JWT tokens in URL query parameters where they can be exposed in browser history, proxy logs, and referrer headers.
Which HTTP status codes should every API developer handle?
Production API clients should handle 200 OK (success), 201 Created (resource created), 204 No Content (successful deletion), 400 Bad Request (malformed JSON/params), 401 Unauthorized (missing/expired token), 403 Forbidden (insufficient permissions), 404 Not Found, 422 Unprocessable Content (validation error), 429 Too Many Requests (rate limit exceeded), and 500/503 server errors.
How do I debug a failing API request when testing online?
First inspect the raw HTTP status code and response body. Check that Content-Type: application/json is set when sending JSON, verify your Authorization header format, validate your JSON payload syntax in a JSON Formatter, and check the browser Network tab if a CORS preflight OPTIONS request is blocked.