0.0.1 • Published 6 months ago

postman-runtime-collection v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

postman-runtime-collection

postman-runtime-collection is a Node.js library that provides an efficient and seamless way to interact with Postman collections programmatically. It allows developers to run, manipulate, and manage Postman collections, enabling automated testing, debugging, and integration into CI/CD pipelines.

npm version License

Features

  • Collection Execution: Run Postman collections directly from your application.
  • Lightweight: Built to be fast and efficient with minimal setup.

Installation

To install the package, use npm or yarn:

  npm install postman-runtime-collection

or

  yarn add postman-runtime-collection

Usage/Examples

// Import the runtime collection module
const runtimeCollection = require('postman-runtime-collection');

/**
 * Fetches Postman collection data using the provided API key and optional collection UID(s).
 *
 * @returns {Promise<Object>} - A promise that resolves with the fetched collection data.
 */
async function getPostmanCollection() {
    // Define the input data for the Postman collection request
    let submitData = {
        postmanApiKey: 'PMAK-XXXdea88fcXXXXXXXX-XXXXXXXXXXXXXX00c5d56eceXXXXXXXXXX', // Replace with your generated Postman API key
        collectionDataUid: [] // Optional: Provide an array of specific collection UIDs to fetch their data
    };

    try {
        // Fetch the collection data
        const collectionData = await runtimeCollection(submitData);

        // Log the collection data
        console.log('Collection Data:', collectionData);

        // Return the collection data
        return collectionData;
    } catch (error) {
        console.error('Error fetching Postman collection data:', error);
        throw error;
    }
}

Explanation

  • postmanApiKey: Your Postman API key, which you can generate from your Postman account. Ensure this key is kept secure.
  • collectionDataUid: (Optional) An array of collection UIDs. If provided, the data for these specific collections will be fetched.
  • Logging and Error Handling: The example includes error handling to ensure the process is robust and errors are logged clearly.

How to Generate a Postman API Key

To generate a Postman API key, follow the detailed instructions provided in the official Postman documentation: Generate Postman API Key

Ensure you store your API key securely and do not expose it in your codebase or public repositories.

Contributing

Feel free to submit issues or pull requests for new features, bug fixes, or general improvements.

🔗 Author Details

portfolio linkedin

License

     WWWWW||WWWWW           
       W W||W W         
          ||            
        ( OO )__________            
         /  |           \           
        /o o|    MIT     \          
        \___/||_||__||_|| *         
             || ||  || ||           
            _||_|| _||_||           
           (__|__|(__|__|           
##############################
||           MIT            ||
##############################