Demuxer
Apiq documentation

Scripts

Run JavaScript before a request is sent and after its response arrives, to prepare it, test it and pass values on to the next requests.

The post-response script of a sign-in request, which tests the signed-in user, with its test passing in the response.

A request's Scripts tab holds two scripts: Before sending, which can change the request, and After response, which can read the response. Folders and the collection can have scripts too, which run around every request inside them.

Scripts reach the request and the response through apiq, also available as pm, so scripts written for Postman keep working:

  • apiq.variables, apiq.environment, apiq.collectionVariables and apiq.globals read and write variables;
  • apiq.request changes the URL, headers and body before the send;
  • apiq.response exposes the response's status, headers, time, text and JSON;
  • apiq.test and apiq.expect write tests with Chai-style assertions;
  • apiq.sendRequest sends another request from within the script;
  • console.log writes to the response's Console tab;
  • require loads libraries such as lodash, moment, ajv, cheerio, crypto-js and uuid.

Each script runs in a sandbox, with time and memory limits, and no access to the files on your computer.

  1. Open a request's Scripts tab and choose Before sending or After response.
  2. Write the script; the editor suggests apiq members as you type.
  3. Send the request, then read the test results in the response's Tests tab and the script's output in Console.

Download Apiq

Non-commercial use of Apiq is free and needs no account.

Download free

SmartScreen: the Windows installer is not code-signed yet, so Windows shows a warning when you open it. To install, click More info and then Run anyway.

Algo deu errado. Recarregue a página. Recarregar