AnnouncementPostmanPython

Introducing routeman: Postman collections without OpenAPI

Why we built routeman, a free CLI that reads Django, DRF, Flask and FastAPI code directly and writes a ready-to-use Postman collection, and how it works under the hood.

Today we're releasing routeman 0.1.0 on PyPI. It's a free, MIT-licensed command-line tool that generates a complete Postman collection from a Django, Django REST framework, Flask or FastAPI project with one command:

$ pip install routeman
$ routeman generate

No OpenAPI schema, no documentation library and no annotations.

The problem

Every API team keeps a Postman collection, and almost every one is out of date. The usual fix is to generate an OpenAPI schema and import it. That works when the project was designed around a schema. Most real Python codebases weren't:

  • Django projects with plain views and forms have nothing for schema generators to read.
  • DRF projects need drf-spectacular or drf-yasg configured, plus annotations wherever a view does something the generator can't follow.
  • Flask has no schema at all unless you adopt flasgger, apispec or flask-smorest.
  • FastAPI has a schema, but importing it still leaves login, tokens, environments and tests to you.

Even a perfect import gives you a list of URLs. To actually use it, someone still has to log in and copy a token, fix example bodies that fail validation, and create environments.

What routeman does differently

routeman treats your code as the source of truth. It:

  1. Loads your app the way your server does and asks the framework which routes it serves: the resolved Django URLconf, Flask's url_map, FastAPI's route table. This is read-only, with no database access and no requests.
  2. Reads what each view declares: DRF serializers, Django forms, marshmallow and Pydantic models, pagination and filter backends, permission and authentication classes.
  3. Reads what each view does when nothing is declared, such as request.data.get('email'), int(data['age']) or request.args.get('page', type=int), and marks those requests as inferred.
  4. Writes a collection for the people who'll use it: example values that pass validation, auth configured once, a login script that saves tokens, environments per server and a smoke test on every request.

A real run

Here it is on a small FastAPI app:

$ routeman routes -a main:app
POST    /auth/token
GET     /products
POST    /products               ๐Ÿ”’ json: name, price, sku
GET     /products/{product_id}  ๐Ÿ”’
4 routes, auth: bearer

$ routeman generate -a main:app
โœ“ fastapi: 4 requests (2 POST, 2 GET)
โœ“ auth: bearer (login: POST /auth/token)
โœ“ wrote postman/demo-api.postman_collection.json
โœ“ wrote postman/demo-api.local.postman_environment.json
  done in 0.31s - import the files in Postman (File โ†’ Import)

The price: float = Field(gt=0) field gets the example 1.5, not 0, so the very first "Send" passes validation.

Design choices

  • Zero dependencies. routeman installs into your project's virtualenv, so it mustn't fight your packages. It needs only the standard library, plus tomli on Python < 3.11.
  • Stable ids. Collection and request ids are derived from the project and route, so re-importing replaces the previous version in Postman.
  • Standard output. Postman Collection v2.1 JSON works in Postman, Newman and other clients that import it.
  • Local only. No account, no telemetry, no network calls.

Supported today

FrameworkVersions
Django3.2 โ€“ 6
Django REST framework3.12+
Flask2.0 โ€“ 3.x (blueprints, MethodView, Flask-RESTful, flask-smorest)
FastAPI0.95+ (Pydantic v1 and v2)

Try it and tell us what breaks

Real projects are full of edge cases, and we want to hear about yours. If routeman misses a route, gets a body wrong or can't load your project, email routeman@swastik.ai with the output of routeman routes, or call +91 76545 31678.

routeman is built by Divakar at Swastik Tech Solutions Pvt Ltd. Start with the docs or a framework guide: DRF, Django, FastAPI, Flask.

Try routeman on your project

$ pip install routeman
$ routeman generate

Read the docs โ†’ Ask a question