{"_id":"@chahakshah/har-to-ts","_rev":"5-8d16e8e6873870b9ee6176ca237e86fc","name":"@chahakshah/har-to-ts","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@chahakshah/har-to-ts","version":"1.0.0","keywords":["HAR","TypeScript","API","Generator"],"author":{"name":"Chahak Shah"},"license":"MIT","_id":"@chahakshah/har-to-ts@1.0.0","maintainers":[{"name":"chahakshah","email":"chahak.shah.cs@gmail.com"}],"homepage":"https://github.com/chahakshahcs5/har-to-ts#readme","bugs":{"url":"https://github.com/chahakshahcs5/har-to-ts/issues"},"bin":{"har-to-ts":"dist/cli.js"},"dist":{"shasum":"7dcb503e90e902b00620413d81cd6df415c8061e","tarball":"https://registry.npmjs.org/@chahakshah/har-to-ts/-/har-to-ts-1.0.0.tgz","fileCount":9,"integrity":"sha512-W0DnY7q1Nt0AdX1lAxcqLoY9H8Flrj4BAEl7r3j+I1Hf0KLFFVZ+PgRgCyoHGiV0tv/pq+RnerIPoa95eMk6Hw==","signatures":[{"sig":"MEUCIBcoCr9GBKcFGVyrqx2ggVbXdnShHYulp8uRyDAwSJqdAiEAifkI8vQmmBYyREJlhrrDxtELUGMvJbl6drtNRK5U53E=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30987},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"d7e27c78ebf9e15c2cd35555f4d685802c9feed7","scripts":{"dev":"ts-node src/index.ts","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","start":"node dist/index.js","typecheck":"tsc --noEmit"},"_npmUser":{"name":"chahakshah","email":"chahak.shah.cs@gmail.com"},"name_ext":"HAR To TypeScript API","repository":{"url":"git+https://github.com/chahakshahcs5/har-to-ts.git","type":"git"},"_npmVersion":"11.6.1","description":"Create API file from HAR Session file","directories":{},"_nodeVersion":"22.19.0","dependencies":{"qs":"^6.14.0","prettier":"^3.6.2","json-to-ts":"^2.1.0","@types/prettier":"^2.7.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ts-node":"^10.9.2","@types/qs":"^6.14.0","typescript":"^5.9.3","@types/node":"^24.7.0"},"_npmOperationalInternal":{"tmp":"tmp/har-to-ts_1.0.0_1759860131853_0.5521627912213551","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@chahakshah/har-to-ts","version":"1.0.4","keywords":["HAR","TypeScript","API","Generator"],"author":{"name":"Chahak Shah"},"license":"MIT","_id":"@chahakshah/har-to-ts@1.0.4","maintainers":[{"name":"chahakshah","email":"chahak.shah.cs@gmail.com"}],"homepage":"https://github.com/chahakshahcs5/har-to-ts#readme","bugs":{"url":"https://github.com/chahakshahcs5/har-to-ts/issues"},"bin":{"har-to-ts":"dist/cli.js"},"dist":{"shasum":"c086c61efec1f5e7c5da0ebb7cad46bc85a409c5","tarball":"https://registry.npmjs.org/@chahakshah/har-to-ts/-/har-to-ts-1.0.4.tgz","fileCount":9,"integrity":"sha512-fw5ndochHppC8IcXgihQV5nRAzmJXWQaX+jn4Q23p1PrgkT/chZzM4ry1WtbxhfU/Y8D593MolttETGJbkZt5w==","signatures":[{"sig":"MEQCIB4TgOJeYryd5p4edswsr4vqiBK0MDoXaVe2ggSCTNv/AiBSHwettuor8lucZLEBPok4Yn9QTI00mZHiXCgCITBE3A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30399},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"aeeac5af067f8c67996874312c4852206eed7c88","scripts":{"dev":"ts-node src/index.ts","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","start":"node dist/index.js","typecheck":"tsc --noEmit"},"_npmUser":{"name":"chahakshah","email":"chahak.shah.cs@gmail.com"},"name_ext":"HAR To TypeScript API","repository":{"url":"git+https://github.com/chahakshahcs5/har-to-ts.git","type":"git"},"_npmVersion":"10.8.2","description":"Create API file from HAR Session file","directories":{},"_nodeVersion":"20.19.5","dependencies":{"qs":"^6.14.0","prettier":"^3.6.2","json-to-ts":"^2.1.0","@types/prettier":"^2.7.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ts-node":"^10.9.2","@types/qs":"^6.14.0","typescript":"^5.9.3","@types/node":"^24.7.0"},"_npmOperationalInternal":{"tmp":"tmp/har-to-ts_1.0.4_1759860706119_0.8421296085783159","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@chahakshah/har-to-ts","version":"1.0.5","keywords":["HAR","TypeScript","API","Generator"],"author":{"name":"Chahak Shah"},"license":"MIT","_id":"@chahakshah/har-to-ts@1.0.5","maintainers":[{"name":"chahakshah","email":"chahak.shah.cs@gmail.com"}],"homepage":"https://github.com/chahakshahcs5/har-to-ts#readme","bugs":{"url":"https://github.com/chahakshahcs5/har-to-ts/issues"},"bin":{"har-to-ts":"dist/cli.js"},"dist":{"shasum":"9dc0db12b99ee292ecccae81246ff0da795cc6e3","tarball":"https://registry.npmjs.org/@chahakshah/har-to-ts/-/har-to-ts-1.0.5.tgz","fileCount":9,"integrity":"sha512-ZHpn4U2pctAQxgBsCTzIOcH5mJo37ewQVqnF21NOC+Kk/7hJ/8N+7kSZmA8emiUHr03TN5cI/awfLOWWgbxluQ==","signatures":[{"sig":"MEUCIQDPb0Is/ABHb+MCTmOCboM/5z3J6D/kzSB4WGii3xXgMQIgVeX15WFiDd0r5cAmfX908iEG1Ve9l1wPVPnRNpBz9+M=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":31339},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"b44408efa28cd120076d9dad5aac95579e2faf93","scripts":{"dev":"ts-node src/index.ts","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","start":"node dist/index.js","typecheck":"tsc --noEmit"},"_npmUser":{"name":"chahakshah","email":"chahak.shah.cs@gmail.com"},"name_ext":"HAR To TypeScript API","repository":{"url":"git+https://github.com/chahakshahcs5/har-to-ts.git","type":"git"},"_npmVersion":"10.8.2","description":"Create API file from HAR Session file","directories":{},"_nodeVersion":"20.19.5","dependencies":{"qs":"^6.14.0","prettier":"^3.6.2","json-to-ts":"^2.1.0","@types/prettier":"^2.7.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ts-node":"^10.9.2","@types/qs":"^6.14.0","typescript":"^5.9.3","@types/node":"^24.7.0"},"_npmOperationalInternal":{"tmp":"tmp/har-to-ts_1.0.5_1759862360274_0.42915380407670556","host":"s3://npm-registry-packages-npm-production"}},"1.0.6":{"name":"@chahakshah/har-to-ts","version":"1.0.6","keywords":["HAR","TypeScript","API","Generator"],"author":{"name":"Chahak Shah"},"license":"MIT","_id":"@chahakshah/har-to-ts@1.0.6","maintainers":[{"name":"chahakshah","email":"chahak.shah.cs@gmail.com"}],"homepage":"https://github.com/chahakshahcs5/har-to-ts#readme","bugs":{"url":"https://github.com/chahakshahcs5/har-to-ts/issues"},"bin":{"har-to-ts":"dist/cli.js"},"dist":{"shasum":"c3c2c62537ae4955c1530fedc8c9199c71257231","tarball":"https://registry.npmjs.org/@chahakshah/har-to-ts/-/har-to-ts-1.0.6.tgz","fileCount":9,"integrity":"sha512-TB9dB3AyfwZLT7abh84hGwjiNDjJb0jpyk1G1oAtNCfVicpGibd6Al6Sf7XNHCHF1Zb3s3cVNSZruZSwY4N7dw==","signatures":[{"sig":"MEUCIFoeOHW+Fc5egYq+kBXUBKmxPHlOxOafCu2dm+TiWX4bAiEAnw+piea5E7c+kUoU0Ws3Hy/cMQkRMt+2tqc+t5Z5sPk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":31347},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"521de7956961543f26250a7fff4de327815b8f3f","scripts":{"dev":"ts-node src/index.ts","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","start":"node dist/index.js","typecheck":"tsc --noEmit"},"_npmUser":{"name":"chahakshah","email":"chahak.shah.cs@gmail.com"},"name_ext":"HAR To TypeScript API","repository":{"url":"git+https://github.com/chahakshahcs5/har-to-ts.git","type":"git"},"_npmVersion":"10.8.2","description":"Create API file from HAR Session file","directories":{},"_nodeVersion":"20.19.5","dependencies":{"qs":"^6.14.0","prettier":"^3.6.2","json-to-ts":"^2.1.0","@types/prettier":"^2.7.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ts-node":"^10.9.2","@types/qs":"^6.14.0","typescript":"^5.9.3","@types/node":"^24.7.0"},"_npmOperationalInternal":{"tmp":"tmp/har-to-ts_1.0.6_1759862569883_0.7934497378555316","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"_id":"@chahakshah/har-to-ts@1.1.0","bin":{"har-to-ts":"dist/cli.js"},"bugs":{"url":"https://github.com/chahakshahcs5/har-to-ts/issues"},"dist":{"shasum":"458ef9a40855177f8d5ad670c83201755cd0cab5","tarball":"https://registry.npmjs.org/@chahakshah/har-to-ts/-/har-to-ts-1.1.0.tgz","fileCount":12,"integrity":"sha512-kl9a0W+VEjA0sgOhu0+yELJCazV0trf7v+EtBFPVLg9qtCi5goENQdP/XhqoxkvoB+dQhazvPFQb9oO2tByybA==","signatures":[{"sig":"MEUCICc7/zsnY5Q+e1JRMvu+EDuYY59hypp1Zl8z0uIYk5fIAiEA9mnh7iwulhsUlUX+jXX4o/345223yPv49eoMwgp1pPA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHTeqL8uSC1jVCuhkQMPqqp/h4/g8nHALRrodTJOtCPqAiADoDEmzaZ+xI0f7BPEHcMFoWPYKEM+Zl2xxMCXVr04jg=="}],"unpackedSize":78764},"main":"dist/index.js","name":"@chahakshah/har-to-ts","types":"dist/index.d.ts","author":{"name":"Chahak Shah"},"gitHead":"04b0dffdb0d3ee37453626d0445d6039e531900b","license":"MIT","scripts":{"dev":"ts-node src/index.ts","test":"npm run build && ts-node test/runAll.ts","build":"tsc","start":"node dist/index.js","prepare":"npm run build","typecheck":"tsc --noEmit"},"version":"1.1.0","_npmUser":{"name":"chahakshah","email":"chahak.shah.cs@gmail.com"},"homepage":"https://github.com/chahakshahcs5/har-to-ts#readme","keywords":["HAR","TypeScript","API","Generator"],"name_ext":"HAR To TypeScript API","repository":{"url":"git+https://github.com/chahakshahcs5/har-to-ts.git","type":"git"},"_npmVersion":"10.8.2","description":"Create API file from HAR Session file","directories":{},"maintainers":[{"name":"chahakshah","email":"chahak.shah.cs@gmail.com"}],"_nodeVersion":"20.20.2","dependencies":{"qs":"^6.14.0","prettier":"^3.6.2","json-to-ts":"^2.1.0","@types/prettier":"^2.7.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ts-node":"^10.9.2","@types/qs":"^6.14.0","typescript":"^5.9.3","@types/node":"^24.7.0","@types/har-format":"^1.2.16"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/har-to-ts_1.1.0_1788249059026_0.9224975625880081"}}},"time":{"created":"2025-10-07T18:02:11.758Z","modified":"2026-09-01T07:50:59.278Z","1.0.0":"2025-10-07T18:02:12.053Z","1.0.4":"2025-10-07T18:11:46.395Z","1.0.5":"2025-10-07T18:39:20.472Z","1.0.6":"2025-10-07T18:42:50.092Z","1.1.0":"2026-09-01T07:50:59.106Z"},"bugs":{"url":"https://github.com/chahakshahcs5/har-to-ts/issues"},"author":{"name":"Chahak Shah"},"license":"MIT","homepage":"https://github.com/chahakshahcs5/har-to-ts#readme","keywords":["HAR","TypeScript","API","Generator"],"repository":{"url":"git+https://github.com/chahakshahcs5/har-to-ts.git","type":"git"},"description":"Create API file from HAR Session file","maintainers":[{"name":"chahakshah","email":"chahak.shah.cs@gmail.com"}],"readme":"# har-to-ts\n\nA powerful tool and library to convert HAR (HTTP Archive) files into fully-typed TypeScript API SDKs with built-in request filtering capabilities.\n\n[![npm version](https://img.shields.io/npm/v/@chahakshah/har-to-ts.svg)](https://www.npmjs.com/package/@chahakshah/har-to-ts)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n\n---\n\n## Features\n\n- ⚡ **Automated TypeScript SDK Generation**: Automatically generates request parameters, body types, response types, and fetch functions from recorded HTTP traffic.\n- 🎯 **Advanced HAR Filtering**: Filter requests by HTTP method, URL patterns, status codes, resource types, headers, latencies, and more.\n- 📦 **CLI & Programmatic API**: Use directly from the terminal or integrate into your Node.js/TypeScript build scripts.\n- ✨ **Clean Code Output**: Automatically formatted with Prettier.\n\n---\n\n## Installation\n\n```bash\nnpm install -g @chahakshah/har-to-ts\n```\n\nOr run directly with `npx`:\n\n```bash\nnpx @chahakshah/har-to-ts <sourcefile> <destinationfile> [options]\n```\n\n---\n\n## CLI Usage\n\n```bash\nhar-to-ts <sourcefile> <destinationfile> [options]\n```\n\n### Arguments\n\n- `<sourcefile>`: Path to the input HAR file (`.har`).\n- `<destinationfile>`: Path to the output TypeScript file (`.ts`).\n\n### Options & Flags\n\n| Flag | Shorthand | Description | Example |\n| :--- | :--- | :--- | :--- |\n| `--filter <file\\|json>` | `-f` | Path to a JSON filter file OR an inline JSON array/object | `-f filter.json` |\n| `--or` | | Combine multiple filter groups with OR logic | `--or` |\n| `--method <methods>` | `-m` | Comma-separated list of HTTP methods | `-m GET,POST` |\n| `--url <patterns>` | `-u` | Comma-separated list of URL substrings/patterns to include | `-u /api/v1/` |\n| `--exclude-url <patterns>` | | Comma-separated list of URL substrings/patterns to exclude | `--exclude-url /health,/metrics` |\n| `--status <codes>` | `-s` | Comma-separated list of HTTP status codes | `-s 200,201` |\n| `--type <types>` | `-t` | Comma-separated list of resource types (`fetch`, `xhr`, `document`, `script`, etc.) | `-t xhr,fetch` |\n| `--response-type <mimes>` | | Comma-separated response MIME types | `--response-type application/json` |\n| `--has-response` | | Include only requests that received a response | `--has-response` |\n| `--is-error` | | Include only error requests (status >= 400 or no response) | `--is-error` |\n| `--help` | `-h` | Display the help menu | `-h` |\n\n---\n\n### CLI Examples\n\n**1. Basic conversion:**\n```bash\nhar-to-ts session.har src/api.ts\n```\n\n**2. Filter only API endpoints (GET & POST):**\n```bash\nhar-to-ts session.har src/api.ts --method GET,POST --type xhr,fetch\n```\n\n**3. Multiple filter rules using `--or`:**\n```bash\nhar-to-ts session.har src/api.ts --url /api/v1/users --method GET --or --url /api/v1/orders --method POST --type fetch\n```\n\n**4. Inline JSON array filter:**\n```bash\nhar-to-ts session.har src/api.ts --filter '[{\"url\":[\"/users\"],\"method\":[\"GET\"]},{\"url\":[\"/orders\"],\"method\":[\"POST\"]}]'\n```\n\n**5. Using a filter configuration file:**\n```bash\nhar-to-ts session.har src/api.ts --filter har-filter.json\n```\n\n---\n\n## Filter Configuration File (`har-filter.json`)\n\nYou can pass a JSON file containing an array of filter objects or a single filter object using `--filter`:\n\n```json\n[\n  {\n    \"url\": [\"/api/v1/\"],\n    \"excludeUrl\": [\"/health\", \"/metrics\"],\n    \"method\": [\"GET\", \"POST\", \"PUT\", \"DELETE\"],\n    \"type\": [\"fetch\", \"xhr\"],\n    \"responseType\": [\"application/json\"],\n    \"statusCode\": [200, 201]\n  }\n]\n```\n\n### Filter Options Reference\n\nWithin a filter object:\n- Properties use **AND** logic (e.g. must match `method` AND `url`).\n- Multiple filter objects in an array use **OR** logic (matches if any filter object matches).\n\n| Option | Type | Description |\n| :--- | :--- | :--- |\n| `url` | `(string \\| RegExp)[]` | Match if URL contains any of these substrings or regexes |\n| `excludeUrl` | `(string \\| RegExp)[]` | Exclude if URL contains any of these substrings or regexes |\n| `method` | `string[]` | Match HTTP methods (`\"GET\"`, `\"POST\"`, `\"PUT\"`, etc.) |\n| `statusCode` | `number[]` | Match specific HTTP status codes (`200`, `201`, `404`, etc.) |\n| `type` | `string[]` | Resource types (`\"fetch\"`, `\"xhr\"`, `\"document\"`, `\"script\"`, `\"image\"`, `\"stylesheet\"`, `\"font\"`) |\n| `requestHeaders` | `string[]` | Match if request contains any of these header names |\n| `responseHeaders`| `string[]` | Match if response contains any of these header names |\n| `responseType` | `(string \\| RegExp)[]` | Match response MIME type (e.g. `[\"application/json\"]`) |\n| `queryStringKeys`| `string[]` | Match if request contains any of these query parameter names |\n| `requestBodyMimeType` | `string[]` | Match request body MIME type |\n| `minTimeMs` | `number` | Minimum request latency in milliseconds |\n| `maxTimeMs` | `number` | Maximum request latency in milliseconds |\n| `hasResponse` | `boolean` | Include only requests with a valid response |\n| `isError` | `boolean` | Include only error requests (status >= 400 or no response) |\n\n---\n\n## Programmatic API\n\nYou can also use `har-to-ts` as a Node.js / TypeScript module in your own tools:\n\n```typescript\nimport { generateFromHar, filterHarFile, filterHarEntries } from \"@chahakshah/har-to-ts\";\n\n// Generate TypeScript SDK with filtering\nawait generateFromHar(\"session.har\", \"src/api.ts\", {\n  mergeTypes: true,\n  typePrefix: \"Api\",\n  filters: [\n    {\n      url: [\"/api/\"],\n      method: [\"GET\", \"POST\"],\n      type: [\"fetch\", \"xhr\"],\n      responseType: [\"application/json\"],\n    },\n  ],\n});\n\n// Or filter HAR files standalone:\nfilterHarFile(\n  \"session.har\",\n  [{ method: [\"GET\", \"POST\"] }],\n  \"filtered-session.har\"\n);\n```\n\n---\n\n## How to get a HAR file\n\n1. Open the website you want to generate an API client for in Google Chrome / Chromium.\n2. Open **Developer Tools** (`F12` or `Ctrl+Shift+I` / `Cmd+Option+I`) and click on the **Settings** gear icon.\n   \n   ![DevTools Settings](screenshots/image-1.png)\n\n3. Under Preferences / Network, check **Preserve log**, **Record network log**, and **Allow to generate HAR with sensitive data** (if authenticated requests are required).\n   \n   ![Network Preferences](screenshots/image-2.png)\n\n4. Clear the network log, refresh the page, interact with the website to trigger the API calls, and click the **Export HAR (Download)** icon in the Network tab.\n   \n   ![Export HAR](screenshots/image-3.png)\n\n---\n\n## License\n\n[MIT](LICENSE)\n","readmeFilename":"README.md"}