REST API Quiz
REST is the most common style for web APIs. Questions cover HTTP methods, status codes, endpoints, JSON, statelessness and how clients and servers exchange data.
What this quiz covers
- GET, POST, PUT and DELETE
- Status codes
- Endpoints and resources
- JSON and statelessness
Study tip: Call a public API from the browser or a tool such as curl and read the status codes it returns.
Questions, answers and explanations
1. What does REST stand for?
- Representational State Transfer
- Remote State Transfer
- Represent State Technology
- Remote Service Transfer
Answer: Representational State Transfer
REST stands for Representational State Transfer.
2. REST APIs commonly use which protocol?
- HTTP
- FTP
- SMTP
- SSH
Answer: HTTP
REST APIs are built on the HTTP protocol.
3. Which HTTP method is used to retrieve data?
- GET
- POST
- PUT
- DELETE
Answer: GET
GET requests retrieve resources from the server.
4. Which HTTP method is used to create a new resource?
- POST
- GET
- PUT
- DELETE
Answer: POST
POST is used to create new resources.
5. Which HTTP method updates an existing resource?
- PUT
- GET
- POST
- DELETE
Answer: PUT
PUT replaces or updates an existing resource.
6. Which HTTP method removes a resource?
- DELETE
- GET
- POST
- PUT
Answer: DELETE
DELETE removes a resource from the server.
7. Which data format is most commonly used in REST APIs?
- JSON
- HTML
- XML
- CSV
Answer: JSON
JSON is lightweight and commonly used for REST API communication.
8. What does API stand for?
- Application Programming Interface
- Application Program Internet
- Advanced Programming Interface
- Application Process Integration
Answer: Application Programming Interface
API stands for Application Programming Interface.
9. Which status code means 'OK'?
- 200
- 404
- 500
- 201
Answer: 200
HTTP status code 200 means the request was successful.
10. Which status code means 'Not Found'?
- 404
- 200
- 500
- 401
Answer: 404
404 indicates that the requested resource could not be found.
11. Which HTTP status code means 'Created'?
- 201
- 200
- 400
- 404
Answer: 201
201 Created indicates a resource has been successfully created.
12. Which HTTP status code means 'Unauthorized'?
- 401
- 403
- 404
- 500
Answer: 401
401 Unauthorized means authentication is required.
13. Which HTTP status code means 'Forbidden'?
- 403
- 401
- 404
- 200
Answer: 403
403 Forbidden means the server understood the request but refuses to authorize it.
14. Which HTTP status code indicates an Internal Server Error?
- 500
- 404
- 200
- 201
Answer: 500
500 indicates an unexpected server-side error.
15. Which HTTP method is used to partially update a resource?
- PATCH
- PUT
- POST
- GET
Answer: PATCH
PATCH updates only specific fields of an existing resource.
16. Which header is commonly used to send an authentication token?
- Authorization
- Content-Type
- Accept
- Host
Answer: Authorization
The Authorization header usually carries JWT or Bearer tokens.
17. Which Content-Type is commonly used for REST APIs?
- application/json
- text/html
- image/png
- text/plain
Answer: application/json
REST APIs commonly exchange data using JSON.
18. What is an endpoint in a REST API?
- A specific URL for accessing a resource
- A database table
- A programming language
- A web browser
Answer: A specific URL for accessing a resource
An endpoint is the URL where an API resource can be accessed.
19. REST APIs are generally ______.
- Stateless
- Stateful
- Offline
- Compiled
Answer: Stateless
REST is stateless, meaning each request contains all the information needed.
20. Which of the following is a major advantage of REST APIs?
- Scalable
- Simple to use
- Platform Independent
- All of the above
Answer: All of the above
REST APIs are scalable, easy to use, and work across different platforms.