### Install and Run SDK Example Source: https://learning.postman.com/docs/sdk-generator/use/typescript-sdk.md Navigate to the SDK's examples directory, install dependencies, and run the example project to see the SDK in action. ```bash cd examples npm install npm start ``` -------------------------------- ### Manually Build and Run Example SDK Source: https://learning.postman.com/docs/sdk-generator/use/java-sdk.md Manually build and install the SDK and its examples using Maven commands. ```bash cd path/to/your-sdk mvn clean install cd examples mvn clean install mvn exec:java ``` -------------------------------- ### Run PHP SDK Example Source: https://learning.postman.com/docs/sdk-generator/use/php-sdk.md Navigate to your SDK directory, install dependencies, and execute the example script to see the SDK in action. ```bash cd path/to/your-sdk composer install php example/index.php ``` -------------------------------- ### Running Example Ruby SDK Project Source: https://learning.postman.com/docs/sdk-generator/use/ruby-sdk.md Instructions to navigate to the example directory, install dependencies, and run the example Ruby SDK project. ```bash cd example bundle install bundle exec ruby example.rb ``` -------------------------------- ### Install Go SDK using go get Source: https://learning.postman.com/docs/sdk-generator/use/go-sdk.md Add the SDK to your project's dependencies using the `go get` command. Then, import the necessary packages into your Go files. ```bash go get github.com/your-org/your-sdk ``` ```go import ( "github.com/your-org/your-sdk/pkg/yoursdk" "github.com/your-org/your-sdk/pkg/yoursdkconfig" ) config := yoursdkconfig.NewConfig() sdk := yoursdk.NewYourSdk(config) ``` -------------------------------- ### Provide Examples for Response Objects (using 'examples') Source: https://learning.postman.com/docs/api-governance/api-definition/openapi3.md Utilize the 'examples' field to offer multiple documented examples for a response, each with a summary and description. ```yaml openapi: '3.0.3' # ... paths: /resources: get: responses: '200': description: A success response content: 'application/json': schema: # ... examples: anExample: summary: An example description: This is an example description value: aProperty: example value ``` -------------------------------- ### Run Example Project Source: https://learning.postman.com/docs/sdk-generator/use/rust-sdk.md Navigate to your SDK directory and run the example project using Cargo. ```bash cd path/to/your-sdk cargo run --example example ``` -------------------------------- ### Complete Mock Server Example with pm.mock Source: https://learning.postman.com/docs/tests-and-scripts/write-scripts/postman-sandbox-reference/pm-mock.md A comprehensive example demonstrating how to use pm.mock.matchRequest and pm.mock.sendExample to handle multiple routes, including specific examples for different endpoints and status codes. Includes a fallback for unmatched routes. ```javascript // Match GET /users and serve the saved "List Users - 200 OK" example if (pm.mock.matchRequest('', req)) { pm.mock.sendExample('', res); return; } // Match GET /users/:id with a path variable if (pm.mock.matchRequest('', req)) { if (req.params.id === '999') { res.status(404).json({ error: 'User not found' }); } else { pm.mock.sendExample('', res); } return; } // Match POST /users if (pm.mock.matchRequest('', req)) { pm.mock.sendExample('', res); return; } res.status(404).json({ error: 'Route not matched' }); ``` -------------------------------- ### Provide Example for Response Objects (using 'example') Source: https://learning.postman.com/docs/api-governance/api-definition/openapi3.md Include an 'example' field within the content of a response object to provide a concrete data sample for consumers. ```yaml openapi: '3.0.3' # ... paths: /resources: get: responses: '200': description: A success response content: 'application/json': schema: # ... example: aProperty: example ``` -------------------------------- ### Add multiple examples to OpenAPI request body Source: https://learning.postman.com/docs/api-governance/api-definition/openapi3.md Use the `examples` property to provide multiple, named examples for a request body. Each example can have a summary and description, offering more context to consumers. ```json openapi: '3.0.3' # ... paths: /resources: post: requestBody: content: 'application/json': schema: # ... examples: anExample: summary: An example description: This is an example description value: aProperty: example value ``` -------------------------------- ### OpenAPI 3.0.3 Parameter with 'examples' field Source: https://learning.postman.com/docs/api-governance/api-definition/openapi3.md Utilize the 'examples' field to provide multiple, documented examples for a parameter. Each example can have its own summary and description. ```yaml openapi: '3.0.3' # ... paths: /resources: get: parameters: - name: status description: Filters resources on their status in: query examples: anExample: summary: An example description: A description of an example value: done schema: type: string ``` -------------------------------- ### Test Docker Installation Source: https://learning.postman.com/docs/reference/newman-cli/newman-with-docker.md Verify that Docker is installed and running correctly on your system by running the hello-world container. ```bash docker run hello-world ``` -------------------------------- ### Run Example Go SDK Usage Source: https://learning.postman.com/docs/sdk-generator/use/go-sdk.md Navigate to your SDK directory and execute the example file to see the SDK in action. This demonstrates initialization, API calls, and error handling. ```bash cd path/to/your-sdk go run cmd/examples/example.go ``` ```go package main import ( "context" "fmt" "github.com/your-org/your-sdk/pkg/yoursdk" "github.com/your-org/your-sdk/pkg/yoursdkconfig" "github.com/your-org/your-sdk/pkg/users" "github.com/your-org/your-sdk/pkg/util" ) func main() { config := yoursdkconfig.NewConfig() config.SetAccessToken("your-bearer-token") sdk := yoursdk.NewYourSdk(config) params := users.ListUsersRequestParams{ Limit: util.ToPointer(int64(10)), } response, err := sdk.Users.ListUsers(context.Background(), params) if err != nil { panic(err) } fmt.Printf("%+v\n", response.Data) } ``` -------------------------------- ### Install Postman CLI using npm Source: https://learning.postman.com/docs/monitoring-your-api/runners/set-up-a-runner-in-your-network.md Install the Postman CLI globally using npm. This is a prerequisite for starting a runner. ```bash npm install -g postman-cli ``` -------------------------------- ### Setup Authentication Help Source: https://learning.postman.com/docs/cli-generator/generated-cli.md Display help for the setup-auth command to see available authentication methods for the generated CLI. ```bash setup-auth --help ``` -------------------------------- ### Example HTTP Request to Mock Server Source: https://learning.postman.com/docs/tests-and-scripts/datasets/use-datasets.md This is an example of an HTTP GET request to the local mock server to retrieve user data for a specific userId. ```http http://localhost:4500/user?userId=2 ``` -------------------------------- ### Remove Existing Postman Enterprise App Source: https://learning.postman.com/docs/administration/enterprise/managing-enterprise-deployment.md Before installing, it's recommended to remove any existing installation of the Postman Enterprise app to ensure a clean setup. ```shell sudo snap remove postman-enterprise ``` -------------------------------- ### Send a GET Request to Postman Echo API Source: https://learning.postman.com/docs/getting-started/quick-start.md Send a GET request to the Postman Echo API to retrieve data. This is a basic example to verify API communication. ```javascript pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); ``` -------------------------------- ### Run SDK Example Manually Source: https://learning.postman.com/docs/sdk-generator/use/kotlin-sdk.md Navigate to the examples directory and run the provided script or use Gradle for execution. ```bash cd examples ./run.sh ``` ```bash cd path/to/your-sdk gradle run ``` -------------------------------- ### Run Example SDK Project Source: https://learning.postman.com/docs/sdk-generator/use/java-sdk.md Navigate to the examples directory and execute the run script to test the generated Java SDK. ```bash cd examples ./run.sh ``` -------------------------------- ### Get Largest Integer with $floor Source: https://learning.postman.com/docs/postman-flows/flows-query-language/function-reference.md Use the $floor function to get the largest integer less than or equal to a given number. Example: $floor(3.4) returns 3. ```Postman Flows $floor(3.4) -> 3 ``` -------------------------------- ### Example: Run Postman Mock Server with Configuration Source: https://learning.postman.com/docs/postman-cli/postman-cli-mock.md Demonstrates how to run a mock server using a configuration file. An optional environment file can also be specified. ```bash postman mock run mock-config.json postman mock run mock-config.json --environment ./postman/environments/dev.yaml ``` -------------------------------- ### Get Run Button Index (DOM) Source: https://learning.postman.com/docs/publishing-your-api/run-in-postman/customize-run-button.md When segregateEnvironments is enabled, use runButtonIndex to reference each button by its position in the DOM. This example shows how to get the index using native JavaScript. ```javascript var runButtons = Array.prototype.slice.call(document.getElementsByClassName('postman-run-button')), runButtonIndex = runButtons.indexOf(elem); ``` -------------------------------- ### Example: Complete Authorization Code Flow Source: https://learning.postman.com/docs/cli-generator/generated-cli.md Demonstrates the sequence of commands to set up client credentials and then initiate the authorization code flow. This includes saving credentials and requesting scopes. ```bash # First, save your client credentials (if not already done) setup-auth oauth client-credentials \ --client-id "abc123" \ --client-secret "secret456" # Then run the authorization code flow setup-auth oauth authorization-code --scopes "read,write" # Opening browser for authorization... # If the browser does not open, visit this URL: # https://auth.example.com/authorize?client_id=abc123&redirect_uri=... # Waiting for authorization... # Authorization successful! ``` -------------------------------- ### Install Postman MCP Server with OAuth (US Server) Source: https://learning.postman.com/docs/reference/postman-api/postman-mcp-server/postman-mcp-remote-server.md Use this command to install the Postman MCP server using OAuth authentication with the US server. This method requires no manual API key setup. ```bash codex mcp add postman --remote-url https://mcp.postman.com/minimal ``` -------------------------------- ### Start a Postman Runner for Private API Monitoring Source: https://learning.postman.com/docs/postman-cli/postman-cli-monitoring.md Start a runner from your internal network to monitor and test APIs. Provide the runner ID and key obtained during runner setup. Ensure you are logged in using `postman login`. ```bash postman runner start --id --key [options] ``` -------------------------------- ### Run Example C# SDK Usage Source: https://learning.postman.com/docs/sdk-generator/use/csharp-sdk.md Demonstrates initializing the SDK, making a type-safe API call, and handling potential errors using custom exceptions. Ensure you have set your access token. ```bash cd path/to/your-sdk/Example dotnet run ``` ```csharp using YourSdk; using YourSdk.Config; using YourSdk.Models; using Environment = YourSdk.Http.Environment; var config = new YourSdkConfig { AccessToken = "YOUR_ACCESS_TOKEN" }; var client = new YourSdkClient(config); try { var response = await client.Users.ListUsersAsync(limit: 10); Console.WriteLine(response); } catch (Exception error) { Console.WriteLine($"Error: {error}"); } ``` -------------------------------- ### Initialize and Use Kotlin SDK Source: https://learning.postman.com/docs/sdk-generator/use/kotlin-sdk.md Demonstrates initializing the SDK with an API key configuration and making a synchronous user retrieval call. Includes basic exception handling. ```kotlin import com.example.sdk.Sdk import com.example.sdk.config.SdkConfig import com.example.sdk.config.ApiKeyAuthConfig import com.example.sdk.models.User fun main() { // Initialize the SDK val config = SdkConfig.builder() .apiKeyAuthConfig( ApiKeyAuthConfig.builder() .apiKey("your-api-key") .build() ) .build() val sdk = Sdk(config) try { // Call an API endpoint val user = sdk.usersService.getUser("123") println("User: $user") } catch (e: Exception) { System.err.println("Error: ${e.message}") } } ``` -------------------------------- ### Navigate to MCP server directory Source: https://learning.postman.com/docs/postman-api-network/showcase/publish/mcp-servers/set-up-start.md Change your terminal's current directory to the root of your MCP server project. This is a prerequisite for installing dependencies and starting the server. ```bash cd /path/to/your-mcp-server ``` -------------------------------- ### PHP SDK Initialization and API Call Example Source: https://learning.postman.com/docs/sdk-generator/use/php-sdk.md This example demonstrates initializing the SDK client with an access token and making a sample API call to retrieve user data, including basic exception handling for API errors. ```php users->getUser('123'); echo "User: " . $user->name . "\n"; } catch (ApiException $e) { echo "Error: " . $e->getMessage() . "\n"; echo "Status: " . $e->statusCode . "\n"; } ``` -------------------------------- ### Get Specific User Command Source: https://learning.postman.com/docs/cli-generator/generated-cli.md Example of retrieving a specific user using their ID. This demonstrates the use of flags to pass parameters to commands within a command group. ```bash my-api users get --id "user-123" ``` -------------------------------- ### Dockerfile for Postman Runner Source: https://learning.postman.com/docs/monitoring-your-api/runners/set-up-a-runner-in-your-network.md This Dockerfile installs the Postman CLI and configures the environment to run the Postman runner. It sets up a non-root user and specifies the command to start the runner with provided credentials. ```dockerfile FROM --platform=linux/amd64 node:22-bookworm-slim # Install ca-certificates for SSL/TLS connections RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/* # Install Postman CLI RUN npm install -g postman-cli # Create a non-root user RUN groupadd -r postman && useradd -r -g postman -u 1001 postman # Set working directory for runner WORKDIR /app # Create Postman directories with proper permissions RUN mkdir -p /home/postman/.postman/logs && \ chown -R postman:postman /home/postman/.postman && \ chown -R postman:postman /app # Switch to non-root user USER postman # Run the Postman runner CMD ["sh", "-c", "postman runner start --id ${POSTMAN_RUNNER_ID} --key ${POSTMAN_RUNNER_KEY}"] ``` -------------------------------- ### Initialize SDK and Call API Source: https://learning.postman.com/docs/sdk-generator/use/java-sdk.md Demonstrates initializing the Java SDK with an API key configuration and making a synchronous call to retrieve user data. ```java import com.example.sdk.Sdk; import com.example.sdk.config.SdkConfig; import com.example.sdk.config.ApiKeyAuthConfig; import com.example.sdk.models.User; public class Main { public static void main(String[] args) { // Initialize the SDK SdkConfig config = SdkConfig.builder() .apiKeyAuthConfig( ApiKeyAuthConfig.builder() .apiKey("your-api-key") .build() ) .build(); Sdk sdk = new Sdk(config); try { // Call an API endpoint User user = sdk.usersService.getUser("123"); System.out.println("User: " + user); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); } } } ``` -------------------------------- ### Apply Security Scheme to API Operation Source: https://learning.postman.com/docs/api-governance/api-definition/openapi2.md When an API operation does not have a security scheme applied by default, you must specify at least one item in the `security` array for that operation. This example applies `basicAuth` to a GET operation. ```yaml swagger: '2.0' #... paths: /user: get: description: 'Returns details about a particular user' security: - basicAuth: [] #... securityDefinitions: basicAuth: type: basic ``` -------------------------------- ### Prompt Coding Agent to Use Postman CLI Context Source: https://learning.postman.com/docs/postman-cli/postman-cli-context.md An example prompt instructing a coding agent to use the Postman CLI for API discovery and client code generation, starting with the `postman context instructions` command. ```text Search for payment APIs using the Postman CLI and help me select one and generate client code for it. Run the `postman context instructions` command first. ``` -------------------------------- ### Dockerfile for Postman Runner with Built-in Proxy Source: https://learning.postman.com/docs/monitoring-your-api/runners/proxy-server/use-built-in-proxy-server.md This Dockerfile installs the Postman CLI, configures a non-root user, and starts the runner with the `--egress-proxy` option enabled and the authorization service URL specified. It's suitable for containerized environments. ```dockerfile FROM --platform=linux/amd64 node:22-bookworm-slim # Install CA certificates for SSL/TLS connections and curl for health checks RUN apt-get update && apt-get install -y ca-certificates curl && rm -rf /var/lib/apt/lists/* # Install Postman CLI RUN npm install -g postman-cli # Set working directory for runner WORKDIR /app # Create non-root user and set up directories # The directory permissions ensure the runner can write logs and cache data RUN groupadd --system --gid 1001 postman && \ useradd --system --uid 1001 --gid postman --home-dir /app postman && \ mkdir -p /.postman/logs \ /app/.postman/logs \ /app/.postman/cli \ /app/.postman-runner-proxy-ca && \ chown -R postman:postman /app && \ chown -R postman:postman /.postman && \ chmod -R 777 /.postman && \ chmod -R 777 /app/.postman-runner-proxy-ca # Switch to non-root user for security USER postman # Start the Postman runner with the built-in proxy enabled CMD ["sh", "-c", "postman runner start --id ${POSTMAN_RUNNER_ID} --key ${POSTMAN_RUNNER_KEY} --egress-proxy --egress-proxy-authz-url ${AUTHORIZATION_SERVICE_URL}"] ``` -------------------------------- ### Install Go SDK from Local Path Source: https://learning.postman.com/docs/sdk-generator/use/go-sdk.md Use a `replace` directive in your `go.mod` file to point to a local directory for SDKs not yet published to a registry. Run `go mod tidy` to update dependencies. ```text module your-app go 1.22 require github.com/your-org/your-sdk v0.0.0 replace github.com/your-org/your-sdk => ../path/to/your-sdk ``` -------------------------------- ### Enforce Security Scheme on Operation Source: https://learning.postman.com/docs/api-governance/api-definition/openapi2.md To prevent unauthorized access, define a `security` field within the operation if neither the global security field nor the operation's security field is defined. This example demonstrates defining `basicAuth` for a GET operation. ```yaml swagger: '2.0' #... paths: /user: get: description: 'Sample endpoint: Returns details about a particular user' security: - basicAuth: [] #... securityDefinitions: basicAuth: type: basic ``` -------------------------------- ### Initialize and Use Ruby SDK Source: https://learning.postman.com/docs/sdk-generator/use/ruby-sdk.md Shows how to initialize the Ruby SDK client and make a basic API call to get a user. ```ruby require 'your_sdk' # Initialize the SDK sdk = YourSdk::Client.new response = sdk.users.get_user("123") puts response ``` -------------------------------- ### Install CLI System-Wide Source: https://learning.postman.com/docs/cli-generator/generated-cli.md Move the generated CLI binary to a directory in your system's PATH to make it accessible from any location. ```bash # macOS / Linux mv ./ /usr/local/bin/ ``` -------------------------------- ### Mocking a User Profile Endpoint with Wildcard Variable Source: https://learning.postman.com/docs/design-apis/mock-apis/matching-algorithm.md This example demonstrates how to use a wildcard variable `{{userId}}` in a GET request URL to capture dynamic segments like user IDs. The mock server will capture the value from the URL and can return it in the response. ```json { "id": 2, "name": "Carol" } ``` -------------------------------- ### Install PKG Installer System-Wide Source: https://learning.postman.com/docs/administration/enterprise/managing-enterprise-deployment.md Use this command to install the PKG installer for the Postman Enterprise app system-wide. This installs to /Applications and preferences to /Library/Preferences. ```shell sudo installer -dumplog -verbose -pkg path/to/app.pkg -target LocalSystem ``` -------------------------------- ### Basic SDK Usage with Tokio Source: https://learning.postman.com/docs/sdk-generator/use/rust-sdk.md Demonstrates basic SDK client initialization and making an API call to list pets using asynchronous operations with Tokio. Configuration includes an access token, environment, and timeout. ```rust use your_sdk::{YourSdkClient, YourSdkConfig}; use your_sdk::http::Environment; #[tokio::main] async fn main() -> Result<(), Box> { let config = YourSdkConfig::builder() .access_token("your-api-key") .environment(Environment::Production) .timeout_ms(30000) .build() .expect("Failed to build configuration"); let client = YourSdkClient::new(config)?; match client.pets().list_pets(None).await { Ok(pets) => { println!("Pets: {:?}", pets); } Err(error) => { eprintln!("Error: {}", error); } } Ok(()) } ``` -------------------------------- ### Install PKG Installer Per-User Source: https://learning.postman.com/docs/administration/enterprise/managing-enterprise-deployment.md Use this command to install the PKG installer for the Postman Enterprise app for the current user. This installs to $HOME/Applications and preferences to $HOME/Library/Preferences. ```shell installer -dumplog -verbose -pkg path/to/app.pkg -target CurrentUserHomeDirectory ``` -------------------------------- ### Run a Simulation Configuration Source: https://learning.postman.com/docs/postman-cli/postman-cli-simulator.md Use this command to start a local mock server with a specified simulation configuration file. This helps in testing how your service handles disruptions and performance issues. ```bash postman simulate run .sim.yaml ``` -------------------------------- ### Initialize and Use TypeScript SDK Source: https://learning.postman.com/docs/sdk-generator/use/typescript-sdk.md Demonstrates how to initialize the generated TypeScript SDK with an API key and base URL, and how to make a sample API call to retrieve user data. ```typescript import { YourSdk } from 'your-sdk-package'; (async () => { // Initialize the SDK const sdk = new YourSdk({ apiKey: 'your-api-key', baseUrl: 'https://api.example.com' }); try { // Call an API endpoint const result = await sdk.users.getUser({ userId: '123' }); console.log('User:', result); } catch (error) { console.error('Error:', error); } })(); ``` -------------------------------- ### Initialize Ruby SDK Client with Authentication Source: https://learning.postman.com/docs/sdk-generator/use/ruby-sdk.md Provides examples of initializing the Ruby SDK client with different authentication methods: no auth, bearer token, and API key/basic auth. ```ruby # No auth client = YourSdk::Client.new # With bearer auth client = YourSdk::Client.new(token: 'YOUR_TOKEN') # With API key / basic auth client = YourSdk::Client.new(api_key: 'YOUR_KEY', username: 'user', password: 'pass') ``` -------------------------------- ### Example: Inject Agent with Discovery Mode and Secrets Source: https://learning.postman.com/docs/insights/reference/agent/api-catalog.md A comprehensive example demonstrating agent injection with discovery mode enabled, specifying service name, enabling secret generation, and directing output to a file. ```bash postman-insights-agent kube inject \ -f deployment.yaml \ --discovery-mode \ --cluster-name "production-cluster" \ --service-name "my-namespace/my-service" \ --secret \ -o injected-deployment.yaml ``` -------------------------------- ### Asynchronous SDK Usage Example Source: https://learning.postman.com/docs/sdk-generator/use/python-sdk.md Provides an example of initializing and using the asynchronous Python SDK. Shows how to make an async API call using `asyncio`. ```python import asyncio from your_sdk import AsyncSdk async def main(): sdk = AsyncSdk(api_key="your-api-key") user = await sdk.users.get_user(user_id="123") print(f"User: {user}") asyncio.run(main()) ``` -------------------------------- ### Install libgconf-2-4 on Ubuntu 18 Source: https://learning.postman.com/docs/getting-started/installation/install-app.md Use this command to install the 'libgconf-2-4' package on Ubuntu 18 if required for Postman installation. ```shell apt-get install libgconf-2-4 ``` -------------------------------- ### Example: Publish API Version with Options Source: https://learning.postman.com/docs/postman-cli/postman-cli-publish-api-versions.md This example demonstrates how to publish an API version using the `postman api publish` command with several options. It specifies the API ID, version name, release notes, associated collections, and the API definition. ```bash postman api publish 12345678-12345ab-1234-1ab2-1ab2-ab1234112a12 --name v1\n--release-notes "# Some release notes information"\n--collections \n--api-definition ``` -------------------------------- ### Install Postman Enterprise to a Custom Directory Source: https://learning.postman.com/docs/administration/enterprise/managing-enterprise-deployment.md Use the INSTALLDIR property to specify a custom installation path for a system-wide installation. ```shell msiexec /i path/to/package.msi INSTALLDIR=C:\custom ``` -------------------------------- ### Install Postman Enterprise Per-User Source: https://learning.postman.com/docs/administration/enterprise/managing-enterprise-deployment.md Set MSIINSTALLPERUSER to 1 to perform a per-user installation instead of a system-wide one. This installs to the default user directory. ```shell msiexec /i path/to/package.msi MSIINSTALLPERUSER=1 ```