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.
๐ 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:pathdeduplication before and after AI enhancement userRoutes.jsbase 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
providerscommand to list all providersmodelscommand to list models per provider--providerand--modelflags 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)
watchcommand 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-agentcommand) - 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
- ๐ง hanzalakashif2003@gmail.com
- ๐ผ @Hanzzalaaa
๐ License
MIT License โ feel free to use and modify!
โญ If this saved you time, please star the repo! "# postman-ai-agents"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82ca9e391d56d2ed25df7224ffc4f612c8adfc0e6e19764cbed373b19eade266
|
|
| MD5 |
b9d65d2157b2917a5a5003744a669d77
|
|
| BLAKE2b-256 |
ae7aaa20df16f906ca122e8663ae7dc2bf857b7472d113116a7304485dad8063
|
Provenance
The following attestation bundles were made for postman_ai_agent-1.0.0.tar.gz:
Publisher:
publish.yml on Hanzzalaaa/postman-ai-agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
postman_ai_agent-1.0.0.tar.gz -
Subject digest:
82ca9e391d56d2ed25df7224ffc4f612c8adfc0e6e19764cbed373b19eade266 - Sigstore transparency entry: 2194577516
- Sigstore integration time:
-
Permalink:
Hanzzalaaa/postman-ai-agent@229ea9f4194c9b10747f4b383a140af33fa10bb9 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/Hanzzalaaa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@229ea9f4194c9b10747f4b383a140af33fa10bb9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file postman_ai_agent-1.0.0-py3-none-any.whl.
File metadata
- Download URL: postman_ai_agent-1.0.0-py3-none-any.whl
- Upload date:
- Size: 30.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04d6e7d2b01dc79e13b4bf398ce4396cae2e90ec4e64e538cfa810b50f5f604c
|
|
| MD5 |
93396ced245d75a959b5665d7b47864d
|
|
| BLAKE2b-256 |
4b1d4ff0872eb5e47cc163a8d89c726c9aae05064e2797235bd4b1b79e316831
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
postman_ai_agent-1.0.0-py3-none-any.whl -
Subject digest:
04d6e7d2b01dc79e13b4bf398ce4396cae2e90ec4e64e538cfa810b50f5f604c - Sigstore transparency entry: 2194577550
- Sigstore integration time:
-
Permalink:
Hanzzalaaa/postman-ai-agent@229ea9f4194c9b10747f4b383a140af33fa10bb9 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/Hanzzalaaa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@229ea9f4194c9b10747f4b383a140af33fa10bb9 -
Trigger Event:
release
-
Statement type: