Skip to content

Generate an Postman Collection from your tRPC server, in one line of code

License

Notifications You must be signed in to change notification settings

zachkirsch/trpc-postman

Repository files navigation

trpc-postman


Generate an Postman spec from your tRPC server, in one line of code

Step 1: Install trpc-postman

# npm
npm install trpc-postman

# yarn
yarn install trpc-postman

# pnpm
pnpm install trpc-postman

Step 2: Generate Postman Collection

import { trpcToPostmanCollection } from "trpc-postman";

// generate Postman Collection JSON
const postmanCollection = trpcToPostmanCollection({
  collectionName: "My API",
  router: trpcRouter,
});

Publishing the Postman Collection

You can update your Postman Collection using your Postman API key and Collection ID

Step 1: Generate a Postman API key

You can generate a Postman API key here.

Step 2: Get your Colllection ID

If you don't already have a collection to publish to, create a collection manually.

Then, you can see your Collection ID by clicking the i button on the right-hand side:

collection id

Step 3: Publish collection

WARNING!! This will ERASE your entire collection with the generated Postman Collection.

import { trpcToPostmanCollection } from "trpc-postman";

// generate Postman Collection JSON
const postmanCollection = trpcToPostmanCollection({
  collectionName: "My API",
  router: trpcRouter,
});

// overwrite collection in postman
await updateRemotePostmanCollection({
  apiKey: POSTMAN_API_KEY,
  collectionId: YOUR_COLLECTION_ID,
  collection: postmanCollection,
});

About

Generate an Postman Collection from your tRPC server, in one line of code

Resources

License

Stars

Watchers

Forks

Packages

No packages published