Search code examples
apiapi-design

What is the best way to describe a company structure by api route


Assume that I have following model

Company -> Department -> Position -> Staff itself

For example: Apple Inc -> Account -> Officer -> staff list

Which propose should I use in api route:

  1. /apple/account/officer

  2. /apple?department=account&pos=officer


Solution

  • Both methods work (You need & in the second one)

    The second however gives you flexibility for searching in the future (if that is something you will need)

    Say, if you wanted to find all officers in different department, the second API allows you to do that, but the first approach requires a separate endpoint.