So I see that in the spec the resource name is plural for both the URL and type. But is it Ok to have the URL plural and type singular? Ex: http://example.com/articles returns resources of type article
While the following is in the spec, it doesn’t clarify if the URL and type need to match. But maybe I’m missing that language elsewhere.?.
Note: This spec is agnostic about inflection rules, so the value of type can be either plural or singular. However, the same value should be used consistently throughout an implementation.
If you only ever have one of that resource, then singular makes a lot of sense. E.i profile for the user’s profile, since he doesn’t have multiple profiles.
More to say, they might be completely different words. For example GET /vehicles endpoint might return resources of type Car, Aircraft, Train, Ship, and so on.
@a-komarev I could see a relationship returning different types like that, but I’m not sure that a “root” resource should do that. It would be difficult to document and wouldn’t you need a resource URL for each of those types.?.
@panman82 you might have endpoint for each type of resource or have endpoint which will have many subtypes. For example GET /vehicles will return CarVehicle, AircraftVehicle, TrainVehicle, ShipVehicle.
But in reality your endpoint could have non-human friendly name GET /a1b2c3 and it will be fine. There is no strict limitations for the URI names. To be honest many JSON:API libraries ties types with endpoints, but I think it’s a question of time.