Flask → Postman collection
Flask has no built-in schema, so most "export to Postman" guides start with installing flasgger or apispec. routeman reads app.url_map and your view code instead, and gives you a full Postman collection in one command.
$ pip install routeman && routeman generate
What routeman reads from a Flask app
- Routes: the app's
url_map, covering every blueprint,MethodViewand Flask-RESTfulResource, with converters (<int:id>,<uuid:id>) turned into typed variables. Blueprints become folders. - Bodies from the view code:
request.json[...],request.get_json().get(...),request.formandrequest.files, with types inferred from casts such asint(...). - Query parameters:
request.args.get('page', type=int)and similar. - Schemas when you have them: marshmallow schemas, flask-smorest
@blp.argumentsand Pydantic models. - Auth: flask-jwt-extended
@jwt_required, Flask-Login@login_requiredand Flask-HTTPAuth.
Example
# app/auth.py
auth_bp = Blueprint("auth", __name__, url_prefix="/api/auth")
@auth_bp.post("/login")
def login():
data = request.get_json()
user = authenticate(data["username"], data["password"])
return jsonify(access_token=create_access_token(identity=user.id))
# app/orders.py
bp = Blueprint("orders", __name__, url_prefix="/api/orders")
@bp.get("/")
@jwt_required()
def list_orders():
page = request.args.get("page", 1, type=int)
status = request.args.get("status")
...
@bp.post("/")
@jwt_required()
def create_order():
data = request.get_json()
product_id = int(data["product_id"])
quantity = int(data.get("quantity", 1))
note = data.get("note")
...
@bp.get("/<int:order_id>")
@jwt_required()
def get_order(order_id):
...
# app/__init__.py
def create_app():
app = Flask(__name__)
app.register_blueprint(auth_bp)
app.register_blueprint(bp)
return app
$ routeman generate -a "app:create_app()"
✓ flask: 5 requests (3 POST, 2 GET)
✓ auth: bearer (login: POST /api/auth/login)
✓ wrote postman/shop-api.postman_collection.json
✓ wrote postman/shop-api.local.postman_environment.json
done in 0.15s - import the files in Postman (File → Import)
This is real output (the test app also had a /api/auth/register view). In Postman:
- Auth › Login sends
{"username": "{{username}}", "password": "{{password}}"}and saves the returnedaccess_token. Register gets{"email": "user@example.com", "password": "Str0ngPassw0rd!"}. Both are No Auth. - Orders › List orders has
pageandstatusquery parameters. - Orders › Create order has a JSON body
{"product_id": 1, "quantity": 1, "note": "Sample text"}. Theint(...)casts make the first two integers, and all three were read from the view code. - Orders › Get order uses
{{order_id}}from the environment, and every@jwt_requiredroute sendsBearer {{access_token}}.
Application factories and .env
routeman finds a module-level app or a create_app() factory. If yours lives elsewhere, pass -a "package.module:create_app()". Settings from .env are loaded before the app is created, just like flask run with python-dotenv.
Full walkthrough: Flask API to Postman collection without Swagger.