Skip to main content

AI Agent that auto-generates Postman Collections from backend code

Project description

๐Ÿค– Postman Collection AI Agent

An AI-powered CLI tool that automatically analyzes your backend code, detects API routes, groups them into smart folders, and imports a complete Postman Collection โ€” in seconds.

PyPI version PyPI downloads Python License GitHub


๐Ÿ“– Why This Was Built

Every backend developer faces the same problem: after building an API, you have to manually create Postman Collections โ€” naming every route, adding request bodies, setting up folders, configuring auth headers. For a project with 30-50 routes, this takes hours.

This tool solves that. Point it at any backend project and it automatically:

  • Scans all files by content (not filename)
  • Detects base paths from app.use() and combines with route paths
  • Groups routes into smart folders (Authentication, Products, Orders...)
  • Generates realistic request bodies based on route context
  • Detects auth type (JWT, OAuth, API Key)
  • Enhances routes with AI (names, descriptions, bodies)
  • Imports the complete collection directly into your Postman workspace

โšก Quick Start

# 1. Install
pip install postman-agent

# 2. Setup (one time only)
postman-agent setup
# โ†’ Choose LLM provider (Groq, Gemini, Ollama, OpenAI...)
# โ†’ Enter API key for chosen provider
# โ†’ Enter Postman API Key (free at postman.com โ†’ Settings โ†’ API Keys)

# 3. Generate from any project
cd your-backend-project
postman-agent generate --scan .

# Output:
# โœ… Found 53 routes!
# ๐Ÿ“ Authentication (7 routes)
# ๐Ÿ“ Products (5 routes)
# ๐Ÿ“ Orders (4 routes)
# ๐Ÿš€ Imported to Postman!
# ๐Ÿ”— https://go.postman.co/collection/xxxxx

๐ŸŽฏ Features

Feature Details
๐Ÿ” Smart File Detection Scans files by content โ€” works with any filename
๐Ÿ“ Base Path Detection Detects app.use('/api/auth', authRoutes) automatically
๐Ÿ“ Auto Folder Grouping Authentication, Products, Orders, Payments...
๐Ÿ” Auth Type Detection JWT, OAuth, API Key auto-detected
๐Ÿ“ Smart Route Names Login, Register, Get All Products, Delete Order...
๐ŸŽฏ Path Params :id, {userId} detected and added as {{id}}
๐Ÿ” Query Params ?page=1&limit=10&q=search auto-detected
๐Ÿ“ฆ Request Bodies Realistic bodies based on route context
๐Ÿค– AI Enhancement LLM-powered names, descriptions & request bodies
๐ŸŒ Environment Variables base_url, token, refresh_token, dynamic params
๐Ÿ”„ Upsert Collections Updates existing collection โ€” no duplicates
๐Ÿš€ Auto Import Direct import to Postman workspace via API
๐Ÿ”— Instant Link Get Postman collection URL after import
๐Ÿ‘๏ธ Watch Mode Auto re-generate on file changes
๐Ÿ’พ Save to File Export collection as JSON with --output
๐Ÿงช Dry Run Preview routes without importing
โšก Fast Entire project analyzed in seconds

Every request includes:

  • โœ… Proper HTTP method
  • โœ… Full path with base URL ({{base_url}})
  • โœ… Auth header (Bearer {{token}})
  • โœ… Realistic request body
  • โœ… Path params as variables ({{id}})
  • โœ… Query params (?page=1&limit=10)
  • โœ… Environment variables

๐ŸŒ Supported Frameworks

Framework Language Detection Pattern
โœ… Express.js JavaScript router.get('/path', handler)
โœ… Fastify JavaScript fastify.get('/path', handler) / register() with prefix
โœ… NestJS TypeScript @Get('/path'), @Post('/path') decorators
โœ… FastAPI Python @app.get('/path')
โœ… Flask Python @app.route('/path', methods=['GET'])
โœ… Django Python path('endpoint/', view)

๐Ÿค– Supported LLM Providers

# Provider Free Default Model
1 Groq โœ… Free llama-3.1-8b-instant
2 Google Gemini โœ… Free gemini-2.0-flash
3 GLM / Zhipu AI โœ… Free glm-4-flash
4 Ollama (Local) โœ… Free llama3.2
5 Cerebras โœ… Free llama3.1-8b
6 SambaNova โœ… Free Meta-Llama-3.1-8B-Instruct
7 Cloudflare AI โœ… Free @cf/meta/llama-3.1-8b-instruct
8 Together AI โœ… Free Llama-3.2-3B-Instruct-Turbo
9 Fireworks AI โœ… Free llama-v3p1-8b-instruct
10 Hugging Face โœ… Free Llama-3.2-3B-Instruct
11 OpenRouter โœ… Free gemma-2-9b-it:free
12 OpenAI ๐Ÿ’ณ Paid gpt-4o-mini
13 Anthropic Claude ๐Ÿ’ณ Paid claude-3-haiku-20240307
14 Mistral ๐Ÿ’ณ Paid mistral-small-latest
15 Cohere ๐Ÿ’ณ Paid command-r-plus
postman-agent generate --scan . --provider gemini
postman-agent generate --scan . --provider ollama --model deepseek-r1
postman-agent generate --scan . --provider openai --model gpt-4o

