Import Postman Collections

API Hub for Explore allows you to import collections from Postman, enabling you to further develop your APIs and web services in a single environment. The importing feature is available through the Explore.CLI solution.

Installing Explore.CLI

You can set up Explore.CLI on your device using the .NET SDK or as a standalone tool. You need an API Hub account with an active license for both installation methods.Getting Started with API Hub

1. Installing with .NET

Prerequisites

  • Ensure that the setup of .NET 7.0 version or higher is in place.

Install procedure

  1. Download the CLI tool installation package from NuGet.

  2. Run the installation command:

    dotnet tool install --global Explore.Cli

2. Standalone installation

Prerequisites

  • In Linux distributions, set up the following packages:

    • libicu - for distributions based on musl and glibc.

    • gcc - for distributions based on musl.

  • In Debian-based Linux distributions, ensure that the required packages are installed by running the command:

    apt update && apt install -y libicu-dev
  • In Alpine Linux distributions, ensure that the required packages are installed by running the command:

    apk add -y gcc icu

Install procedure

  1. Download the CLI tool installation package from GitHub. Ensure the package version is compatible with your operating system. The following are the supported OS architectures:

    OS

    Architecture

    OSX

    x86_64

    Linux

    Windows

    Alpine

    OSX

    arm64

    Linux

    Windows

    Alpine

  2. Run the installation file.

Running Explore.CLI on Docker

Alternatively, you can use the Explore.CLI tool on Docker. Follow the instructions below to build and run the Docker image.

Note

The supported system architectures are amd64 and arm64 .

  1. Download the Explore.CLI Dockerfile from GitHub, compatible with your system:

    • ./Dockerfile.alpine for Alpine Linux distributions.

    • ./Dockerfile.debian for Debian Linux distributions.

  2. Build a Docker image with one of the commands below, depending on your system architecture:

    docker build . --platform=linux/arm64 -f Dockerfile.debian  -t explore-cli:debian-arm64
    docker build . --platform=linux/arm64 -f Dockerfile.debian  -t explore-cli:debian-amd64
    docker build . --platform=linux/arm64 -f Dockerfile.alpine  -t explore-cli:alpine-arm64
    docker build . --platform=linux/arm64 -f Dockerfile.alpine  -t explore-cli:alpine-amd64
  3. To use your Docker image, set the environment variables and run the command:

    export EXPLORE_SESSION_TOKEN=<SESSION_TOKEN>
    export EXPLORE_XSRF_TOKEN=<XSRF-TOKEN>
  4. Run the Docker image. In the following example, the import-spaces references a file residing in a local directory called spaces. This directory is mounted into the Docker container at /spaces, so any file paths in the command should reference this mount point.

    docker run --platform=linux/amd64 Thank you for reaching out.
      --rm Thank you for reaching out.
      -it Thank you for reaching out.
      -v $PWD/spaces:/spaces Thank you for reaching out.
      explore-cli:debian Thank you for reaching out.n
      import-spaces Thank you for reaching out.
      --explore-cookie "SESSION=${EXPLORE_SESSION_TOKEN}; XSRF-TOKEN=${EXPLORE_XSRF_TOKEN}" Thank you for reaching
      -fp /spaces/explore_demo_spaces.json

CLI commands

Session cookies

You need to obtain certain cookies from an active session in API Hub for Explore to run the CLI commands.

  1. From API Hub for Explore, navigate to your browser development tools, and locate the application cookies. Extract the SESSION and XSRF-TOKEN cookies:

    API_screenshot_Postman_ObtainCookies.png
  2. Insert the cookies into your CLI commands in the <explore-cookie> position using the format: cookie-name=cookie-value; cookie-name=cookie-value. For example:

    SESSION=5a0a2e2f-97c6-4405-b72a-299fa8ce07c8; XSRF-TOKEN=3310cb20-2ec1-4655-b1e3-4ab76a2ac2c8

CLI command: Exporting spaces

Using Explore.CLI, you can export your API Hub for Explore spaces to the filesystem.

Note

The current export-spaces does not support exporting KAFKA APIs.

To initiate the export, run the command:

export-spaces

You can modify your export using the following flags:

-ec, --explore-cookie <explore-cookie> (REQUIRED) A valid and active SwaggerHub Explore session cookie

-fp, --file-path <file-path> The path to the directory used for exporting data. It can be either relative or absolute

-en, --export-name <export-name> The name of the exported file

-n, --names <names> A comma-separated list of space names to export

-v, --verbose Include verbose output during processing

-?, -h, --help Show help and usage information

CLI command: Importing spaces

Using Explore.CLI, you can import your API Hub for Explore spaces from the filesystem.

Note

The current import-spaces does not support importing KAFKA APIs.

To initiate the import, run the command:

import-spaces

You can modify your export using the following flags:

-ec, --explore-cookie <explore-cookie> (REQUIRED) A valid and active SwaggerHub Explore session cookie-fp, --file-path <file-path> (REQUIRED) The path to the file used for importing data-n, --names <names> A comma-separated list of space names to import-v, --verbose Include verbose output during processing-?, -h, --help Show help and usage information-ec, --explore-cookie <explore-cookie> (REQUIRED) A valid and active SwaggerHub Explore session cookie

-fp, --file-path <file-path> The path to the directory used for exporting data. It can be either relative or absolute

-en, --export-name <export-name> The name of the exported file

-n, --names <names> A comma-separated list of space names to export

-v, --verbose Include verbose output during processing

-?, -h, --help Show help and usage information

CLI command: Importing Postman collections

Using Explore.CLI, you can import your Postman collections from a file.

Note

  • The import-spaces command is compatible with Postman Collections 2.1.

  • This command bundles root level request into the API folder with the same name as the collection.

  • It adds nested collections to an API folder with the naming format parent folder - nested folder.

  • It does not support GraphQL collections/requests.

  • It does not include Environments, Authorization data (apart from explicit headers), Pre-request Scripts, or Tests in the import.

To initiate the collections import, run the command:

import-postman-collection

You can modify your collections import using the following flags:

-ec, --explore-cookie <explore-cookie> (REQUIRED) A valid and active SwaggerHub Explore session cookie

-fp, --file-path <file-path> (REQUIRED) The path to the Postman collection

-v, --verbose Include verbose output during processing

-?, -h, --help Show help and usage information
Publication date: