Surprisingly Simple Tools to Help You Smash API-First Approach

API-First is an approach of defining your API specification before jumping into the development phase. With an API-first approach, instead of starting with code, you could start with design, planning, mocks, and tests.

By choosing an API-First approach, teams can crystallize their vision before development, removing the unnecessary complexity in implementation to deliver a resourceful, smart API that can no only keep R&D costs low, but has the ability to meet today’s modern IT landscape where a single operation to query several systems and components to get the job done. The specification is shared internally, as a general to-do list for the project teams to work on independently.

Hence, a well-prepared API which sets out the project’s limits and scope, lets you identify potential pain points from the outset. It also has some key benefits:

SPEED API-First encourages an engineer-first approach, with the business following and adjusting the project details to the technical capabilities and limitations. By doing so, the application life cycle is trimmed, saving cost and time.  Likewise, with no dependency on other departments, frontend and backend teams can work together, simultaneously, towards a mutual goal.  And since you already have a defined spec, it can easily be used as the basis for your customer documentation after publication. 

DIRECTION FIRST The essence of API-First is to set a project overview, including identifying the crucial functionality in the application that will need to be exposed. Clearly stating the application’s responsibilities results in greater transparency, project cost and time forecasting. Additionally, with an established tech ecosystem, you can create a path for the swift expansion of the product in the future.

USABILITY At a time when “every API is a potential public API”, the ability to plan and implement strict standards across your internal products will lead to not only a good quality API, but can also directly translate into the API’s reusability, value and visibility on the market.

Getting Started

An API-First approach is best reserved for brand-new projects where solid API design, in-depth understanding of the business goals and technical know-how will help you deliver a truly competitive API-driven software ecosystem.

However, focusing on the design first does not mean ruminating endlessly on all the what-if scenarios. A good design should have the flexibility to adapt to changing circumstances and accommodate new insights. As some teams can attest, mandating that specifications drive development can backfire.

Word of Caution: It is also important to note that an API-first approach is not suitable for

  • Smaller team (under 10 people) where the cost of planning is excessive
  • Projects that require a high degree of experimentation 
  • Pre-existing APIs where changes will affect the end-user (and force them to make changes)

Other obstacles to consider are highly-specialized or low-paced sectors who are reluctant to change, organisations with complicated bureaucracy or poor development culture. For example, the banking industry had weakly adopted API-First mostly because product iterations take on average 9-12 months. Reorienting their legacy architecture is time-consuming and not always as cost-effective as planned.

Your New Toolset

NOTE: All tools below use the OpenAPI specification – the standard specification for REST APIs. The OpenAPI Initiative involves more than 30 organizations from different areas of the tech world — including Microsoft, Google, IBM, and CapitalOne. An OpenAPI file allows you to describe your entire API, including:

  • Available endpoints and operations on each endpoint
  • Operation parameters input and output for each operation
  • Authentication methods
  • Contact information, license, terms of use and other information.

API specifications can be written in YAML or JSON. The format is easy to learn and readable to both humans and machines. Important to note hers that the document gives no notion of how the service is implemented. A well-designed specification allows the consumer to interact with the service by a minimal amount of implementation logic and study time.

Apicurio is an intuitive, open-source tool installed on-premises or web-based supporting OpenAPI 2.0 and 3.0.2 versions. The account is linked to either a GitHub, Bitbucket or GitLab source control system where your API specifications will be stored. Among that, one can find preset validation rule sets to choose from, 2 simple API templates and features for importing existing APIs and generating eye-catching documentation. 

SwaggerHub is a neat collection of handy tools that can be used both by freshmen and seasoned programmers. These include complementary Swagger Editor and Swagger UI.

Swagger Editor – a simple yet powerful editor aiming at time efficiency. Besides the option of converting between JSON and YAML representation, you can auto-create and download server and client stubs based on your application, which saves hours of monotonous coding. Both server and client can be built upon a wide range of popular front-end and back-end frameworks, eg. aspnetcore, nodejs, flask, spring, and over 20 languages: JavaScript, TypeScript, C#, Python, scala, just to name a few. Learning the tool takes minutes.

Swagger UI can be used alongside with Swagger Editor for visualization of the definitions of app paths and methods in the form of collapsible boxes. Also, you can interact with the API on the go by sending and receiving requests.

If a simple “request-in response-out” check for a single client is not enough to verify that your services works correctly, there are quite a variety of paid professional tools with more sophisticated testing and mocking options.

ReadyAPI is a well-rounded platform, integrating 3 tools to test REST and SOAP APIs. With some overlapping features, ReadyAPI is a good option for big-sized teams seeking seamless CI/CD integration with JIRA, Git, Slack, or Jenkins.

  • SoapUI is for creating a wide variety of tests: functional, security, performance, load tests with test data loaded from external sources. You can also simulate basic hacker attacks such as fuzzing, cross-site scripting and boundary scan. Despite the name, it supports more types of APIs: REST, TCP, JMS, JDBC, GraphQL. 
  • LoadUI simulates virtual users checking if your service can stand up to 5000 requests. The number of requests fired can be distributed in time to fit real-life scenarios. The simulation can be done either from a local machine, local network or cloud-based machines. 
  • ServiceV is a virtual service counterpart that imitates your real app. By doing so, ServiceV helps you to track down bottlenecks with the simulations of client activity that are as close to real-life as possible. 

Linx is a low-code development tool with extreme flexibility in producing – and hosting – rapid backend applications. If you use the most popular kids on the block – REST or SOAP – and you have your API definition ready, Linx can help you develop and host RESTful APIs, all on one platform, within minutes. 

 For REST APIs, Linx only supports the Open API 3.0 standard (and WSDL for SOAP), so conversions from older API versions would be necessary. However, that said, creating new APIs from scratch is a doddle and offers both the option to import your definition or create your own with a powerful designer. 

Conclusion

With a relatively small investment in time upfront, API-First can lay a solid path for your team to follow throughout the project lifecycle. The approach advocates naming concrete goals and planning actions before even opening up the code editor, pinning a label on the final product’s capabilities first.  By doing so – outlining the big picture — the organization can align itself with the popular agile software development principle of iterating rapidly and allowing any other stakeholders to weigh in on the proposed direction and functionality, early and often.

Topics:

api
,
api architecture
,
api design
,
api-first
,
integration
,
rest api

Opinions expressed by DZone contributors are their own.

Read More