- Introduction
- Installing and updating
- Navigating Postman
- Sending your first request
- Managing your account
- Syncing your work
- Discovering templates
- Creating your first collection
- Creating a workspace
- Setting up your Postman app
- Importing and exporting data
- Troubleshooting app issues
- Building requests
- Authorizing requests
- Receiving responses
- Grouping requests in collections
- Using variables
- Managing environments
- Visualizing responses
- Specifying examples
- Using cookies
- Working with certificates
- Generating client code
- Troubleshooting requests
- Using the Collection Runner
- Scheduling runs with monitors
- Building request workflows
- Importing data files
- Working with your team
- Defining roles
- Requesting access
- Sharing your work
- Your Private API Network
- Commenting on collections
- Versioning APIs
- Using version control
- Using the API Builder
- Managing and sharing APIs
- Validating APIs
- Monitoring your APIs
- Setting up a monitor
- Viewing monitor results
- Monitoring APIs and websites
- Set up integrations to receive alerts
- Running Postman monitors using static IPs
- Troubleshooting monitors
- Monitoring FAQs
- Analyzing with reports
- Documenting your API
- Authoring your docs
- Publishing your docs
- Viewing documentation
- Using custom domains
- Publishing templates
- Publishing to the API Network
- Submission guidelines
- Managing your team
- Purchasing Postman
- Billing
- Configuring team settings
- Utilizing audit logs
- Onboarding checklist
- Migrating data between teams
- Intro to SSO
- Configuring SSO for a team
- Logging in to an SSO team
- Microsoft AD FS
- Custom SAML in Azure AD
- Custom SAML in Duo
- Custom SAML in GSuite
- Custom SAML in Okta
- Custom SAML in Onelogin
- Custom SAML in Ping Identity
- Migrating to the current version of Postman
Code generator library
You can generate client code for your API collections in Postman. The node.js code generator module converts a request into client code for your target language in conjunction with the Collection SDK.
The code generator takes a Collection SDK Request object and turns it into code to make the same request in a client app using a specified language / framework.
You can install the code generator library from NPM or by cloning it from the repo.
If you just need to generate client code for a request or collection you can do so in the Postman app.
Using code generation programmatically
The code generator library allows you to generate client requests in your application code. The following simplified code excerpt demonstrates using convert
to build a client code snippet from a Request object via the Collection SDK, targeting node.js:
var codegen = require('postman-code-generators'),
sdk = require('postman-collection'),
request = new sdk.Request('https://www.google.com'),
language = 'nodejs',
variant = 'request',
options = {
indentCount: 3,
indentType: 'Space',
trimRequestBody: true,
followRedirect: true
};
codegen.convert(language, variant, request, options,
function(error, snippet) {
if (error) {
// handle error
}
// handle snippet..
});
You can use the getOptions
method to find config options for your target language:
var codegen = require('postman-code-generators'),
language = 'nodejs',
variant = 'Request';
codegen.getOptions(language, variant, function (error, options) {
if (error) {
// handle error
}
console.log(options);
});
The getLanguageList
method returns available languages your request client code can target:
var codegen = require('postman-code-generators'),
supportedCodegens = codegen.getLanguageList();
console.log(supportedCodegens);
Supported languages
Since the code generator module is an open source project, if there is a language or framework you would like to be able to generate client code for, but that isn't currently provided, you can add it yourself by contributing to the project. This allows people to access your contribution not only by using the code utility, but also in the Postman app itself.
Next steps
To get started using the code generator module, check out the instructions for installation and usage in the project repo on GitHub. If you're using Postman to work with client applications, you might also find it useful to capture request data.