What is an API Definition?
An API Definition is a document that defines the structure of the API. It includes the endpoints, request and response schemas, and authentication requirements.
Fern integrates with several API definition formats:
OpenAPI (REST & Webhook APIs)
AsyncAPI (WebSocket APIs)
AsyncAPI is a specification for defining event-driven APIs. It is used to document APIs that use WebSockets, MQTT, and other messaging protocols.
Check out an example AsyncAPI spec for a chat application below:
Fern Definition (REST, Webhook, & WebSocket APIs)
The Fern Definition is our take on a simpler API definition format. It is designed with best-practices, supports both RESTful and event-driven APIs, and is optimized for SDK generation.
Check out an example Fern Definition below:
Why create an API Definition ?
Once you have an API definition, Fern will use it as an input to generate artifacts like SDKs and API Reference documentation. Every time you update the API definition, you can regenerate these artifacts and ensure they are always up-to-date.
Client libraries in multiple languages.
A Stripe-like API documentation website.
A published Postman collection, with example request and responses.
Pydantic models for FastAPI or controllers for your Spring Boot application.