What is an API definition?
An API definition is a machine-readable specification of your API’s structure, including endpoints, request and response schemas, and authentication requirements. Instead of manually keeping SDKs and documentation in sync with API changes, an API definition enables automatic generation of these artifacts.
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:
OpenRPC (JSON-RPC APIs)
OpenRPC is a spec for describing JSON-RPC 2.0 APIs. It enables interactive docs and code generation tooling to the JSON-RPC ecosystem.
Check out an example OpenRPC Specification for a crypto wallet service below:
gRPC (RPC APIs)
gRPC is a modern, open-source RPC framework developed by Google. It uses Protocol Buffers as its interface definition language and supports multiple programming languages with efficient binary serialization.
gRPC APIs are defined using Protocol Buffer (.proto) files that specify services and message types. Check out an example gRPC service definition 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 uses 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 to ensure they are always up-to-date.
Client libraries in multiple languages that automatically stay in sync with your API.
Interactive API docs with code examples and live testing capabilities.
Ready-to-use collection with pre-filled example requests and responses.
Pydantic models for FastAPI or controllers for your Spring Boot application.