In the blogging app, a user taps a button to see all posts tagged “travel.” The app sends this request:
GET https://myblog.com/api/posts?tag=travel
The server responds with:
{ "posts": [ { "id": 1, "title": "My Trip to Paris", "tag": "travel" } ] }
What role does the API play here?
It displays the post titles on the user’s screen
It acts as a middleman, passing the request to the server and returning the data
It translates the JSON into a webpage
It stores the “travel” posts in the app’s memory
It creates a new post with the “travel” tag
You’re an admin adding a new post to the blogging app with this request:
POST https://myblog.com/api/posts
Body:
{ "title": "Beach Day!", "tag": "travel", "content": "Loved the sun!" }
{ "id": 3, "status": "Post created" }
What does the POST method tell the server to do?
POST
Fetch all posts with the “travel” tag
Update an existing post’s title
Create a new post with the provided data
Delete a post with ID 3
Filter posts by date
You test the “Dad Joke” API in your terminal:
curl -H "Accept: application/json" https://icanhazdadjoke.com/
The response is:
{ "id": "abc123", "joke": "Why don’t skeletons fight? They don’t have the guts.", "status": 200 }
Why might you choose JSON over plain text for the blogging app?
Plain text is harder for the server to process
JSON is faster to send over the internet
JSON is required for all APIs
Plain text can’t include multiple pieces of information
JSON structures data (e.g., id, joke) for easy use in the app
The blogging app filters posts by date with this request:
GET https://myblog.com/api/posts?date=2025-03
The server returns:
{ "posts": [ { "id": 1, "title": "My Trip to Paris", "date": "2025-03-01"\ }, { "id": 2, "title": "Hiking in Japan", "date": "2025-03-15" } ] }
What would happen if the app used GraphQL instead of REST for this?
The request would fail because GraphQL doesn’t use URLs
The server would return all post details, including content
The app could request only titles and dates in one query
The server would send XML instead of JSON
GraphQL would notify the app of new posts instantly
Imagine a news feed app subscribes to the blogging app’s API. When you add a new post, the news feed gets updated instantly. Which API type makes this possible?
REST API
GraphQL API
JSON API
SOAP API
Webhook
This content is only available to registered users.Please register at the the home page.