Web Frameworks & APIs

connexion

Write the contract first, and let the code fill itself in around it.

Install it: pip install connexion

What does it do?

Connexion flips the usual order of building an API: instead of writing code first and documenting it as an afterthought, you write a specification document describing exactly what the API should do, and Connexion wires up the actual working endpoints to match it automatically. It’s like writing the blueprint before laying a single brick, guaranteeing the finished building actually matches the plan. That specification format, called OpenAPI or Swagger, has become a widely used standard for describing APIs in a way both humans and computers can read.

See it in action

This code starts a web service whose available addresses and rules are described in a separate specification file, with this code supplying the actual responses.

import connexion

app = connexion.App(__name__)
app.add_api("openapi.yaml")

if __name__ == "__main__":
    app.run(port=8080)

Why would a non-developer care?

When multiple teams, or multiple companies, need software that talks to the same connection point correctly, having one shared, unambiguous contract prevents the kind of miscommunication that causes real integration bugs and wasted engineering time.

Real-world examples

Connexion was created and open-sourced by Zalando, the large European e-commerce company, to help keep its many internal services consistent with their documented contracts. Without a spec-first approach like this, documentation frequently drifts out of sync with what the code actually does, leaving other teams building against outdated assumptions.

Who uses it

Teams building APIs that multiple other teams or external partners need to integrate with reliably, where the written contract has to match real behavior exactly.

How it compares to alternatives

Connexion overlaps with FastAPI’s automatic documentation features but takes the opposite direction — FastAPI generates the specification from your code, while Connexion generates the code’s routing from a specification you write first.

New to Python and want to actually try libraries like this yourself?

Find a beginner-friendly course

Related libraries