{"_id":"@buywhere/sdk","name":"@buywhere/sdk","dist-tags":{"latest":"0.2.0"},"versions":{"0.2.0":{"name":"@buywhere/sdk","version":"0.2.0","description":"Official BuyWhere SDK for product search, price comparison, and deals","type":"module","main":"dist/index.cjs","module":"dist/index.js","types":"dist/index.d.ts","browser":"dist/index.global.js","exports":{".":{"types":"./dist/index.d.ts","browser":"./dist/index.global.js","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsup src/index.ts --format cjs,esm,iife --dts --clean","build:tsc":"tsc --outDir dist --moduleResolution node --esModuleInterop --target es2020 src/index.ts && tsc --outDir dist --declaration --emitDeclarationOnly --declarationMap src/index.ts","dev":"tsup src/index.ts --format cjs,esm --dts --watch","lint":"eslint src/","test":"npm run typecheck && npm run build && node --test tests/**/*.test.mjs","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"keywords":["buywhere","product-search","price-comparison","deals","shopping","agent-sdk"],"author":{"name":"BuyWhere"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/buywhere/buywhere-site.git","directory":"packages/buywhere-sdk"},"homepage":"https://buywhere.ai","bugs":{"url":"https://github.com/buywhere/buywhere-site/issues"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"peerDependencies":{"typescript":"^5.0.0"},"devDependencies":{"@types/node":"^20.0.0","eslint":"^8.0.0","tsup":"^8.0.0","typescript":"^5.0.0"},"_id":"@buywhere/sdk@0.2.0","gitHead":"44b0381ea28a247a8da19a4b87a45f3842dda1bd","_nodeVersion":"22.22.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-KMO931vNFo2PyuJ9vNfHPbPVxAGsZgR+sl/XNfuURd5JkOj/dbBh9igzgJd+L0vli+9Xhqdg7idlGhVInp/5FA==","shasum":"03fbab67fece280ad98e6480f4825833dc27eb2b","tarball":"https://registry.npmjs.org/@buywhere/sdk/-/sdk-0.2.0.tgz","fileCount":10,"unpackedSize":695028,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIC5jqMvWV+1IULKl4qVeu4tfBtEQhRZd3McA//3X0YFHAiEAuG0Tnc4deHVoHHPPWw9GKDdPrcCfHYZ3ZD3WNGXA4as="}]},"_npmUser":{"name":"richieboyz18","email":"richmond.teo@gmail.com"},"directories":{},"maintainers":[{"name":"richieboyz18","email":"richmond.teo@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.2.0_1777376737208_0.7302011355159757"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-28T11:45:37.113Z","0.2.0":"2026-04-28T11:45:37.364Z","modified":"2026-04-28T11:45:37.684Z"},"maintainers":[{"name":"richieboyz18","email":"richmond.teo@gmail.com"}],"description":"Official BuyWhere SDK for product search, price comparison, and deals","homepage":"https://buywhere.ai","keywords":["buywhere","product-search","price-comparison","deals","shopping","agent-sdk"],"repository":{"type":"git","url":"git+https://github.com/buywhere/buywhere-site.git","directory":"packages/buywhere-sdk"},"author":{"name":"BuyWhere"},"bugs":{"url":"https://github.com/buywhere/buywhere-site/issues"},"license":"MIT","readme":"# @buywhere/sdk\n\nOfficial TypeScript/JavaScript SDK for BuyWhere product search, compare, price history, key rotation, and webhooks.\n\n## Installation\n\n```bash\nnpm install @buywhere/sdk\n```\n\n## Quick start\n\n```ts\nimport { createClient } from '@buywhere/sdk';\n\nconst client = createClient('bw_live_your_api_key');\n\nconst results = await client.search.search('wireless headphones', {\n  country: 'US',\n  limit: 5,\n});\n\nconst comparison = await client.compare(['sku_123', 'sku_456']);\nconst history = await client.priceHistory('sku_123', {\n  limit: 30,\n  since: '2026-01-01T00:00:00Z',\n});\n\nconst webhook = await client.webhooks.create(\n  'https://example.com/webhooks/buywhere',\n  ['price_drop', 'product_update'],\n);\n\nconsole.log(results.items.length, comparison.products.length, history.price_history.length, webhook.id);\n```\n\n## Configuration\n\n```ts\nimport { BuyWhereSDK } from '@buywhere/sdk';\n\nconst client = new BuyWhereSDK({\n  apiKey: 'bw_live_your_api_key',\n  baseUrl: 'https://api.buywhere.ai',\n  timeout: 30000,\n  defaultCurrency: 'USD',\n  defaultCountry: 'US',\n  retry: {\n    maxRetries: 3,\n    initialDelayMs: 1000,\n    maxDelayMs: 10000,\n    backoffMultiplier: 2,\n  },\n});\n```\n\n## v0.2.0 methods\n\n```ts\nimport type {\n  CompareResponse,\n  PriceHistoryResponse,\n  RotateApiKeyResponse,\n  Webhook,\n} from '@buywhere/sdk';\n\nconst client = createClient('bw_live_your_api_key');\n\nconst compareResult: CompareResponse = await client.compare(['sku_123', 'sku_456']);\n\nconst historyResult: PriceHistoryResponse = await client.priceHistory('sku_123', {\n  limit: 14,\n  since: '2026-04-01T00:00:00Z',\n});\n\nconst rotation: RotateApiKeyResponse = await client.rotateApiKey();\n\nconst createdWebhook = await client.webhooks.create(\n  'https://example.com/webhooks/buywhere',\n  ['price_drop'],\n);\n\nconst webhooks: Webhook[] = await client.webhooks.list();\nawait client.webhooks.delete(createdWebhook.id);\n```\n\nThe existing namespaced helpers still work:\n\n```ts\nconst categoryComparison = await client.compare.compareByCategory('electronics');\nconst product = await client.products.getProduct(12345);\nconst deals = await client.deals.getDeals({ country: 'US', limit: 10 });\n```\n\n## Error handling\n\n```ts\nimport { BuyWhereError, createClient } from '@buywhere/sdk';\n\nconst client = createClient('bw_live_your_api_key');\n\ntry {\n  await client.compare(['sku_123', 'sku_456']);\n} catch (error) {\n  if (error instanceof BuyWhereError) {\n    console.error(error.statusCode);\n    console.error(error.errorCode);\n    console.error(error.requestId);\n    console.error(error.message);\n  }\n}\n```\n\n`BuyWhereError` normalizes the API error payload into:\n\n- `statusCode`\n- `errorCode`\n- `requestId`\n- `message`\n\n## Module formats\n\nThe package ships dual ESM + CJS builds with typed exports:\n\n```ts\nimport { createClient } from '@buywhere/sdk';\n```\n\n```js\nconst { createClient } = require('@buywhere/sdk');\n```\n\n## Development\n\n```bash\nnpm run build\nnpm test\n```\n","readmeFilename":"README.md","_rev":"1-459e476babe89b1c2cc505b1db0b41f1"}