I'm building a Json REST API for my application, and have some doubts about the design itself. My application has organizations and also equipment which belongs to organizations. That would be an example of the organizations API:
/organizations:
Loads all the organizations from the application
/organizations/{id}:
Loads a specific organization by id
This seems quite clear. However now I want to access equipment, which is accessible by id or code. The id is unique for the application, whereas the code is unique per organization. Some choices:
/organizations/{id}/equipment:
Loads the equipment by organization. This seems quite clear to me
/organizations/{idOrg}/equipment/{idEquip}:
Equipment by id. Isn't the organization id quite redundant here?
/organizations/{idOrg}/equipment/code/{code}:
Seems it makes sense, but probably would be better to pass code as a parameter.
/organizations/{idOrg}/equipment?id={idEquip}:
Best choice?
/organizations/{idOrg}/equipment?code={code}:
Best choice?
In my opinion, the methods below look better just for grabbing equipment (even if the return a list, while the method is supposed to return a single value or nothing). However I still have more relations into equipment, which these methods don't seem proper to fit. For example how to extend the API to integrate the methods to load files for each equipment?
UPDATE
It should be considered that organizations are structured hierarchically, so we've got organization trees and if org1 contains org2 and one equipment belongs to org2, it also belongs to org1.
/equipments/{idEquip}
"