IDL
Interface Definition Language: a schema that defines the contract between client and server. Protobuf, Thrift, and OpenAPI are IDLs that generate client/server code.
What is IDL?
In short
An Interface Definition Language (IDL) is a language-neutral schema that describes the exact shape of an API: its methods, the fields in each request and response, and their types. You write the contract once in the IDL, then a code generator produces matching client and server code in Go, Java, Python, or any supported language so both sides agree on the wire format without sharing source code.
What an IDL Actually Is
An IDL is a small, declarative file that says nothing about how your code runs and everything about how two programs talk to each other. It lists the service methods, the messages those methods send and receive, and the type of every field. Protocol Buffers (.proto), Apache Thrift (.thrift), and OpenAPI (formerly Swagger, written in YAML or JSON) are the IDLs you will see most often.
The point is that the contract lives in one place and is the single source of truth. A team in Go and a team in Python do not exchange handwritten parsing code or English docs that drift out of date. They both compile the same IDL file and get types and stubs that are guaranteed to line up.
Here is a tiny Protobuf example. It defines a service with one method and the two messages it uses:
service UserService { rpc GetUser (GetUserRequest) returns (User); } message GetUserRequest { int64 id = 1; } message User { int64 id = 1; string name = 2; string email = 3; }
How Code Generation Works
You run a compiler against the IDL file. For Protobuf that is protoc plus a language plugin; for Thrift it is the thrift binary; for OpenAPI it is a tool like openapi-generator. The compiler reads the schema and emits source files.
On the client side you get typed stub functions: calling getUser(id) serializes your request into the wire format, sends it, and deserializes the response back into a typed object. On the server side you get an interface or abstract base class with the same method signatures, and you fill in the business logic. Neither side hand-writes serialization or parsing.
The field numbers you see in Protobuf (id = 1, name = 2) are what travels on the wire, not the field names. That is why you can rename a field freely, and why you must never reuse or change an existing field number. Adding a new field with a new number is backward compatible: old clients ignore numbers they do not recognize, and new fields default to zero or empty.
When to Use One and the Trade-offs
Reach for an IDL when you have services in more than one language, or when many teams call the same API and you need a contract that cannot silently drift. Binary IDLs like Protobuf and Thrift also give you compact payloads and fast parsing, which matters for high-traffic internal RPC. gRPC is built directly on Protobuf for exactly this reason.
The cost is a build step and some ceremony. You add a code-generation stage to your pipeline, and the generated binary formats are not human readable, so you debug with tooling like grpcurl instead of curl plus your eyes. For a small public REST API consumed by browsers, plain JSON with no codegen is often simpler.
OpenAPI sits in the middle. It describes JSON-over-HTTP APIs, so the payloads stay human readable, and it can still generate clients, server stubs, and interactive docs. You trade the compactness of binary formats for the universal reach of HTTP and JSON. Pick the binary IDLs for internal performance-sensitive RPC, and OpenAPI when the API is REST and the consumers are diverse.
A Concrete Example
Imagine a checkout service written in Go that needs to call a fraud-scoring service written in Python. Without an IDL, the Go team writes JSON-marshalling code by hand, the Python team writes parsing code by hand, and a renamed field or a string-versus-int mismatch is found only at runtime in production.
With a Protobuf IDL, both teams compile the same fraud.proto. The Go side gets a typed client, the Python side gets a typed servicer base class. If someone changes the schema in an incompatible way, the build fails before anything ships. The two services have never seen each other's source code, yet they agree precisely on every byte they exchange.
Where it is used in production
Created Protocol Buffers and uses .proto IDLs across nearly all internal services; gRPC generates the client and server stubs.
Meta
Built Apache Thrift to define and generate cross-language service interfaces for its many backend systems.
Stripe
Publishes a detailed OpenAPI specification of its REST API, which drives its docs and the generated SDKs in multiple languages.
Uber
Uses Protobuf and Thrift IDLs heavily for service-to-service RPC across thousands of microservices.
Frequently asked questions
- Is an IDL the same as an API schema?
- Close. An IDL is a language used to write a schema, and the file you write in it is the schema. People often use the terms loosely, but the IDL is the grammar and the schema is the document. A .proto file is a Protobuf schema written in the Protobuf IDL.
- What is the difference between Protobuf, Thrift, and OpenAPI?
- Protobuf and Thrift are binary IDLs aimed at fast, compact RPC between services, with Protobuf powering gRPC. OpenAPI describes JSON-over-HTTP REST APIs, so its payloads stay human readable. Use binary IDLs for internal performance-sensitive RPC and OpenAPI for REST APIs with many or external consumers.
- Do I have to regenerate code every time the IDL changes?
- Yes. The generated client and server code is derived from the IDL, so after editing the schema you rerun the compiler to refresh the stubs. Most teams wire this into the build or CI so the generated files never fall behind the contract.
- Why do Protobuf fields have numbers like id equals 1?
- The number, not the field name, is what gets written on the wire. This lets you rename fields freely and add new ones for backward compatibility. The rule is never to change or reuse an existing field number, because old data and old clients identify fields by that number.
- Can I use an IDL without gRPC?
- Yes. Protobuf can serialize messages for any transport, including HTTP, message queues, or files on disk. Thrift ships its own RPC layer but the IDL and serialization are usable on their own, and OpenAPI is plain HTTP with no RPC framework at all.
Learn IDL hands-on
This page explains the idea. The full lesson lets you step through the ring as servers join and leave, read the implementation, and check yourself with a quiz. It is one of 760+ lessons in the System Design Masterclass, from your first API call to distributed consensus. Eleven Foundation lessons are free, no signup. Lifetime access is ₹499 in India or $7.99 worldwide, one payment, no subscription.
Related lessons
Lessons that touch on IDL as part of a larger topic.
See also
Related glossary terms you might want to look up next.
Protocol Buffers
Google's language-neutral, binary serialization format. Smaller and faster than JSON. Defines schemas in .proto files that generate typed code for any language.
gRPC
A high-performance RPC framework by Google using Protocol Buffers and HTTP/2. Much faster than REST for service-to-service communication.
REST API
An architectural style for building APIs using standard HTTP methods (GET, POST, PUT, DELETE). Resources are identified by URLs.
WebSocket
A protocol for full-duplex communication over a single TCP connection. Unlike HTTP, the server can push data to the client without being asked.
SSE
Server-Sent Events: a one-way channel where the server pushes updates to the client over HTTP. Simpler than WebSockets when you only need server-to-client streaming.
Rate Limiting
Controlling how many requests a client can make in a given time window. Protects your API from abuse and ensures fair usage.