API Design

Here are five things you can do to make your API more evolvable over time:
1. Be careful with auto-incrementing IDs in distributed environments.
2. Consider generating identifiers higher up in the call stack or at the API level.
3. Use UUIDs or grids for unique identifiers.
4. Move work asynchronously by placing messages on a queue.
5. Have separate processes handle the messages and persist data into the database.

[00:04](https://www.youtube.com/watch?v=HBH6qnj0trU&t=4) Implementing unique identifiers can make your API more evolvable over time.

[01:22](https://www.youtube.com/watch?v=HBH6qnj0trU&t=82) Generating IDs asynchronously in API helps with scalability and improves performance.

[02:43](https://www.youtube.com/watch?v=HBH6qnj0trU&t=163) Generate meaningful IDs

[04:07](https://www.youtube.com/watch?v=HBH6qnj0trU&t=247) Provide information about what actions can be performed on an order

[05:28](https://www.youtube.com/watch?v=HBH6qnj0trU&t=328) The response provides actions that can be performed on an order.

[06:48](https://www.youtube.com/watch?v=HBH6qnj0trU&t=408) Dynamic URIs and their benefits

[08:10](https://www.youtube.com/watch?v=HBH6qnj0trU&t=490) Return an object with statuses and orders instead of an array.

[09:27](https://www.youtube.com/watch?v=HBH6qnj0trU&t=567) Consistency in terminology is crucial for creating an API that focuses on actual capabilities and data within the domain.

---------------------------------

Here are five things you can do to make your API more evolvable over time:
1. Be careful with auto-incrementing IDs in distributed environments.
2. Consider generating identifiers higher up in the call stack or at the API level.
3. Use UUIDs or grids for unique identifiers.
4. Move work asynchronously by placing messages on a queue.
5. Have separate processes handle the messages and persist data into the database.

[00:04](https://www.youtube.com/watch?v=HBH6qnj0trU&t=4) Implementing unique identifiers can make your API more evolvable over time.
- Using auto-incrementing IDs generated by the database can lead to issues in distributed environments.
- Having control over the generation of unique identifiers allows for easier data merging and asynchronous processing.

[01:22](https://www.youtube.com/watch?v=HBH6qnj0trU&t=82) Generating IDs asynchronously in API helps with scalability and improves performance.
- By generating and returning order IDs asynchronously, the API can handle the full execution separately from the client.
- Placing a message on the queue allows workers to handle the ID generation process asynchronously.
- This approach improves scalability and performance in distributed environments.
- Generating meaningful and understandable IDs can be beneficial for troubleshooting and analysis.

[02:43](https://www.youtube.com/watch?v=HBH6qnj0trU&t=163) Generate meaningful IDs
- Creating an order ID that has meaning is valuable.
- Meaningful IDs provide useful information at a glance.

[04:07](https://www.youtube.com/watch?v=HBH6qnj0trU&t=247) Provide information about what actions can be performed on an order
- Understanding the order data and its status
- Allowing cancellation only when the order is pending

[05:28](https://www.youtube.com/watch?v=HBH6qnj0trU&t=328) The response provides actions that can be performed on an order.
- The client UI looks for the 'cancel order' key to determine if the order can be canceled.
- By providing this information via API, the client can have less business logic and duplicated logic.

[06:48](https://www.youtube.com/watch?v=HBH6qnj0trU&t=408) Dynamic URIs and their benefits
- URIs are not constructed, but given at runtime
- URIs are opaque to the client
- Routes can change, URI structure is irrelevant
- Allow room for backward compatible changes in responses

[08:10](https://www.youtube.com/watch?v=HBH6qnj0trU&t=490) Return an object with statuses and orders instead of an array.
- Consider using an object with identifiers instead of a string for the status.
- Use language that people understand in the domain, not technical terms.

[09:27](https://www.youtube.com/watch?v=HBH6qnj0trU&t=567) Consistency in terminology is crucial for creating an API that focuses on actual capabilities and data within the domain.
- The names of entities in the domain should make sense and be explicit.
- The names of behaviors and capabilities provided by the system should be exposed in the API and appropriately named.

Did you find this article useful?