Should I use UUIDs for resources in my public API?

后端 未结 2 1330
南方客
南方客 2021-01-30 12:16

I\'m building a SaaS application and want to expose IDs for resources which are not tied to my current data storage implementation (Postgres auto-increment IDs). These Stack Ove

2条回答
  •  盖世英雄少女心
    2021-01-30 13:11

    It's possible that those other vendors you listed have their own ID or hashing scheme to allow them to expose a smaller number while using something more akin to a UUID internally. But in the end, the question must be asked: as long as your URIs are intended to be consumed by code (API clients) rather than humans, why would it matter?

    Don't get too freaked out by what those vendors have done. There's no guarantee that (a) they are doing the "right" thing and (b) that their needs are the same as yours.

    Go ahead and use UUIDs.

提交回复
热议问题