Skip to main content

What is OpenAPI? An In-Depth Exploration of API Development

ยท 5 min read
Dylan Huang

What exactly is an OpenAPI? In this article, we'll cover the problem that OpenAPI solves and explore its importance in modern software architecture.

As software systems become more interconnected, OpenAPI has emerged as a vital tool for promoting collaboration and enabling seamless integration between different applications. Today large API-first companies like Stripe and Plaid use OpenAPI so it's no surprise that OpenAPI is finding widespread adoption.

Google trend on openapi from 1/1/2017 to 7/10/2023
Google trend on "openapi" from 1/1/2017 to 7/10/2023

Understanding APIsโ€‹

Imagine you're building an application and you need to incorporate services or information from an external source, such as messaging, financial data, and payment processing.

How do we integrate these components into our application? One option is to build all of this data and payments infrastructure yourself, but that could take years. Instead, let's leverage API providers like Twilio, Plaid, and Stripe to avoid building the infrastructure themselves.

Suddenly, our application has access to the necessary data infrastructure and payment processing capabilities! Developing our application now takes weeks instead of years ๐ŸŽ‰. But not so fast, now we need to integrate the APIs. Okay, let's start reading the documentation...

Oh no! The APIs you need to integrate are complex and hard to use ๐Ÿ˜ฑ.

Introducing OpenAPIโ€‹

OpenAPI standardizes APIs. It's a specification that provides a structured approach for designing, building, and documenting APIs, ensuring clarity and consistency throughout the entire lifecycle. Now that Twilio, Plaid, and Stripe offer OpenAPI Specifications, developing integrations is a breeze. We are saved ๐Ÿ˜ฎโ€๐Ÿ’จ!

OpenAPI has come a long way since its inception as Swagger. With each iteration, it has evolved and refined its features, culminating in the latest version, OpenAPI 3.1, which brings enhanced capabilities and improved support for modern API design.

History of versions for Swagger/OpenAPI

Key Features and Components of OpenAPIโ€‹

At the core of OpenAPI is a specification that defines the various components and details of an API, allowing developers to understand and interact with it effectively. For example, the title, description, contact information, version, and API URL.

stripe.yaml

_13
# Example OpenAPI from Stripe
_13
info:
_13
title: Stripe API
_13
description: >-
_13
The Stripe REST API. Please see https://stripe.com/docs/api for more
_13
details.
_13
contact:
_13
name: Stripe Dev Platform Team
_13
url: 'https://stripe.com'
_13
version: '2022-11-15'
_13
servers:
_13
- url: 'https://api.stripe.com/'

Snippet from Stripe's OpenAPI Specification

But most importantly, OpenAPI specifies available endpoints and their operations, defines input parameters and expected responses, includes practical examples for better understanding, and security requirements for authentication.

plaid.yaml

