npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

postman-collection-manager

v0.2.0

Published

Postman Collection Manager is a powerful TypeScript library that simplifies the process of working with Postman collections and OpenAPI files. This library streamlines common tasks such as generating Postman collection files, importing data into Postman,

Downloads

4

Readme

Postman Collection Manager

Postman Collection Manager is a powerful TypeScript library that simplifies the process of working with Postman collections and OpenAPI files. This library streamlines common tasks such as generating Postman collection files, importing data into Postman, updating collections, retrieving collections, and deleting collections. Additionally, it includes a utility for converting OpenAPI files to Postman collections using the openapi2postmanv2 command line tool.

Installation

To use Postman Collection Manager in your project, install it via npm:

npm install postman-collection-manager

Overview

Postman Collection Manager provides the following key features:

  1. Generate JSON File: generateFileJson function creates a JSON file from the provided object and saves it in the "docs" folder.

  2. Import JSON to Postman: importJsonToPostman function allows you to import JSON data into Postman using the Postman API.

  3. Update Collection: updateCollection function updates an existing Postman collection with new data.

  4. Get Collection: getCollection function retrieves a Postman collection based on its ID.

  5. Delete Collection: deleteCollection function deletes a Postman collection.

  6. OpenAPI to Postman Collection: openapiToPostmanCollection function converts an OpenAPI file to a Postman collection using the openapi2postmanv2 command line tool.

Usage

1. Generate JSON File

import { generateFileJson } from 'postman-collection-manager';

const dataObject = { /* Your data object here */ };

generateFileJson(dataObject)
  .then(result => console.log(result.message))
  .catch(error => console.error(error.message, error.err));

2. Import JSON to Postman

import { importJsonToPostman } from 'postman-collection-manager';

const jsonData = { /* Your JSON data here */ };
const apiKey = 'your_postman_api_key';

importJsonToPostman(jsonData, apiKey)
  .then(result => console.log('Collection imported successfully:', result))
  .catch(error => console.error(error.message, error.error));

Note: Obtain your Postman API key for authentication.

3. Update Collection

import { updateCollection } from 'postman-collection-manager';

const collectionId = 'your_collection_id';
const updatedData = { /* Your updated data here */ };
const apiKey = 'your_postman_api_key';

updateCollection(collectionId, updatedData, apiKey)
  .then(result => console.log('Collection updated successfully:', result))
  .catch(error => console.error(error.message, error.error));

4. Get Collection

import { getCollection } from 'postman-collection-manager';

const collectionId = 'your_collection_id';
const apiKey = 'your_postman_api_key';

getCollection(collectionId, apiKey)
  .then(result => console.log('Collection retrieved successfully:', result))
  .catch(error => console.error(error.message, error.error));

5. Delete Collection

import { deleteCollection } from 'postman-collection-manager';

const collectionId = 'your_collection_id';
const apiKey = 'your_postman_api_key';

deleteCollection(collectionId, apiKey)
  .then(result => console.log('Collection deleted successfully:', result))
  .catch(error => console.error(error.message, error.error));

6. OpenAPI to Postman Collection

import { openapiToPostmanCollection } from 'postman-collection-manager';

const openAPIFile = 'path/to/your/openapi.yaml';
const postmanCollectionFile = 'path/to/save/your/collection.json';

openapiToPostmanCollection(openAPIFile, postmanCollectionFile)
  .then(result => console.log('Conversion successful:', result))
  .catch(error => console.error(error.message, error.data));

Note: Ensure openapi2postmanv2 is installed globally (npm install -g openapi2postmanv2).

Documentation Flow

  1. Generate JSON from OpenAPI Object:

    • Use generateFileJson to create a JSON file from an OpenAPI object.
  2. Convert JSON to Postman Collection:

    • Utilize openapiToPostmanCollection to convert the generated JSON file to a Postman collection.
  3. Import or Update Collection in Postman:

    • Use importJsonToPostman to import the new collection or updateCollection to update an existing collection in Postman.
  4. Publish and Share Documentation:

    • Visit the Postman API Dashboard to obtain your API key.
    • Use Postman UI to publish and share your collection documentation.
  5. Automate Collection Updates:

    • Create a script in your code or API to automate the process of updating your collection documentation using the library functions.

Additional Information

  • Postman API Key: Obtain your API key from Postman API Dashboard.
  • Postman Collection ID: The collectionId parameter refers to the unique identifier of your Postman collection.

For more details on the library and its functionalities, refer to the source code and inline comments.

Feel free to contribute, report issues, or suggest improvements on GitHub.

Additional Information

gitHub Code: https://github.com/Anderson1703/postman-collection-forge/tree/master

Happy coding! 🚀