← All topics

REST API

Endpoints, HTTP methods, URL parameters, JSON, and response statuses.

Question 1 of 17Correct: 0Incorrect: 0

Questions and explanations

Find an explanation for each question here. To test yourself, take the quiz above first.

  1. What is an API?

    An API defines the rules by which one application can request data or an action from another application.

  2. What is an endpoint in a REST API?

    A client can request a user list at /api/v1/users, while /api/v1/users/42 points to one user. The path tells the API which resource to work with.

  3. Which HTTP method is usually used to retrieve data?

    GET /api/v1/orders/42 reads order 42. Fetching that order again should not change it; other methods are used to modify resources.

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

    POST usually sends the server data for a new resource, such as a new user or order.

  5. Which HTTP method is usually used to delete a resource?

    DELETE /api/v1/orders/42 asks the server to remove order 42. The path identifies one resource, so the request should not remove the entire order collection.

  6. What is the difference between PUT and PATCH?

    PUT is used for a full resource replacement, while PATCH is for a partial update, such as changing only an order status.

  7. What is a path parameter?

    In the route /api/v1/users/:id, the value 42 in /api/v1/users/42 replaces :id. This tells the server which user's data was requested.

  8. What is a query parameter?

    Query parameters are often used for filtering, sorting, or pagination, for example ?status=paid.

  9. Where is data usually sent when creating a resource?

    In a POST request, data for a new resource is usually in the request body.

  10. In which format does a REST API often send data?

    JSON is a common text format for exchanging structured data between a client and server.

  11. What does the HTTP status 200 usually mean?

    A successful GET /api/v1/users/42 usually returns 200 OK with the user's data. It signals success, but not that a new resource was created; creation commonly uses 201 Created.

  12. What does the HTTP status 201 usually mean?

    201 Created is commonly returned after a resource, such as a new user or order, has been created successfully.

  13. How do status codes 400, 401, 403, and 404 differ?

    These are client-side errors: the request may be invalid, the user may not be signed in, may lack permission, or may be requesting a nonexistent address.

  14. What does the HTTP status 500 mean?

    500 Internal Server Error means the server could not process the request correctly because of an internal problem.

  15. Where is the path parameter in the request GET /api/v1/users/42?

    42 is in the URL path and identifies a specific user, so it is a path parameter.

  16. Where is the query parameter in the request GET /api/v1/users?status=active

    status=active comes after the ? character and sets an additional request condition, so it is a query parameter.

  17. Which URL contains a query parameter?

    Query parameters start after the ? character. In this example, status=paid sends a filter for the order list.