{"id":15288945,"url":"https://github.com/benruns/bmp-client","last_synced_at":"2025-10-05T17:34:59.543Z","repository":{"id":18933328,"uuid":"85245514","full_name":"BenRuns/bmp-client","owner":"BenRuns","description":"Browsermob js client","archived":false,"fork":false,"pushed_at":"2025-04-05T02:49:13.000Z","size":84,"stargazers_count":4,"open_issues_count":9,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T03:24:57.778Z","etag":null,"topics":["browsermob-proxy","monitoring","selenium","webdriver"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BenRuns.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-16T22:02:40.000Z","updated_at":"2024-05-16T13:42:10.000Z","dependencies_parsed_at":"2024-01-12T20:17:00.975Z","dependency_job_id":"47e9c0a7-4162-4586-bd95-6f6dec495624","html_url":"https://github.com/BenRuns/bmp-client","commit_stats":{"total_commits":64,"total_committers":4,"mean_commits":16.0,"dds":0.5,"last_synced_commit":"901ae3cd050f5e354e12d1a62190d495cafcafdf"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenRuns%2Fbmp-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenRuns%2Fbmp-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenRuns%2Fbmp-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenRuns%2Fbmp-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BenRuns","download_url":"https://codeload.github.com/BenRuns/bmp-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670517,"owners_count":21142896,"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":["browsermob-proxy","monitoring","selenium","webdriver"],"created_at":"2024-09-30T15:54:44.219Z","updated_at":"2025-10-05T17:34:54.473Z","avatar_url":"https://github.com/BenRuns.png","language":"JavaScript","readme":"\n# BrowserMob Proxy Client\n\nA library built to interact with  [browsermob-proxy][1]'s  REST Api. Browsermob proxy has not been updated in several years, it is unlikely that this library will see any substantial updates anytime soon\n\n### Setup\n\n1. Ensure that you've downloaded  [browsermob-proxy][1] and have it running\n2. `npm install browsermob-proxy-client`\n\n\n#### Quick Start With Selenium\n\n```javascript\nconst webdriver = require('selenium-webdriver');\nconst By = webdriver.By;\nconst until = webdriver.until;\nconst selProxy = require('selenium-webdriver/proxy');\nconst bmpClient = require('browsermob-proxy-client').createClient();\n//need to require this or it looks for a globally installed chromedriver\nconst chromedriver = require('chromedriver');\n\nasync function runBmp() {\n  await bmpClient.start();\n  await bmpClient.createHar();\n  const driver = new webdriver.Builder()\n    .forBrowser('chrome')\n    .setProxy(selProxy.manual({ http: 'localhost:' + bmpClient.proxy.port }))\n    .build();\n\n\n  await driver.get(\"https://search.yahoo.com\");\n  const harData = await bmpClient.getHar();\n  //do something\n  console.log(harData);\n  await bmpClient.end();\n}\n\nrunBmp()\n  .then(function () {\n    console.log(\"Finished Successfully\");\n    process.exit([0]);\n  })\n  .catch(function (err) {\n    console.error(err.message);\n    console.error(err.stack)\n    process.exit([1]);\n  });\n\n```\n\n\n#### API\n\n##### BrowserMobClient.createClient(config)\nSynchronous function that instantiates a new client\n- config\n\n      {\n        browserMob:{ // *optional* details on where browsermob is running\n           host:'localhost',\n           port: 8080,\n           protocol:'http'\n         },\n         proxy:{ // *optional*\n           port:8081,\n           bindAddress: `192.168.1.222`\n         }\n      }\n\n##### client.callRest(url, method, data)\nMethod to make direct calls to browsermob-proxy's REST API\nsee [browsermob-proxy](https://github.com/lightbody/browsermob-proxy#rest-api) for available urls. Returns a promise.\n\n- url\n\n  String - '/har' (see https://github.com/lightbody/browsermob-proxy#rest-api, for a list of endpoints) \n- method\n\n  String - 'GET, POST, DELETE, PUT'\n\n- data\n\n  Object - { enable: true }\n\n\n##### client.closeProxies()\nReturns a promise that closes all proxies running\n\n\n##### client.createHar(options)\nReturns a promise. Creates a har file on browsermob\n\n- options\n\n      {\n        captureHeaders: - Boolean, capture headers or not.\n                             Optional, default to \"false\".\n\n        captureContent: - Boolean, capture content bodies or not.\n                      Optional, default to \"false\".\n\n        captureBinaryContent:  Boolean, capture binary content or not.\n                         Optional, default to \"false\".\n\n        initialPageRef: - The string name of The first page ref\n                     that should be used in the HAR. Optional,\n                     default to \"Page 1\".\n\n        initialPageTitle: - The title of first HAR page. Optional,\n                        default to initialPageRef.\n      }\n\n\n\n##### client.end()\nReturns a promise that stops the proxy port\n\n\n##### client.getHar()\nReturns a promise that resolves to a har in JSON format\n\n##### client.listProxies()\nResolves to { proxyList: [ { port: 8081 }, { port: 8082 }, { port: 8083 } ]\n\n\n##### client.setLimits(options)\nsets limits on the proxy\n- options\n\n      {\n        downstreamKbps: - Sets the downstream bandwidth limit in kbps. Optional.\n\n        upstreamKbps: - Sets the upstream bandwidth limit kbps. Optional, by default unlimited.\n\n        downstreamMaxKB: - Specifies how many kilobytes in total the client is allowed to download through the proxy. Optional, by default unlimited.\n\n        upstreamMaxKB: - Specifies how many kilobytes in total the client is allowed to upload through the proxy. Optional, by default unlimited.\n\n        latency: - Add the given latency to each HTTP request. Optional, by default all requests are invoked without latency.\n\n        enable: - A boolean that enable bandwidth limiter. Optional, by default to \"false\", but setting any of the properties above will implicitly enable throttling\n\n        payloadPercentage: - Specifying what percentage of data sent is payload, e.g. use this to take into account overhead due to tcp/ip. Optional.\n\n        maxBitsPerSecond: - The max bits per seconds you want this instance of StreamManager to respect. Optional.\n      }\n\n##### client.start(options)\nstarts a port to use\n- options\n\n      {\n        port: 'specify a port to start the proxy on',\n        bindAddress: '192.168.1.222'    // if working in a multi-home env\n      }\n\n\n\n\n### Development\n\n### Testing\n1. Install dependencies `npm install`\n\n2. Install and run [browsermob-proxy][1]\n\n       npm run install-browsermob\n       npm run start-browsermob\n\n2. Run the tests\n\n       npm test\n\n\n\n[1]:  https://github.com/lightbody/browsermob-proxy\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenruns%2Fbmp-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenruns%2Fbmp-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenruns%2Fbmp-client/lists"}