RESTful resources: plural or singular when the resource is always the only one in the database

If I decide to go with the plural for all route names, but some of the resources exist only as one thing, do you keep it as the only (more intuitive) or do you respect this decision to use the plural and stay that way?

We were developing a new API for our client portal in PHP, and we had something like this:

/ Api / orders / or-a41931-0001 / special agreements /

And an order can have only one special agreement (and no other types of agreements, by the way, I cannot do / agreements /? Type = special or something like that).

Is it typical to make / special agreements / or / special agreement / used if the order must have exactly one?

+4
source share
1 answer

More opinion based questions, but ...

As far as I can see, there are two main types of resources: collection and instance.

The collection will be "users". You can access / users to get a list of users, or access / users / id to get a specific user. Usually the user should be an instance.

In this case, the reason for many users is that it is a collection. It makes no sense to use / user s if there is no way to go further (access to the collection instance).

, , /profile, not/profiles ( )

, , .

+3

Source: https://habr.com/ru/post/1598757/


All Articles