Real-world examples of 3 practical examples of REST API with JSON response
When people search for examples of 3 practical examples of REST API with JSON response, what they usually want is not abstract definitions. They want to see:
- How a URL is structured
- What HTTP method to use
- What the JSON request body looks like
- What the JSON response looks like on success and on error
So let’s start with three core patterns you’ll see everywhere: user management, weather data, and e‑commerce orders. Then we’ll add more real examples that build on the same ideas.
Example 1: User management API (create, fetch, update)
A user API is often the first example of a REST service people encounter. It’s simple but covers most of the basics: POST, GET, PATCH, error handling, and JSON validation.
Creating a user (POST /api/users)
Request
POST /api/users HTTP/1.1
Content-Type: application/json
{
"email": "alex@example.com",
"name": "Alex Rivera",
"password": "S3curePass!",
"timezone": "America/New_York"
}
Successful JSON response
HTTP/1.1 201 Created
Content-Type: application/json
Location: /api/users/42
{
"id": 42,
"email": "alex@example.com",
"name": "Alex Rivera",
"timezone": "America/New_York",
"created_at": "2025-03-10T14:22:05Z"
}
Notice what’s missing: the password. A good JSON response never echoes sensitive fields.
Validation error JSON response
HTTP/1.1 400 Bad Request
Content-Type: application/json
{
"error": "validation_error",
"message": "Invalid request body",
"details": [
{
"field": "email",
"issue": "must be a valid email address"
},
{
"field": "password",
"issue": "must be at least 10 characters"
}
]
}
This pattern—error, message, and a details array—is one of the best examples to follow in your own REST API with JSON responses. It’s human-readable but still structured enough for clients to parse.
Getting a user (GET /api/users/{id})
Request
GET /api/users/42 HTTP/1.1
Accept: application/json
JSON response
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 42,
"email": "alex@example.com",
"name": "Alex Rivera",
"timezone": "America/New_York",
"created_at": "2025-03-10T14:22:05Z",
"last_login_at": "2025-03-11T09:15:44Z"
}
Not found JSON response
HTTP/1.1 404 Not Found
Content-Type: application/json
{
"error": "not_found",
"message": "User with id 42 was not found"
}
These user endpoints give us the first of our examples of 3 practical examples of REST API with JSON response. Next, let’s look at external data: weather.
Example 2: Weather API with JSON forecast data
Weather APIs are everywhere in mobile apps and dashboards. They’re also clean, easy-to-understand real examples of REST API design.
Imagine a simple endpoint:
GET /api/weather?city=Boston&units=imperial
Accept: application/json
JSON response
HTTP/1.1 200 OK
Content-Type: application/json
{
"location": {
"city": "Boston",
"country": "US",
"coordinates": {
"lat": 42.3601,
"lon": -71.0589
}
},
"units": "imperial",
"current": {
"temperature": 61.0,
"feels_like": 59.4,
"humidity": 72,
"wind_mph": 8.1,
"condition": "Partly Cloudy",
"observed_at": "2025-04-02T13:00:00Z"
},
"forecast": [
{
"date": "2025-04-02",
"high": 65.0,
"low": 50.0,
"condition": "Partly Cloudy",
"precip_chance": 10
},
{
"date": "2025-04-03",
"high": 63.0,
"low": 48.0,
"condition": "Light Rain",
"precip_chance": 60
}
]
}
This JSON response illustrates a few patterns you can reuse:
- A top-level
locationobject that provides context - A
currentobject for real-time data - A
forecastarray for time-series data
If you want to see a production-grade version, the National Weather Service API publishes JSON data for forecasts and alerts in the United States, documented at https://www.weather.gov/documentation/services-web-api (a good reference when you’re hunting for more examples of REST API JSON responses).
Example 3: E‑commerce orders API
For the third of our examples of 3 practical examples of REST API with JSON response, let’s move to something every online store needs: an orders API. This one combines nested objects, arrays, and status fields.
Creating an order (POST /api/orders)
Request
POST /api/orders HTTP/1.1
Content-Type: application/json
{
"customer_id": 42,
"items": [
{ "product_id": 1001, "quantity": 2 },
{ "product_id": 2005, "quantity": 1 }
],
"shipping_address": {
"line1": "123 Market St",
"city": "San Francisco",
"state": "CA",
"postal_code": "94103",
"country": "US"
},
"payment_method_id": 17
}
Successful JSON response
HTTP/1.1 201 Created
Content-Type: application/json
Location: /api/orders/98765
{
"id": 98765,
"customer_id": 42,
"status": "pending",
"items": [
{
"product_id": 1001,
"name": "Wireless Mouse",
"quantity": 2,
"unit_price": 24.99,
"line_total": 49.98
},
{
"product_id": 2005,
"name": "Mechanical Keyboard",
"quantity": 1,
"unit_price": 89.99,
"line_total": 89.99
}
],
"currency": "USD",
"subtotal": 139.97,
"tax": 11.20,
"shipping": 5.99,
"total": 157.16,
"shipping_address": {
"line1": "123 Market St",
"city": "San Francisco",
"state": "CA",
"postal_code": "94103",
"country": "US"
},
"created_at": "2025-04-02T14:10:00Z"
}
This order API is one of the best examples of nested JSON that still stays readable. It mirrors patterns used by large platforms like Stripe and Shopify.
Beyond three: more practical REST API JSON examples you’ll actually use
The phrase examples of 3 practical examples of REST API with JSON response is a mouthful, but in real life you rarely stop at three. Most production systems expose dozens of endpoints that all follow the same patterns. Here are more examples that build on the user, weather, and order APIs.
4. Login and JWT authentication
Modern apps commonly return JSON Web Tokens (JWTs) on login.
POST /api/auth/login HTTP/1.1
Content-Type: application/json
{
"email": "alex@example.com",
"password": "S3curePass!"
}
JSON response
HTTP/1.1 200 OK
Content-Type: application/json
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 3600,
"user": {
"id": 42,
"email": "alex@example.com",
"name": "Alex Rivera"
}
}
This is a very common pattern in 2024–2025, especially for single-page apps and mobile clients.
5. Paginated list of users
When you have more than a handful of records, you need pagination.
GET /api/users?page=2&page_size=20 HTTP/1.1
Accept: application/json
JSON response
HTTP/1.1 200 OK
Content-Type: application/json
{
"page": 2,
"page_size": 20,
"total_items": 145,
"total_pages": 8,
"items": [
{
"id": 41,
"email": "user41@example.com",
"name": "User 41"
},
{
"id": 42,
"email": "alex@example.com",
"name": "Alex Rivera"
}
]
}
If you look at public APIs from companies like GitHub or the U.S. government’s data portal (https://api.data.gov/), you’ll see similar patterns for pagination metadata.
6. Partial update with PATCH
Sometimes you just want to update a single field, not the entire resource.
PATCH /api/users/42 HTTP/1.1
Content-Type: application/json
{
"timezone": "America/Los_Angeles"
}
JSON response
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 42,
"email": "alex@example.com",
"name": "Alex Rivera",
"timezone": "America/Los_Angeles",
"updated_at": "2025-04-02T15:30:00Z"
}
This is another one of those quiet but powerful real examples that shows how REST APIs evolve as products grow.
7. Health data API example (steps and heart rate)
Health apps and wearables rely heavily on JSON APIs. For inspiration, you can look at how research platforms structure data, such as the NIH and academic projects listed at https://www.nlm.nih.gov/healthit.html. Here’s a simplified, privacy-friendly example.
GET /api/users/42/health/summary?date=2025-04-01 HTTP/1.1
Accept: application/json
JSON response
HTTP/1.1 200 OK
Content-Type: application/json
{
"user_id": 42,
"date": "2025-04-01",
"steps": 10432,
"calories_burned": 520,
"sleep_hours": 7.2,
"average_heart_rate_bpm": 72,
"resting_heart_rate_bpm": 60
}
This is the kind of JSON payload a mobile health app might consume to show daily summaries.
Why these are good examples of REST API JSON responses
Across all these examples of 3 practical examples of REST API with JSON response (and the extra ones we added), a few patterns repeat:
- Clear, predictable resource URLs (
/api/users,/api/orders,/api/weather) - Consistent use of HTTP methods: GET for reads, POST for create, PATCH for partial updates
- JSON responses that are:
- Self-describing (fields have obvious meaning)
- Stable over time (new fields can be added without breaking clients)
- Safe (no sensitive data like raw passwords)
- Standard error shapes with
errorandmessagefields
If you’re designing your own API, treating these as reference designs is far more helpful than reading another abstract definition of REST. They’re real examples you can copy, then adapt to your own domain.
For more background on JSON itself, the official specification is published by the IETF at https://www.rfc-editor.org/rfc/rfc8259. It’s a short read and pairs well with studying practical REST API responses like the ones above.
FAQ: common questions about REST API JSON examples
What are some real examples of REST API with JSON response?
Real-world examples include user registration and login endpoints, weather forecast services, e‑commerce order creation, health data summaries from wearables, paginated lists of resources, and partial updates with PATCH. The user, weather, and order scenarios in this article are three of the best examples to start with if you want practical patterns you can reuse.
Can you give an example of a simple REST API JSON response?
A minimal JSON response might look like this:
{
"id": 1,
"name": "Sample Item",
"active": true
}
Even this tiny example of a REST API response shows the key idea: a resource represented as a JSON object with fields that a client can parse and display.
How many fields should a JSON response have in a REST API?
There’s no fixed number. The examples of 3 practical examples of REST API with JSON response in this guide show both small and larger payloads. The rule of thumb is: include what the client actually needs, keep naming consistent, and avoid returning sensitive data. If payloads get too large, consider pagination, filtering, or separate endpoints for summary vs. detailed views.
Where can I find more public JSON API examples?
You can explore:
- The National Weather Service API: https://www.weather.gov/documentation/services-web-api
- The U.S. government’s data APIs: https://api.data.gov/
- Health IT resources from the National Library of Medicine: https://www.nlm.nih.gov/healthit.html
Studying these alongside the examples of 3 practical examples of REST API with JSON response here will give you a strong mental model for designing and consuming JSON APIs.
Related Topics
Modern examples of diverse examples of pagination in REST API design
Real-world examples of 3 practical examples of REST API with JSON response
Modern examples of diverse REST API query parameter patterns
Modern examples of asynchronous requests to REST API (with real code)
Explore More REST API Examples
Discover more examples and insights in this category.
View All REST API Examples