REST APIs
Published on
This note contains general information and styles I like to follow when designing REST (Web) APIs.
- Use the plural for resource routes. For example the path to retrieve the resource note should be
/notes
and not/note
. To get a single note use/notes/123
where 123 is the id of the note. - Use HTTP methods to chose what to do:
GET
= Retrieve state of a resourcePOST
= Add a new resourcePUT
= Update a resourceDELETE
= Delete a resource
- Pass values that may contain file paths as query parameters and not as part of the URL segment. I learned this the hard way…multiple times.
- Describe and document your endpoints.