This post covers best practices for building HTTP and RESTful APIs. Let’s start with the terms that we will use mostly:
- The resource is a information that can be a singleton or a collection. E.g. /companies, /company and /employees are resources. Collections are set of resources, e.g. /companies collection resource is the collection of /company resource. /Company resource is a singleton resource. A resource may contain sub-collections such as /companies/{company_id}/departments and it can be followed by a singleton resource, e.g. /companies/{company_id}/departments/{department_id}.
- Operations such as patch, put, update, delete, and post can be performed on these resources.
- URL (Uniform Resource Locator) is a path.