## Table of contents 1. [Introduction](#history) 2. [Structure](#structure) 1. [Structure of the properties](#structure-of-the-properties) 1. [sessions and its use cases](#sessions) 2. [data and its use cases](#data) 3. [Usage](#usage-and-verbose-mode) # History As the name suggests, the history object holds the entire life-cycle of the request sent and the response received as well as the low-level execution information which helps to debug the request execution. ## Structure The history object has the following top-level properties: ```javascript { "execution": { /* * Following properties are not available since they are passed via arguments * in request and response callback but eventually the history object will * include these as well: * * "request": , * "response": , * "cookies": */ "verbose": true "sessions": { .. } "data": [ .. ] } } ```
Changelog | Version | Changes | |---------|-------------------| | v7.11.0 | Added in: v7.11.0 |
- **execution** `` - **verbose** `` Flag indicating whether the low-level information is available or not. - **sessions** `` Holds low-level information of every socket connections made during the request. - **data** `` Request execution information for every request sent (including redirects). > Each request sent by runtime have its own unique history. In the above documentation, every socket and every request sent means the redirection the initial request went through. ### Structure of the properties #### sessions > These details are not enabled by default. Enable `verbose` requester option to get this information. - **sessions** `` - ** `` Every socket have a unique session ID which will be referred in the request `data`. The same socket can be reused for a [persistent connection](https://en.wikipedia.org/wiki/HTTP_persistent_connection). - **addresses** `` Local and remote address information like IP, Port. - **local** `` Local address data. - *address* `` Local IP address. For example, `192.168.1.1`. - *family* `` Local IP family, `IPv4` or `IPv6`. - *port* `` Local port. For example, `8080`. - **remote** `` Remote address data - *address* `` Remote IP address. - *family* `` Remote IP family. - *port* `` Remote port. - **tls** `` SSL/TLS related information. - **reused** `` Flag indicating whether the TLS session reused. - **authorized** `` Flag indicating whether the `peerCertificate` was signed by one of the trusted CAs. - **authorizationError** `` Reason why the `peerCertificate` was not been verified. - **cipher** `` TLS cipher information. - *name* `` Cipher name. For example `AES256-SHA`. - *version* `` Cipher version. - **protocol** `` The negotiated SSL/TLS protocol version of the current connection. - **ephemeralKeyInfo** `` Represents the type, name, and size of the parameter of an ephemeral key exchange in [Perfect Forward Secrecy](https://en.wikipedia.org/wiki/Forward_secrecy) on a client connection. It returns an empty object when the key exchange is not ephemeral. - *type*: `` The type of ephemeral key exchange. - *name*: `` The ephemeral key name. - *size*: `` The size of ephemeral key. - **peerCertificate** `` The peer's certificate information. - **subject**: `` The certificate subject data. - *country* `` - *stateOrProvince* `` - *locality* `` - *organization* `` - *organizationalUnit* `` - *commonName* `` - *alternativeNames* `` - **issuer**: `` The certificate issuer data. - *country* `` - *stateOrProvince* `` - *locality* `` - *organization* `` - *organizationalUnit* `` - *commonName* `` - **validFrom** `` The date-time the certificate is valid from. - **validTo** `` The date-time the certificate is valid to. - **fingerprint** `` The SHA-1 digest of the DER encoded certificate. It is returned as a : separated hexadecimal string. - **serialNumber** `` The certificate serial number, as a hex string. For example, `B9B0D332A1AA5635`. **Use cases**: - The remote IP address of the request. Using `addresses.remote`. - The reason why the peer's certificate was not been verified. Using `tls.authorizationError`. - The negotiated TLS cipher of the connection. Using `tls.cipher.name`. - The negotiated TLS protocol version of the connection. Using `tls.protocol`. - The peer's certificate information. Using `peerCertificate`. - The peer's certificate validity. Using `peerCertificate.validFrom` and `peerCertificate.validTo`. #### data > This is an array because it holds information of every request sent in a redirect chain. - **data** `` The execution data/logs of every request sent (including redirects). - **request** `` The information of the request sent. - *method* `` Request method. For example, `GET`, `POST`. - *href* `` Request URL. - *proxy* `` Request Proxy details if enabled. - *href* `` Proxy URL. - *httpVersion* `` Request HTTP Version. For example, `1.1` - **response** `` The response of the request. - *statusCode* `` Response status code. - *httpVersion* `` Response HTTP Version. - **session** `` Session used by this request connection (referred in `sessions`). - *id* `` Unique session ID (UUID). - *reused* `` Is session reused (persistent connection connection). - **timings** `` Request-Response events timeline. - *start* `` Timestamp of the start of the request (in Runtime). - *requestStart* `` Timestamp of the start of the request (in Postman Request). - *offset* `` Events offsets in millisecond resolution relative to `start`. - *request* `` Timestamp of the start of the request. - *socket* `` Timestamp when the socket is assigned to the request. - *lookup* `` Timestamp when the DNS has been resolved. - *connect* `` Timestamp when the server acknowledges the TCP connection. - *secureConnect* `` Timestamp when secure handshaking process is completed. - *response* `` Timestamp when the first bytes are received from the server. - *end* `` Timestamp when the last bytes of the response is received. - *done* `` Timestamp when the response is received at the client (Runtime). **Use cases**: - The total number of redirects a request went through and detailed information about every request. Using `data[..]`. - The connection session information. Using `session`. - The total response time. Using `timings.offset.end`. - Calculating the request timing phases.
Example of timing phases