_74
paths:
_74
/asset_report/create:
_74
post:
_74
summary: Create an Asset Report
_74
operationId: assetReportCreate
_74
description: |-
_74
The `/asset_report/create` endpoint initiates the process of creating an Asset Report, which can then be retrieved by passing the `asset_report_token` return value to the `/asset_report/get` or `/asset_report/pdf/get` endpoints.
_74
The Asset Report takes some time to be created and is not available immediately after calling `/asset_report/create`. When the Asset Report is ready to be retrieved using `/asset_report/get` or `/asset_report/pdf/get`, Plaid will fire a `PRODUCT_READY` webhook. For full details of the webhook schema, see [Asset Report webhooks](https://plaid.com/docs/api/products/assets/#webhooks).
_74
The `/asset_report/create` endpoint creates an Asset Report at a moment in time. Asset Reports are immutable. To get an updated Asset Report, use the `/asset_report/refresh` endpoint.
_74
requestBody:
_74
required: true
_74
content:
_74
application/json:
_74
schema:
_74
type: object
_74
description: AssetReportCreateRequest defines the request schema for `/asset_report/create`
_74
properties:
_74
client_id:
_74
$ref: '#/components/schemas/APIClientID'
_74
secret:
_74
$ref: '#/components/schemas/APISecret'
_74
access_tokens:
_74
type: array
_74
description: An array of access tokens corresponding to the Items that will be included in the report. The `assets` product must have been initialized for the Items during link; the Assets product cannot be added after initialization.
_74
items:
_74
$ref: '#/components/schemas/AccessToken'
_74
minItems: 1
_74
maxItems: 99
_74
user_token:
_74
type: string
_74
description: The user token associated with the User for which to create an asset report for. All items associated with the User will be included in the report.
_74
x-hidden-from-docs: true
_74
days_requested:
_74
type: integer
_74
maximum: 731
_74
minimum: 0
_74
description: |-
_74
The maximum integer number of days of history to include in the Asset Report. If using Fannie Mae Day 1 Certainty, `days_requested` must be at least 61 for new originations or at least 31 for refinancings.
_74
_74
An Asset Report requested with "Additional History" (that is, with more than 61 days of transaction history) will incur an Additional History fee.
_74
options:
_74
$ref: '#/components/schemas/AssetReportCreateRequestOptions'
_74
required:
_74
- days_requested
_74
responses:
_74
"200":
_74
description: OK
_74
content:
_74
application/json:
_74
schema:
_74
type: object
_74
additionalProperties: true
_74
description: AssetReportCreateResponse defines the response schema for `/asset_report/create`
_74
properties:
_74
asset_report_token:
_74
$ref: '#/components/schemas/AssetReportToken'
_74
asset_report_id:
_74
$ref: '#/components/schemas/AssetReportId'
_74
request_id:
_74
$ref: '#/components/schemas/RequestID'
_74
required:
_74
- asset_report_token
_74
- asset_report_id
_74
- request_id
_74
examples:
_74
example-1:
_74
value:
_74
asset_report_token: assets-sandbox-6f12f5bb-22dd-4855-b918-f47ec439198a
_74
asset_report_id: 1f414183-220c-44f5-b0c8-bc0e6d4053bb
_74
request_id: Iam3b
_74
security:
_74
- clientId: []
_74
secret: []
_74
plaidVersion: []

Snippet from Plaid's OpenAPI Specification

Benefits and Use Cases of OpenAPIโ€‹

Embracing OpenAPI brings numerous benefits, including standardized and well-documented APIs, seamless integration with diverse systems, and automated code generation, reducing development efforts, and enhancing collaboration.

Checkout our code generation tool!

At Konfig, we code generate SDKs from OpenAPIs to help developer integrate APIs even faster.

OpenAPI has found its home in a wide range of use cases, including building scalable microservices architectures, enabling generated API documentation, and fueling the growth of API marketplaces that empower developers with powerful APIs.

OpenAPI Tools and Ecosystemโ€‹

With over 3.5k repositories on GitHub under the topic openapi, the OpenAPI ecosystem is bustling with handy tools and frameworks like Swagger UI, ReDoc, and Insomnia, which provide interactive documentation and API exploration, making API development and consumption a breeze.

Landscape of popular tools for OpenAPI

These tools bring OpenAPI documents to life by offering intuitive interfaces, interactive exploration features, auto-generated documentation, and auto-generated code, enabling developers to visualize and interact with APIs effortlessly.

Screenshot of Swagger UI, a visual and interactive API documentation tool
Screenshot of Swagger UI, a visual and interactive API documentation tool

OpenAPI also synergizes with JSON Schema, which allows for detailed data validation and modeling, enhancing the capabilities of OpenAPI for building robust and accurate APIs. At Konfig, we natively support request validation in our generated SDKs based to ensure that data errors are caught earlier in the development process.

Best Practices for OpenAPIโ€‹

To make the most of OpenAPI, follow best practices, such as adopting consistent naming conventions, thoroughly documenting each aspect of your API, ensuring the OpenAPI document's accuracy, leveraging reusable components, and implementing robust security measures. To automatically enforce best practices, open-source tools like Spectral allow you to define your own rules that integrates with VSCode and continuous integration.

Checkout our Linter

To ensure your OpenAPI Specification is ready for generating high-quality SDKs, we created a spectral-based linter with over 30 advanced rules.

Conclusionโ€‹

OpenAPI plays a pivotal role in today's API landscape, bringing standardization, clarity, and collaboration to API development, enabling developers to build powerful and interoperable software systems.

For more information, check out the official OpenAPI documentation and explore the rich ecosystem of tools and frameworks on GitHub.

Dylan Huang
Dylan HuangGitHubLinkedIn

Dylan is a Co-Founder at Konfig. Previously, he built SDK & API tooling at C3.ai. He also once built a viral website with over 210,000 unique users.