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

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?

  1. Representational State Transfer
  2. Remote State Transfer
  3. Represent State Technology
  4. Remote Service Transfer

Answer: Representational State Transfer

REST stands for Representational State Transfer.

2. REST APIs commonly use which protocol?

  1. HTTP
  2. FTP
  3. SMTP
  4. SSH

Answer: HTTP

REST APIs are built on the HTTP protocol.

3. Which HTTP method is used to retrieve data?

  1. GET
  2. POST
  3. PUT
  4. DELETE

Answer: GET

GET requests retrieve resources from the server.

4. Which HTTP method is used to create a new resource?

  1. POST
  2. GET
  3. PUT
  4. DELETE

Answer: POST

POST is used to create new resources.

5. Which HTTP method updates an existing resource?

  1. PUT
  2. GET
  3. POST
  4. DELETE

Answer: PUT

PUT replaces or updates an existing resource.

6. Which HTTP method removes a resource?

  1. DELETE
  2. GET
  3. POST
  4. PUT

Answer: DELETE

DELETE removes a resource from the server.

7. Which data format is most commonly used in REST APIs?

  1. JSON
  2. HTML
  3. XML
  4. CSV

Answer: JSON

JSON is lightweight and commonly used for REST API communication.

8. What does API stand for?

  1. Application Programming Interface
  2. Application Program Internet
  3. Advanced Programming Interface
  4. Application Process Integration

Answer: Application Programming Interface

API stands for Application Programming Interface.

9. Which status code means 'OK'?

  1. 200
  2. 404
  3. 500
  4. 201

Answer: 200

HTTP status code 200 means the request was successful.

10. Which status code means 'Not Found'?

  1. 404
  2. 200
  3. 500
  4. 401

Answer: 404

404 indicates that the requested resource could not be found.

11. Which HTTP status code means 'Created'?

  1. 201
  2. 200
  3. 400
  4. 404

Answer: 201

201 Created indicates a resource has been successfully created.

12. Which HTTP status code means 'Unauthorized'?

  1. 401
  2. 403
  3. 404
  4. 500

Answer: 401

401 Unauthorized means authentication is required.

13. Which HTTP status code means 'Forbidden'?

  1. 403
  2. 401
  3. 404
  4. 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?

  1. 500
  2. 404
  3. 200
  4. 201

Answer: 500

500 indicates an unexpected server-side error.

15. Which HTTP method is used to partially update a resource?

  1. PATCH
  2. PUT
  3. POST
  4. GET

Answer: PATCH

PATCH updates only specific fields of an existing resource.

16. Which header is commonly used to send an authentication token?

  1. Authorization
  2. Content-Type
  3. Accept
  4. Host

Answer: Authorization

The Authorization header usually carries JWT or Bearer tokens.

17. Which Content-Type is commonly used for REST APIs?

  1. application/json
  2. text/html
  3. image/png
  4. text/plain

Answer: application/json

REST APIs commonly exchange data using JSON.

18. What is an endpoint in a REST API?

  1. A specific URL for accessing a resource
  2. A database table
  3. A programming language
  4. 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 ______.

  1. Stateless
  2. Stateful
  3. Offline
  4. 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?

  1. Scalable
  2. Simple to use
  3. Platform Independent
  4. All of the above

Answer: All of the above

REST APIs are scalable, easy to use, and work across different platforms.

Take the timed quiz