**The Challenges of Building External APIs**
Building external APIs is often touted as a way to make data more accessible and usable by developers outside of an organization's walls. However, in practice, it can be a complex and time-consuming process that requires careful consideration of many factors.
One of the biggest challenges when building external APIs is dealing with existing problems within an organization's systems. For example, if an internal API exposes sensitive data that should not be accessible to outsiders, developers may need to limit what is exposed or add additional security measures to protect it. This can require significant work and modifications to existing codebases.
Another challenge is ensuring consistency in naming conventions throughout the system. In our experience, this can be a major issue when building an external API for a business flow that is not well-prepared for B2B interactions. For instance, we recently had to add support for issuing invoices, which required modifying multiple parts of the system.
When it comes to designing an external API, there are many factors to consider. One key principle is to keep the API simple and easy to use for developers who will be using it. However, this can sometimes mean making compromises on how data is represented or accessed.
In our experience, one of the most common mistakes when building an external API is to underestimate the amount of work required. This can lead to delays and frustration for all parties involved. On the other hand, with careful planning and execution, an external API can be a powerful tool for making data more accessible and usable by developers outside of an organization's walls.
**The Importance of Consensus on Naming Conventions**
One of the key challenges when building an external API is achieving consensus on naming conventions throughout the system. In our experience, this can be a major issue when building APIs for different parts of a business flow that do not communicate well with each other.
For example, when we built an API for travel, we encountered significant issues with inconsistent naming conventions between different microservices. The solution was to unify these names and ensure they made sense from a business perspective. This required careful consideration and communication among developers and stakeholders.
In general, achieving consensus on naming conventions is crucial when building external APIs. Without it, developers may struggle to understand how the API works or what data is being returned, leading to frustration and delays.
**The Role of HTTP Semantics in Building External APIs**
When building external APIs, it's essential to take advantage of HTTP semantics, such as methods, headers, and status codes. These are the same principles that govern web development and ensure that APIs are consistent and easy to use.
However, this doesn't mean following these principles blindly. In some cases, deviating from the norm may be necessary to achieve the desired outcome. For example, if you need to return a large list of resources in the response body, it may make more sense to do so rather than trying to fit it all into the URL.
In our experience, one common mistake when building external APIs is not considering the impact of HTTP semantics on API design. This can lead to APIs that are difficult to use or understand, leading to frustration for developers who rely on them.
**The Limitations of REST and Alternatives**
When building external APIs, REST (Representational State of Resource) is often the go-to choice. However, it's not the only option, and GraphQL is becoming increasingly popular as an alternative.
GraphQL offers a more flexible and powerful way to query data than traditional REST APIs. With GraphQL, developers can specify exactly what data they need, reducing the amount of unnecessary data that needs to be returned in the response.
However, GraphQL also has its own set of challenges and complexities, particularly when it comes to performance and scalability. In our experience, GraphQL can be a great choice for building external APIs, but careful planning and consideration are required to ensure its success.
**Conclusion**
Building an external API is a complex process that requires careful consideration of many factors. From dealing with existing problems in the system to ensuring consistency in naming conventions, there are many challenges to overcome. However, with careful planning and execution, an external API can be a powerful tool for making data more accessible and usable by developers outside of an organization's walls.
As we continue to evolve and improve our understanding of what makes a great API, it's essential to stay informed about the latest developments in the field. Whether you're building an external API or simply looking to learn more about how they work, there's always something new to discover.