Apicat Docs
  1. Using scripts
Apicat Docs
  • What is Apicat?
  • Send requests
    • Create requests
      • Request basics
      • Parameters and body
      • Request headers
      • Request settings
      • Dynamic values
      • HTTP/2
    • Authentication and authorization
      • Overview
      • CA and client certificates
      • Authorization types supported by Apicat
      • Digest Auth
      • OAuth 1.0
      • OAuth 2.0
      • Hawk Authentication
      • Kerberos
      • NTLM
      • Akamai EdgeGrid
    • Response and cookies
      • Overview
      • API response in Apicat
      • Create and send cookies
      • Debug requests
    • Dynamic values Modules
      • Airline
      • Animal
      • Color
      • Commerce
      • Company
      • Database
      • Datatype
      • Date
      • Finance
      • Food
      • Git
      • Hacker
      • Helpers
      • Image
      • Internet
      • Location
      • Lorem
      • Music
      • Number
      • Person
      • Phone
      • Science
      • String
      • System
      • Vehicle
      • Word
  • Environments & variables
    • Overview
    • Using variables
    • Environments & services
  • Pre/Post processors
    • Overview
    • Assertion
    • Extract variable
    • Wait
    • Database operations
      • Overview
      • MySQL
      • MongoDB
      • Redis
      • Oracle Client
    • Using scripts
      • Overview
      • Pre processor scripts
      • Post processor scripts
      • Public scripts
      • Postman scripts reference
      • Calling other programming languages
      • Using JS libraries
      • Visualizing responses
      • Script examples
        • Assertion scripts
        • Using variables in scripts
        • Using scripts to modify request messages
        • Other examples
  • Best practices
    • How to handle API signatures
    • How to access OAuth 2.0 protected APIs
    • Apicat collaboration workflow
    • Managing authentication state in Apicat
  • Account & preferences
    • Account settings
    • Generate OpenAPI access token
    • Language settings
    • Hot keys
    • Network proxy configuration
    • Data backup
    • Updating Apicat
    • Deleting account
    • Experimental Features
  • References
    • API-Design First Approach
    • Apicat OpenAPI/Swagger Specificaiton Extensions
    • JSONPath
    • XPath
    • Regular Expressions
    • JSON Schema
    • CSV File Format
    • Install Java Environment
    • Runner deployment environment
    • Apicat flavored Markdown
  1. Using scripts

Using Scripts

Apicat contains a Javascript-based scripting engine. You can use scripts (JavaScript code snippets) to add dynamic behavior to API requests or collection tests.
What can be achieved with scripts:
1.
Test (assert) the correctness of the results returned by the request (postprocessor script).
2.
Modify API request parameters dynamically, such as adding API signature parameters, etc (preprocessor script).
3.
Pass data between API requests (using scripts to manipulate variables).
4.
Directly call programs written in other languages. We support java(.jar), python, PHP, JS, BeanShell, go, shell, Ruby, Lua, etc.
Apicat script syntax is compatible with Postman script syntax. Postman scripts can be seamlessly migrated to Apicat.
See all pm syntax supported here.
For those unfamiliar with JavaScript, writing pm scripts can be challenging. To address this, we recommend using the Apicat Script Generator to simplify script writing. Simply describe the script you want in natural language, and the generator will create a runnable script for you.

Usage#

Scripts can be added in the following two stages:
1.
Use preprocessor scripts before sending the request to the server.
2.
Use the postprocessor script (assertion) after receiving the response.

Debugging Scripts#

You can write debugging scripts in preprocessor and postprocessor so you can log output information through console.log("message") in the console.

Examples#

1.
Assertion scripts
2.
Using variables in scripts
3.
Using scripts to modify request messages
4.
Other examples

FAQ#

Q: Does Apicat support pm.nextRequest()?
A: Apicat does not have a "Run collection" functionality, so it cannot use pm.nextRequest(). The corresponding method is to create a test scenario in the Tests module, and then add an if condition, so that you can make different requests under different conditions.
Modified at 2025-09-03 09:51:32
Previous
Oracle Client
Next
Pre processor scripts
Built with