Final exam
APIs, REST and JSON Basics
Before you start
- 20 questions, drawn at random from a pool of 32.
- Pass mark: 70%. Your final score is 30% practice + 70% exam.
- No time limit, but finish within 3 hours. You can move between questions before you submit.
- Failed? Review the lessons and try again: every attempt gets a new set of questions.
Question 1 of 20Choose one
What best describes an API?
Question 2 of 20True or false
In a web API conversation, the server normally starts the exchange by sending data to the client.
Question 3 of 20Match the pairs
Match each part of https://api.maps.example/v3/places/ch_81/photos?size=large to its role.
Tap an answer, then tap the place where it belongs (or drag it there).
httpsapi.maps.example/v3/places/ch_81/photossize=large
Question 4 of 20Sort into groups
Sort each item into the part of an HTTP message it belongs to.
Tap an item, then tap its group (or drag it there).
Question 5 of 20Work it out
A server responds HTTP/1.1 503 Service Unavailable. What is the status code family number (the first digit)?
Question 6 of 20Spot the mistake
Click every line that makes this JSON invalid.
Question 7 of 20Choose one
Which JSON value has the type number?
Question 8 of 20Fill in the blanks
Fill in the blanks
In JavaScript, converting JSON text into an object is done with JSON.(), and converting an object into JSON text with JSON.().
Question 9 of 20Work it out
An API returns {"items": [{"qty": 3, "price": 4.5}, {"qty": 2, "price": 10}, {"qty": 1, "price": 0.75}]}. What is the total of qty × price across all items?
Question 10 of 20True or false
After parsing, {"id": "1234567890123456789"} gives an id that should be kept as a string, because converting such large integers to JavaScript numbers can lose precision.
Question 11 of 20Choose one
Which endpoint best follows REST conventions for deleting comment 31 on post 12?
Question 12 of 20What would you do?
What would you do?
An API requires clients to first call POST /start-session, after which the server remembers the user in memory for later calls. Traffic grows, and the team adds four more servers behind a load balancer. Users start getting "no session" errors at random. Which REST principle was ignored?
Question 13 of 20Match the pairs
Match each operation to the usual HTTP method.
Tap an answer, then tap the place where it belongs (or drag it there).
- Read a list of invoices
- Create a new invoice
- Change only the due date of an invoice
- Replace an invoice entirely
- Remove an invoice
Question 14 of 20Select all that apply
Which methods are idempotent by definition? Select all that apply.
Select all that apply.
Question 15 of 20Choose one
A checkout page sends POST /payments and the request times out. Why is blindly resending it risky, and what do payment APIs offer to make retries safe?
Question 16 of 20Match the pairs
Match each status code to its meaning.
Tap an answer, then tap the place where it belongs (or drag it there).
- 201
- 204
- 400
- 404
- 500
Question 17 of 20What would you do?
What would you do?
A user is signed in and has a valid token, but tries to view another company's invoices. Which response should the API return?
Question 18 of 20Sort into groups
Which failures should a client retry automatically (with backoff), and which should it not?
Tap an item, then tap its group (or drag it there).
Question 19 of 20True or false
JavaScript's fetch rejects its Promise when the server responds with 404 or 500.
Question 20 of 20Fill in the blanks
Fill in the blanks
Gluing raw text into a URL is unsafe. A space must be percent-encoded as and an ampersand as .
Question 21 of 20Work it out
An API returns 25 items per page using offset pagination. Which offset requests the 5th page?
Question 22 of 20Work it out
How many requests are needed to download 2,010 records at 200 records per page?
Question 23 of 20Choose one
What is the main advantage of cursor pagination over offset pagination for a fast-changing feed?
Question 24 of 20Choose one
A mobile app needs to call a third-party API that requires a secret key. Where should the key live?
Question 25 of 20Put in order
Order the steps of an OAuth 2.0 authorization code flow.
Drag the items, or use the arrow buttons, to put them in order.
- App calls the API with the bearer token
- User signs in at the provider and approves scopes
- App server exchanges the code for an access token
- User clicks "Connect" and is sent to the provider
- Provider redirects back to the app with a code
Question 26 of 20Work it out
A data sync needs 2,400 requests, and the API allows 80 requests per minute. What is the minimum time in minutes to finish without exceeding the limit?
Question 27 of 20Work it out
An exponential backoff uses a base of 2 seconds and a cap of 20 seconds. What is the wait before retry number 4?
Question 28 of 20Sort into groups
Classify each change to a published API.
Tap an item, then tap its group (or drag it there).
Question 29 of 20What would you do?
What would you do?
A shop receives order.paid webhooks and ships goods for each one. Occasionally an order ships twice. What should the receiver do?
Question 30 of 20Match the pairs
Match each API style to its defining feature.
Tap an answer, then tap the place where it belongs (or drag it there).
- REST
- GraphQL
- gRPC
- WebSockets
Question 31 of 20Choose one
A browser app gets a CORS error calling an API on another domain. Who can actually fix it?
Question 32 of 20True or false