Search code examples
restapinaming-conventionsidentifier

REST api naming convention technical or functional identifier


I have a user in database with two unique identifiers, one is technical (id table primary key autoincrement) and other one is functional.

Example :

User id : 40

User functional id: U12345

Which identifier should I use in my rest api naming ?

api/v1/users/40 or api/v1/users/U12345

Thanks,


Solution

  • For REST, it's best you make use of the primary key in these circumstances.

    api/v1/users/{ID} is much better and makes SQL joins seamless.