๐Ÿ› ๏ธ CLI Commands

setup โ€” Configure provider & API keys

postman-agent setup

providers โ€” List all available providers

postman-agent providers

models โ€” List models for a provider

postman-agent models --provider groq
postman-agent models --provider gemini

generate โ€” Generate Postman Collection

# Scan entire directory
postman-agent generate --scan .

# Single file
postman-agent generate --file routes/auth.js

# Custom options
postman-agent generate --scan . \
  --provider gemini \
  --model gemini-2.0-flash \
  --base-url https://api.myapp.com \
  --token my_jwt_token \
  --name "My API Collection" \
  --output collection.json \
  --dry-run
Flag Short Description
--scan -s Directory to scan
--file -f Single route file
--provider -p LLM provider
--model -m Model name
--base-url -b Base URL (default: http://localhost:3000)
--token -t JWT token value
--name -n Override collection name
--output -o Save as JSON file
--dry-run -d Preview without importing
--ai Force AI enhancement for large projects (>100 routes)

watch โ€” Auto re-generate on file changes

postman-agent watch --scan . --interval 5

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  CLI Entry Point                     โ”‚
โ”‚              postman_agent/cli.py                    โ”‚
โ”‚                                                      โ”‚
โ”‚  โ€ข Smart file scanner (content-based)                โ”‚
โ”‚  โ€ข 15 LLM provider support                          โ”‚
โ”‚  โ€ข API key management (setup/update/delete)          โ”‚
โ”‚  โ€ข Watch mode (auto re-generate on changes)          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚               LangGraph AI Agent                     โ”‚
โ”‚            postman_agent/agent/graph.py              โ”‚
โ”‚                                                      โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”‚
โ”‚  โ”‚  agent  โ”‚โ”€โ”€โ–ถโ”‚ ai_enhance โ”‚โ”€โ”€โ–ถโ”‚ generate โ”‚โ”€โ”€โ–ถ END โ”‚
โ”‚  โ”‚  node   โ”‚   โ”‚    node    โ”‚   โ”‚   node   โ”‚        โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                Code Parser                           โ”‚
โ”‚           postman_agent/tools/code_parser.py         โ”‚
โ”‚                                                      โ”‚
โ”‚  1. detect_auth_type()    โ†’ JWT / OAuth / API Key    โ”‚
โ”‚  2. Extract base paths    โ†’ app.use('/api/auth', .)  โ”‚
โ”‚  3. Split by file         โ†’ per-file route extract   โ”‚
โ”‚  4. Combine paths         โ†’ /api/auth + /login       โ”‚
โ”‚  5. detect_folder()       โ†’ Authentication folder    โ”‚
โ”‚  6. generate_name()       โ†’ "Login", "Get Products"  โ”‚
โ”‚  7. extract_path_params() โ†’ :id โ†’ {{id}}             โ”‚
โ”‚  8. extract_query_params()โ†’ ?page=1&limit=10         โ”‚
โ”‚  9. generate_body()       โ†’ Realistic request body   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Postman Collection Builder              โ”‚
โ”‚           build_postman_collection()                 โ”‚
โ”‚                                                      โ”‚
โ”‚  โ€ข Groups routes into folders                        โ”‚
โ”‚  โ€ข Auth first (Authentication folder always first)   โ”‚
โ”‚  โ€ข Builds Postman v2.1 JSON format                   โ”‚
โ”‚  โ€ข Adds environment variables                        โ”‚
โ”‚  โ€ข Upsert by name (no duplicates)                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚               Postman API Import                     โ”‚
โ”‚           import_to_postman()                        โ”‚
โ”‚                                                      โ”‚
โ”‚  POST/PUT https://api.getpostman.com/collections     โ”‚
โ”‚  โ†’ Creates or updates collection                     โ”‚
โ”‚  โ†’ Returns collection URL                            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ Tech Stack

Layer Technology Purpose
๐Ÿง  Agent Framework LangGraph 3-node pipeline: parse โ†’ enhance โ†’ generate
๐Ÿค– LLM 15 Providers (Groq, Gemini, Ollama...) AI route enhancement
โšก Parallel Execution concurrent.futures Parallel LLM batches (3x faster)
๐Ÿ”ง Code Parser Python AST + Regex Route extraction for 6 frameworks
๐Ÿ”— Integration Postman REST API via httpx Collection create/update
๐Ÿ CLI Python + rich Beautiful animated terminal UI
๐Ÿ”‘ Config python-dotenv + pydantic Secure API key storage
๐Ÿ“ฆ Package PyPI pip install postman-agent

๐Ÿ”‘ API Keys Setup

Key Where to Get Cost
GROQ_API_KEY console.groq.com โ†’ API Keys Free
GOOGLE_API_KEY aistudio.google.com โ†’ API Keys Free
POSTMAN_API_KEY postman.com โ†’ Settings โ†’ API Keys Free
OPENAI_API_KEY platform.openai.com โ†’ API Keys Paid

Keys are stored securely at ~/.postman-agent/.env


๐Ÿ“ฆ Installation with Extra Providers

# Default (Groq only)
pip install postman-agent

# With Gemini support
pip install "postman-agent[gemini]"

# With Ollama support
pip install "postman-agent[ollama]"

# All free providers
pip install "postman-agent[all-free]"

# Everything
pip install "postman-agent[all]"

๐Ÿ—“๏ธ Changelog

v1.0.15 โ€” Performance & Bug Fixes (Latest)

  • Parallel LLM batching โ€” 25 routes per batch, max 3 batches simultaneously (3x faster)
  • LLM call timeout (60s) โ€” no more infinite hangs
  • Progress bar simulation window increased (120s) โ€” accurate for large projects
  • Duplicate route fix โ€” method:path deduplication before and after AI enhancement
  • userRoutes.js base path fix โ€” app.use() now matches any variable name, not just *Routes/*Router
  • Bare route folder fix โ€” routes like GET /{{id}} now correctly inherit folder from base path
  • Phantom route fix โ€” bmap fallback only triggers when variable is declared in that file

v1.0.13 โ€” Stability

  • Single batch LLM call for all routes
  • Removed unused file section helpers
  • Tightened bmap variable matching

v1.0.12 โ€” Multi-Provider LLM

  • 15 LLM providers: Groq, Gemini, GLM, Ollama, Cerebras, SambaNova, Cloudflare, Together, Fireworks, HuggingFace, OpenRouter, OpenAI, Anthropic, Mistral, Cohere
  • providers command to list all providers
  • models command to list models per provider
  • --provider and --model flags on generate/watch

v1.0.5 โ€” Smart Collection

  • Base path detection (app.use('/api/auth', authRoutes))
  • Full path combining (/api/auth + /login = /api/auth/login)
  • Smart folder grouping (Authentication, Products, Orders...)
  • Human-readable route names (Login, Get All Products...)
  • Path params as Postman variables ({{id}})
  • Query params auto-detection (?page=1&limit=10)
  • Realistic request body generation
  • Auth type detection (JWT, OAuth, API Key)
  • watch command for auto re-generation
  • Upsert collections (no duplicates)

v1.0.3 โ€” Multi-Framework Support

  • FastAPI, Flask, Django support added
  • Python AST parsing for accurate detection
  • Content-based file detection (not filename)
  • Fastify register() with prefix support

v1.0.1 โ€” CLI Tool

  • Python CLI package (postman-agent command)
  • Auto-import to Postman via API
  • Setup command for API key management
  • PyPI package published

v1.0.0 โ€” Foundation

  • Basic Express.js route detection with Regex
  • Simple Postman Collection generation
  • LangGraph ReAct agent

๐Ÿ”— Links

Resource Link
๐Ÿ“ฆ PyPI pypi.org/project/postman-agent
๐Ÿ’ผ GitHub Hanzzalaaa/postman-ai-agent
๐ŸŒ Portfolio https://hanzzalaaa.github.io/hanzala-portfolio/

๐Ÿค Contributing

See CONTRIBUTING.md for guidelines.


๐Ÿ‘จโ€๐Ÿ’ป Author

Hanzala Kashif โ€” Full Stack Developer & AI Agent Builder


๐Ÿ“„ License

MIT License โ€” feel free to use and modify!


โญ If this saved you time, please star the repo! "# postman-ai-agents"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

postman_ai_agent-1.0.0.tar.gz (33.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

postman_ai_agent-1.0.0-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

Details for the file postman_ai_agent-1.0.0.tar.gz.

File metadata

  • Download URL: postman_ai_agent-1.0.0.tar.gz
  • Upload date:
  • Size: 33.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for postman_ai_agent-1.0.0.tar.gz
Algorithm Hash digest
SHA256 82ca9e391d56d2ed25df7224ffc4f612c8adfc0e6e19764cbed373b19eade266
MD5 b9d65d2157b2917a5a5003744a669d77
BLAKE2b-256 ae7aaa20df16f906ca122e8663ae7dc2bf857b7472d113116a7304485dad8063

See more details on using hashes here.

Provenance

The following attestation bundles were made for postman_ai_agent-1.0.0.tar.gz:

Publisher: publish.yml on Hanzzalaaa/postman-ai-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file postman_ai_agent-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for postman_ai_agent-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 04d6e7d2b01dc79e13b4bf398ce4396cae2e90ec4e64e538cfa810b50f5f604c
MD5 93396ced245d75a959b5665d7b47864d
BLAKE2b-256 4b1d4ff0872eb5e47cc163a8d89c726c9aae05064e2797235bd4b1b79e316831

See more details on using hashes here.

Provenance

The following attestation bundles were made for postman_ai_agent-1.0.0-py3-none-any.whl:

Publisher: publish.yml on Hanzzalaaa/postman-ai-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page