Parameterized API endpoints

When designing REST endpoints, the general rule of thumb is to provide an endpoint for each of the logical groups of data that will be queried. The name of this endpoint should be a plural, indicating that it will return an array of results. So the /api/boards endpoint will return a list of data relating to all the boards within the database. Search criteria can then be implemented on this endpoint to filter results. As an example, the /api/boards?type=1&manufacturer=2 URL should apply the type and manufacturer values as a filter in order to limit the search of all boards in the system.

When we need to work with a single instance of an item, we append the id of the item we wish to query to the plural endpoint name. ...

Get Mastering TypeScript 3 - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.