Reputation: 602
In RESTful APIs, for IDs in a query URL, does it have to be a numerical ID?
Can I have something like GET '/users/10gpmGBE6b' instead of GET '/users/1'? The first random string is also a unique identifier.
Upvotes: 0
Views: 71
Reputation: 6982
Yes, it can be a String. As long as it is unique and it helps you to identify the underlying resource, it can be whatever you want.
It is often a good choice to provide both options. Let's say you got an API for persons, you could
GET /users/133/
and GET /users/jondoe
point to the same resource.
Upvotes: 2