Re:How to Design Better APIs
by trinovantes on Saturday March 12, 2022 @12:04AM
(#30649130)
Do you guys use plural or singular terms in your API endpoints or both?
It gets harder to keep consistent when there are a lot of nouns that have the same singular/plural form like "clothing"
[ Parent
| on HN ]
I always prefer singular just because it's easier to spell if you know the type.
It's stupid to have /geese return a Goose.
If the APIs were in Esperanto it would be different.
Re:How to Design Better APIs
by systemvoltage on Saturday March 12, 2022 @12:32AM
(#30649218)
/clothes/:clothing_id
The reason for using plural is because without the `:clothing_id`, `/clothes` endpoint would return a collection of clothing.We use the form that represents a collection of objects. For example books and clothing both refer to a collection of things so I take them as valid forms
Re:How to Design Better APIs
by imnitishng on Saturday March 12, 2022 @12:09AM
(#30649144)
Both
/books
/book/:id