How to complete the challenge GET /api/todos (200) ?filter&_limit&_offset

How to issue a GET request on a top level entity endpoint and combine a todo field filter with pagination.

GET /api/todos (200) ?filter&_limit&_offset

Issue a GET request on the /api/todos end point with a query filter and pagination parameters, requesting the response in JSON format.

  • doneStatus=false filters the collection to only not done todos
  • _limit=2 asks for 2 returned todos
  • _offset=1 skips 1 todo after filtering
  • filtering is applied before pagination
  • if your current session has fewer matching todos after the offset, the response will contain fewer todos
  • if necessary add header Accept: application/json so the filtered and sorted todo collection is visible as JSON

Basic Instructions

  • Issue a GET request to end point "/api/todos"
    • https://apichallenges.com/api/todos
  • The request should have an X-CHALLENGER header to track challenge completion
  • The request should have an Accept: application/json header so the API returns todos in JSON format
  • Add doneStatus=false, _limit=2, and _offset=1 as URL parameters:
    • https://apichallenges.com/api/todos?doneStatus=false&_limit=2&_offset=1
  • The response status code should be 200 because the request is accepted
  • Check that the response body contains no more than 2 todos and all returned todos have doneStatus set to false

Try it now

GET /api/todos?doneStatus=false&_limit=2&_offset=1 to filter and paginate todos

Example Request

> GET /api/todos?doneStatus=false&_limit=2&_offset=1 HTTP/1.1
> Host: apichallenges.com
> User-Agent: rest-client
> X-CHALLENGER: x-challenger-guid
> Accept: application/json

Example Response

< HTTP/1.1 200 OK
< Connection: close
< Content-Type: application/json
< X-Challenger: x-challenger-guid

Returned body:

{
  "todos": [
    { "id": 2, "title": "not done todo", "doneStatus": false, "description": "" },
    { "id": 3, "title": "another not done todo", "doneStatus": false, "description": "" }
  ]
}

Lessons Learned

  • Filtering before pagination changes which records are eligible for a page.
  • Small _limit values make it easier to spot whether pagination happens after filtering.
  • Page assertions should track both result count and field criteria.

Suggested Experiments

  • Use doneStatus=true&_limit=1&_offset=0, then increase _offset and ensure every page still contains only done todos.
  • Compare a filtered page with the same _limit and _offset without the filter to see how the dataset changes.
Experiment with this endpoint