**Usage**: ```javascript var Response = require('postman-collection').Response, executionData = history.execution.data[0]; Response.timingPhases(executionData.timings); ``` **Timing Phases**: ```javascript { prepare: Number, // duration of request preparation wait: Number, // duration of socket initialization dns: Number, // duration of DNS lookup tcp: Number, // duration of TCP connection secureHandshake: Number, // duration of secure handshake firstByte: Number, // duration of HTTP server response download: Number, // duration of HTTP download process: Number, // duration of response processing total: Number // duration entire HTTP round-trip } ```

### Usage and Verbose Mode Getting this level of debug data for every request sent in runtime might be expensive so the `sessions` details are not enabled by default and this behavior can be changed using the requester [option](https://github.com/postmanlabs/postman-runtime/#options) `verbose`. The history object is accessible in both `request` and `response` [callbacks](https://github.com/postmanlabs/postman-runtime/#callbacks). ```javascript runner.run(collection, { requester: { verbose: true // default: false } }, function (err, run) { run.start({ // Called just after sending a request, may include request replays request: function (err, cursor, response, request, item, cookies, history) { }, // Called once with response for each request in a collection response: function (err, cursor, response, request, item, cookies, history) { } }) }); ```
Example with `verbose: false` (default)

```javascript // History for a request made at https://getpostman.com { "execution": { "verbose": false, "data": [ { "request": { "method": "GET", "href": "https://getpostman.com/", "httpVersion": "1.1" }, "response": { "statusCode": 301, "httpVersion": "1.1" }, "timings": { "start": 1552926961425, "requestStart": 1552926961471, "offset": { "request": 45.888378999999986, "socket": 53.386758999999984, "lookup": 83.14568000000008, "connect": 307.48709400000007, "secureConnect": 764.0249290000002, "response": 1074.4071250000002, "end": 1080.177714, "done": 1945.8932490000002 } } }, { "request": { "method": "GET", "href": "https://www.getpostman.com/", "httpVersion": "1.1" }, "response": { "statusCode": 200, "httpVersion": "1.1" }, "timings": { "start": 1552926961425, "requestStart": 1552926962507, "offset": { "request": 1081.5938489999999, "socket": 1083.8545450000001, "lookup": 1105.6880500000002, "connect": 1220.856875, "secureConnect": 1811.9732119999999, "response": 1935.2714970000002, "end": 1940.5843479999999, "done": 1945.962564 } } } ] } } ```

Example with `verbose: true`

```javascript // History for a request made at https://www.getpostman.com { "execution": { "verbose": true, "sessions": { "306b0a7e-5962-4315-85b8-f86f2ee43079": { "addresses": { "local": { "address": "192.168.0.1", "family": "IPv4", "port": 65411 }, "remote": { "address": "54.192.216.79", "family": "IPv4", "port": 443 } }, "tls": { "reused": false, "authorized": true, "authorizationError": null, "cipher": { "name": "ECDHE-RSA-AES128-GCM-SHA256", "version": "TLSv1/SSLv3" }, "protocol": "TLSv1.2", "ephemeralKeyInfo": { "type": "ECDH", "name": "prime256v1", "size": 256 }, "peerCertificate": { "subject": { "commonName": "*.postman.co", "alternativeNames": "DNS:*.postman.co, DNS:*.getpostman.com, DNS:postman.co, DNS:getpostman.com" }, "issuer": { "country": "US", "organization": "Amazon", "organizationalUnit": "Server CA 1B", "commonName": "Amazon" }, "validFrom": "2019-02-26T00:00:00.000Z", "validTo": "2020-03-26T12:00:00.000Z", "fingerprint": "A1:64:B8:9E:7B:C4:16:44:44:7F:FD:59:58:20:C7:54:0A:29:35:23", "serialNumber": "06DDCE4821DC9169CE927A9DFFE8D037" } } } }, "data": [ { "request": { "method": "GET", "href": "https://www.getpostman.com/", "httpVersion": "1.1" }, "response": { "statusCode": 200, "httpVersion": "1.1" }, "timings": { "start": 1552927008827, "requestStart": 1552927008874, "offset": { "request": 46.947711000000254, "socket": 54.140085, "lookup": 54.46655400000009, "connect": 171.43801800000028, "secureConnect": 430.9515040000001, "response": 550.5739940000003, "end": 554.7618190000003, "done": 562.3317340000003 } }, "session": { "id": "306b0a7e-5962-4315-85b8-f86f2ee43079", "reused": false } } ] } } ```