0.1.0 β€’ Published 1 month ago

@sirhc77/postman-sdk-gen v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 month ago

Postman TypeScript SDK Generator

Generate a fully-typed TypeScript SDK from a Postman collection, with support for Axios or Fetch, folder-based namespacing, and auto-inferred types.

✨ Features

  • πŸ”Œ Input: Supports Postman Collection v2.1
  • πŸ“¦ Output: TypeScript SDK with methods, namespaces, and inferred request/response types
  • ⚑ Transport: Axios (default) or Fetch
  • πŸ”’ Authentication: Auto-parses Postman auth schemes (Bearer, API Key, Basic Auth)
  • 🧠 Type Inference: Generates interfaces for bodies and responses
  • πŸ—‚οΈ Folder-Based Namespacing: Postman folders become nested namespaces
  • 🧾 .d.ts Generation: Optional separate type declarations for consumption in JS projects

πŸš€ Getting Started

1. Install

npm install -g @sirhc77/postman-sdk-gen

2. Generate SDK

postman-sdk-gen ./collection.json \
  --output ./sdk \
  --client-name ApiClient \
  --use-fetch \

CLI Options

FlagDescription
--outputOutput directory (default: ./sdk)
--client-nameName of generated class (default: ApiClient)
--use-fetchUse native fetch instead of Axios
--single-fileGenerate one file instead of multi-file
--quietSupress logs
--versionShow version

πŸ§ͺ Sample Usage

import { ApiClient } from './sdk/ApiClient';

const client = new ApiClient('https://api.example.com', '<your username>', '<your password>');

const res = await client.users.getCurrentUser();

πŸ“ Namespacing

A Postman folder structure like:

- Space Management
  - Phone Numbers
    - List All

…generates:

client.spaceManagement.phoneNumbers.listAll();

πŸ”’ Authentication

Postman auth sections are auto-detected. Supported:

  • Bearer token`
  • API key
  • Basic Auth

πŸ› οΈ Contributing

  • Clone the repo
  • Run locally with ts-node or build with tsc
  • Use examples/*.postman_collection.json to test

πŸ“„ License

MIT License