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
/note. To get a single note use
/notes/123where 123 is the id of the note.
- Use HTTP methods to chose what to do:
GET= Retrieve state of a resource
POST= Add a new resource
PUT= Update a resource
DELETE= 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.