{"id":16184667,"url":"https://github.com/paulirish/request-capture-har","last_synced_at":"2025-03-19T02:31:36.007Z","repository":{"id":57354011,"uuid":"66743485","full_name":"paulirish/request-capture-har","owner":"paulirish","description":"Wrapper for request module that saves all traffic as a HAR file. ","archived":false,"fork":false,"pushed_at":"2017-03-27T19:35:56.000Z","size":740,"stargazers_count":41,"open_issues_count":3,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-19T12:32:18.387Z","etag":null,"topics":["har","request"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paulirish.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-28T01:30:08.000Z","updated_at":"2024-02-23T19:57:37.000Z","dependencies_parsed_at":"2022-09-05T11:20:56.005Z","dependency_job_id":null,"html_url":"https://github.com/paulirish/request-capture-har","commit_stats":null,"previous_names":["paulirish/node-request-capture-har"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulirish%2Frequest-capture-har","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulirish%2Frequest-capture-har/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulirish%2Frequest-capture-har/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulirish%2Frequest-capture-har/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paulirish","download_url":"https://codeload.github.com/paulirish/request-capture-har/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221720426,"owners_count":16869484,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["har","request"],"created_at":"2024-10-10T07:11:12.221Z","updated_at":"2024-10-27T19:09:07.553Z","avatar_url":"https://github.com/paulirish.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# request-capture-har\n\n\u003e Wrapper for [`request` module](https://www.npmjs.com/package/request) that saves all network traffic data as a HAR file.\n\n[![Build Status](https://travis-ci.org/paulirish/request-capture-har.svg?branch=master)](https://travis-ci.org/paulirish/request-capture-har) [![NPM request-capture-har package](https://img.shields.io/npm/v/request-capture-har.svg)](https://npmjs.org/package/request-capture-har)\n\n**Compatibility**\n\nrequest \u003e= 2.81.0 recommended, as it has much more detailed timings via `timingPhases`.\n\nrequest \u003e= v2.75.0 required, at a minimum.\n\n### Usage\n\n```js\n// wrap around your request module\nconst RCH = require('request-capture-har');\nconst requestCaptureHar = new RCH(require('request'));\n\n// ...\n// `requestCaptureHar.request` is your `request` module's API.\n// ...\nrequestCaptureHar.request(uri, options, callback);\n\n// Save HAR file to disk\nrequestCaptureHar.saveHar(`network-waterfall_${new Date().toISOString()}.har`);\n\n// You can also clear any collected traffic\nrequestCaptureHar.clear();\n```\n\nThis repo is a fork of [larsthorup's `node-request-har-capture`](https://github.com/larsthorup/node-request-har-capture). Instead of monkey-patching `request-promise`, the API allows you to pass in the general `request` module. We also added better support for transfer timings.\n\n![image](https://cloud.githubusercontent.com/assets/39191/18031306/9401070c-6c8f-11e6-994d-03e6b8b511e4.png)\n_Above is a HAR captured by using `request-capture-har` from within `npm` to capture an `npm install`._\n\n### Background\nThis is especially useful for capturing all test traffic from your back-end test suite, for doing auto mocking in your front-end test suite. See this project for an example: https://github.com/larsthorup/http-auto-mock-demo. Blog post about this technique: http://www.zealake.com/2015/01/05/unit-test-your-service-integration-layer/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulirish%2Frequest-capture-har","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulirish%2Frequest-capture-har","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulirish%2Frequest-capture-har/lists"}