Skip to content

HTTP

HTTP Methods

  • GET
Terminal window
curl http://localhost:3000/movies
Terminal window
curl -X GET http://localhost:3000/movies/2
  • POST
Terminal window
curl -X POST -H "Content-Type: application/json" -d '{
"title": "Interstellar",
"year": 2014,
"directorId": 101,
"genre": ["Sci-Fi", "Adventure"],
"cast": ["Matthew McConaughey", "Anne Hathaway"]
}' http://localhost:3000/movies
  • PUT
Terminal window
curl -X PUT -H "Content-Type: application/json" -d '{
"title": "Interstellar (Updated)",
"year": 2015,
"directorId": 101,
"genre": ["Sci-Fi", "Adventure", "Drama"],
"cast": ["Matthew McConaughey", "Anne Hathaway", "Jessica Chastain"]
}' http://localhost:3000/movies/4
  • DELETE
Terminal window
curl -X DELETE http://localhost:3000/movies/4

Query

Pagination

Terminal window
curl "http://localhost:3000/movies?\_page=1"
Terminal window
curl "http://localhost:3000/movies?\_page=1&_limit=20"

Filtering

Terminal window
curl "http://localhost:3000/movies?director=Christopher%20Nolan"

Sort

Terminal window
curl "http://localhost:3000/movies?_sort=year&_order=desc"

Operators

Add _gte or _lte for getting a range

Terminal window
curl "http://localhost:3000/movies?year_gte=1980&year_lte=1990"

Add _ne to exclude a value

Terminal window
curl "http://localhost:3000/movies?director_ne=Christopher%20Nolan"