{"_id":"@berrydev-ai/retreaver-api-client","name":"@berrydev-ai/retreaver-api-client","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@berrydev-ai/retreaver-api-client","version":"0.1.0","publishConfig":{"access":"public"},"description":"TypeScript/JavaScript client for the Retreaver Core API - manage call tracking, routing, affiliates, campaigns, and more","author":{"name":"Retreaver"},"repository":{"type":"git","url":"git+https://github.com/berrydev-ai/retreaver-api-client.git"},"keywords":["retreaver","call-tracking","call-routing","api-client","axios","typescript","openapi-client"],"license":"MIT","main":"./dist/index.js","typings":"./dist/index.d.ts","module":"./dist/esm/index.js","sideEffects":false,"scripts":{"build":"tsc && tsc -p tsconfig.esm.json","prepare":"npm run build"},"dependencies":{"axios":"^1.6.1"},"devDependencies":{"@types/node":"12.11.5 - 12.20.42","typescript":"^4.0 || ^5.0"},"_id":"@berrydev-ai/retreaver-api-client@0.1.0","gitHead":"871df73a353026ca62ec452406a713e4fc9a9a12","bugs":{"url":"https://github.com/berrydev-ai/retreaver-api-client/issues"},"homepage":"https://github.com/berrydev-ai/retreaver-api-client#readme","_nodeVersion":"20.19.3","_npmVersion":"10.8.2","dist":{"integrity":"sha512-6ToBnNmpYx5/qkYET2uiO10+1RP1QF0xCylteYeAlkNK5EK/KTdA/oCeo10cp6+Fdr1ji1k/ZOpc5ndySIx1eg==","shasum":"1269a5ef1953534a043366cabe515c5806571a3b","tarball":"https://registry.npmjs.org/@berrydev-ai/retreaver-api-client/-/retreaver-api-client-0.1.0.tgz","fileCount":323,"unpackedSize":1001915,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDS4lL1q6Fdp16rgpMVojxId/J4SuP2Jtc8Ll+GVcAb0QIhAJDYEN2ZgVjFsm/qloTkNbKMCAEdwUpaRqkxnlfJxl08"}]},"_npmUser":{"name":"coderberry","email":"coderberry@gmail.com"},"directories":{},"maintainers":[{"name":"coderberry","email":"coderberry@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/retreaver-api-client_0.1.0_1759591397346_0.22768941444705826"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-04T15:23:17.254Z","0.1.0":"2025-10-04T15:23:17.544Z","modified":"2025-10-04T15:23:17.855Z"},"maintainers":[{"name":"coderberry","email":"coderberry@gmail.com"}],"description":"TypeScript/JavaScript client for the Retreaver Core API - manage call tracking, routing, affiliates, campaigns, and more","homepage":"https://github.com/berrydev-ai/retreaver-api-client#readme","keywords":["retreaver","call-tracking","call-routing","api-client","axios","typescript","openapi-client"],"repository":{"type":"git","url":"git+https://github.com/berrydev-ai/retreaver-api-client.git"},"author":{"name":"Retreaver"},"bugs":{"url":"https://github.com/berrydev-ai/retreaver-api-client/issues"},"license":"MIT","readme":"# Retreaver API Client\n\nTypeScript/JavaScript client library for the [Retreaver Core API](https://api.retreaver.com). This client provides type-safe access to all Retreaver API endpoints for managing call tracking, routing, affiliates, campaigns, targets, and more.\n\n## Features\n\n- 🎯 **Full TypeScript Support** - Complete type definitions for all API operations\n- 📦 **Multiple Module Formats** - CommonJS and ES Modules support\n- 🔐 **Secure Authentication** - Built-in API key authentication\n- 🚀 **Modern HTTP Client** - Uses Axios for reliable HTTP requests\n- 📝 **Comprehensive API Coverage** - All Retreaver Core API endpoints\n\n## Installation\n\n```bash\nnpm install retreaver-api-client\n```\n\n## Quick Start\n\n### Basic Usage\n\n```typescript\nimport { Configuration, CallsV2Api } from 'retreaver-api-client';\n\n// Configure the API client with your API key\nconst config = new Configuration({\n  apiKey: 'your_api_key_here'\n});\n\n// Create an API instance\nconst callsApi = new CallsV2Api(config);\n\n// Fetch recent calls\nconst calls = await callsApi.getCallsV2('your_api_key_here');\nconsole.log(calls.data);\n```\n\n### JavaScript (CommonJS)\n\n```javascript\nconst { Configuration, CallsV2Api } = require('retreaver-api-client');\n\nconst config = new Configuration({\n  apiKey: 'your_api_key_here'\n});\n\nconst callsApi = new CallsV2Api(config);\n\ncallsApi.getCallsV2('your_api_key_here')\n  .then(response => console.log(response.data))\n  .catch(error => console.error(error));\n```\n\n## Authentication\n\nAll API requests require an API key. You can obtain your API key from [https://retreaver.com/users/edit](https://retreaver.com/users/edit).\n\n**Security Warning:** Never expose your API key publicly! Store it securely using environment variables.\n\n```typescript\nconst config = new Configuration({\n  apiKey: process.env.RETREAVER_API_KEY\n});\n```\n\nIf you have access to multiple companies, you'll also need to pass the `company_id` parameter:\n\n```typescript\nconst calls = await callsApi.getCallsV2(\n  process.env.RETREAVER_API_KEY,\n  1234 // company_id\n);\n```\n\n## Usage Examples\n\n### Working with Calls\n\n#### Fetch Recent Calls (V2 API)\n\n```typescript\nimport { Configuration, CallsV2Api } from 'retreaver-api-client';\n\nconst config = new Configuration({ apiKey: process.env.RETREAVER_API_KEY });\nconst callsApi = new CallsV2Api(config);\n\n// Get calls with filters\nconst response = await callsApi.getCallsV2(\n  process.env.RETREAVER_API_KEY,\n  undefined, // company_id\n  '2024-01-01T00:00:00+00:00', // created_at_start\n  '2024-01-31T23:59:59+00:00', // created_at_end\n  'created_at', // sort_by\n  'desc', // order\n  undefined, // caller\n  undefined, // client_afid\n  undefined, // client_cid\n  undefined, // client_tid\n  undefined, // sub_id\n  true, // call_flow_events\n  1 // page\n);\n\nconsole.log(response.data);\n```\n\n#### Get a Specific Call by UUID\n\n```typescript\nconst callUuid = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890';\nconst response = await callsApi.getCallByUuidV2(\n  callUuid,\n  process.env.RETREAVER_API_KEY\n);\n\nconsole.log(response.data.call);\n```\n\n### Managing Affiliates\n\n```typescript\nimport { Configuration, AffiliatesApi } from 'retreaver-api-client';\n\nconst config = new Configuration({ apiKey: process.env.RETREAVER_API_KEY });\nconst affiliatesApi = new AffiliatesApi(config);\n\n// Get all affiliates\nconst affiliates = await affiliatesApi.getAffiliates(process.env.RETREAVER_API_KEY);\n\n// Create a new affiliate\nconst newAffiliate = await affiliatesApi.createAffiliate(\n  process.env.RETREAVER_API_KEY,\n  {\n    affiliate: {\n      afid: 'affiliate-123',\n      first_name: 'John',\n      last_name: 'Doe',\n      company_name: 'Acme Corp'\n    }\n  }\n);\n\n// Update an affiliate\nconst updated = await affiliatesApi.updateAffiliate(\n  'affiliate-123',\n  process.env.RETREAVER_API_KEY,\n  {\n    affiliate: {\n      company_name: 'Updated Company Name'\n    }\n  }\n);\n\n// Delete an affiliate\nawait affiliatesApi.deleteAffiliate('affiliate-123', process.env.RETREAVER_API_KEY);\n```\n\n### Managing Targets\n\n```typescript\nimport { Configuration, TargetsApi } from 'retreaver-api-client';\n\nconst config = new Configuration({ apiKey: process.env.RETREAVER_API_KEY });\nconst targetsApi = new TargetsApi(config);\n\n// Get all targets\nconst targets = await targetsApi.getTargets(process.env.RETREAVER_API_KEY);\n\n// Create a new target\nconst newTarget = await targetsApi.createTarget(\n  process.env.RETREAVER_API_KEY,\n  {\n    target: {\n      number: '+15551234567',\n      name: 'Sales Team',\n      priority: 1,\n      timeout_seconds: 30\n    }\n  }\n);\n\n// Update a target\nconst updatedTarget = await targetsApi.updateTarget(\n  12345, // target id\n  process.env.RETREAVER_API_KEY,\n  {\n    target: {\n      name: 'Updated Sales Team',\n      paused: false\n    }\n  }\n);\n\n// Reset target cap\nawait targetsApi.resetTargetCap(12345, process.env.RETREAVER_API_KEY);\n```\n\n### Managing Campaigns\n\n```typescript\nimport { Configuration, CampaignsApi } from 'retreaver-api-client';\n\nconst config = new Configuration({ apiKey: process.env.RETREAVER_API_KEY });\nconst campaignsApi = new CampaignsApi(config);\n\n// Get all campaigns\nconst campaigns = await campaignsApi.getCampaigns(process.env.RETREAVER_API_KEY);\n\n// Create a campaign\nconst newCampaign = await campaignsApi.createCampaign(\n  process.env.RETREAVER_API_KEY,\n  {\n    campaign: {\n      cid: 'campaign-123',\n      name: 'My Campaign',\n      record_calls: true,\n      message: 'Welcome to our service',\n      voice_gender: 'Female'\n    }\n  }\n);\n\n// Update a campaign\nconst updated = await campaignsApi.updateCampaign(\n  'campaign-123',\n  process.env.RETREAVER_API_KEY,\n  {\n    campaign: {\n      name: 'Updated Campaign Name',\n      dedupe_seconds: 300\n    }\n  }\n);\n```\n\n### Working with Numbers\n\n```typescript\nimport { Configuration, NumbersApi } from 'retreaver-api-client';\n\nconst config = new Configuration({ apiKey: process.env.RETREAVER_API_KEY });\nconst numbersApi = new NumbersApi(config);\n\n// Get all phone numbers\nconst numbers = await numbersApi.getNumbers(process.env.RETREAVER_API_KEY);\nconsole.log(numbers.data);\n```\n\n## API Reference\n\n### Available API Classes\n\n- **CallsApi** - V1 calls endpoint (legacy)\n- **CallsV2Api** - V2 calls endpoint with enhanced data\n- **AffiliatesApi** - Manage affiliates/publishers/sources\n- **TargetsApi** - Manage destination phone numbers for routing\n- **CampaignsApi** - Manage campaigns with routing and IVR settings\n- **NumbersApi** - View phone numbers routed to campaigns\n\n### API Endpoints\n\nAll URIs are relative to `https://api.retreaver.com`\n\n#### Calls API\n\n| Method | HTTP Request | Description |\n|--------|--------------|-------------|\n| `getCallsV1` | `GET /calls.json` | Get recent calls (V1) |\n| `getCallByUuidV1` | `GET /calls/{uuid}.json` | Get specific call by UUID (V1) |\n| `getCallsV2` | `GET /api/v2/calls.json` | Get recent calls (V2) |\n| `getCallByUuidV2` | `GET /api/v2/calls/{uuid}.json` | Get specific call by UUID (V2) |\n\n#### Affiliates API\n\n| Method | HTTP Request | Description |\n|--------|--------------|-------------|\n| `getAffiliates` | `GET /affiliates.json` | Get all affiliates |\n| `createAffiliate` | `POST /affiliates.json` | Create an affiliate |\n| `getAffiliateByAfid` | `GET /affiliates/afid/{afid}.json` | Get affiliate by AFID |\n| `updateAffiliate` | `PUT /affiliates/afid/{afid}.json` | Update an affiliate |\n| `deleteAffiliate` | `DELETE /affiliates/afid/{afid}.json` | Delete an affiliate |\n\n#### Targets API\n\n| Method | HTTP Request | Description |\n|--------|--------------|-------------|\n| `getTargets` | `GET /targets.json` | Get all targets |\n| `createTarget` | `POST /targets.json` | Create a target |\n| `getTargetById` | `GET /targets/{id}.json` | Get specific target |\n| `updateTarget` | `PUT /targets/{id}.json` | Update a target |\n| `deleteTarget` | `DELETE /targets/{id}.json` | Delete a target |\n| `resetTargetCap` | `POST /targets/{id}/reset_cap.json` | Reset target hard cap |\n\n#### Campaigns API\n\n| Method | HTTP Request | Description |\n|--------|--------------|-------------|\n| `getCampaigns` | `GET /campaigns.json` | Get all campaigns |\n| `createCampaign` | `POST /campaigns.json` | Create a campaign |\n| `getCampaignByCid` | `GET /campaigns/cid/{cid}.json` | Get campaign by CID |\n| `updateCampaign` | `PUT /campaigns/cid/{cid}.json` | Update a campaign |\n| `deleteCampaign` | `DELETE /campaigns/cid/{cid}.json` | Delete a campaign |\n\n#### Numbers API\n\n| Method | HTTP Request | Description |\n|--------|--------------|-------------|\n| `getNumbers` | `GET /numbers.json` | Get all numbers |\n\n## Pagination\n\nThe API returns 25 results per page. Use the `Link` HTTP header to navigate between pages:\n\n```typescript\nconst response = await callsApi.getCallsV2(\n  process.env.RETREAVER_API_KEY,\n  undefined,\n  undefined,\n  undefined,\n  'created_at',\n  'desc',\n  undefined,\n  undefined,\n  undefined,\n  undefined,\n  undefined,\n  false,\n  2 // page number\n);\n\n// Check Link header for next/prev URLs\nconsole.log(response.headers.link);\n```\n\n## Error Handling\n\n```typescript\nimport { AxiosError } from 'axios';\n\ntry {\n  const response = await callsApi.getCallsV2(process.env.RETREAVER_API_KEY);\n  console.log(response.data);\n} catch (error) {\n  if (error instanceof AxiosError) {\n    console.error('API Error:', error.response?.status);\n    console.error('Error Details:', error.response?.data);\n  } else {\n    console.error('Unexpected Error:', error);\n  }\n}\n```\n\n## Building from Source\n\n```bash\n# Clone the repository\ngit clone https://github.com/berrydev-ai/retreaver-api-client.git\ncd retreaver-api-client\n\n# Install dependencies\nnpm install\n\n# Build the project\nnpm run build\n```\n\nThis will generate:\n- CommonJS output in `dist/`\n- ES Modules output in `dist/esm/`\n\n## TypeScript Support\n\nThis library includes TypeScript definitions. The types are automatically resolved when you import the package:\n\n```typescript\nimport { CallV2, Campaign, Target } from 'retreaver-api-client';\n\nconst call: CallV2 = {\n  uuid: '...',\n  caller: '+15551234567',\n  // ... fully typed!\n};\n```\n\n## Requirements\n\n- Node.js 12.x or higher\n- TypeScript 4.x or 5.x (for TypeScript projects)\n\n## Dependencies\n\n- `axios` ^1.6.1\n\n## Support\n\n- [Retreaver Support](https://support.retreaver.com/)\n- [API Documentation](https://api.retreaver.com)\n\n## License\n\nMIT\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.","readmeFilename":"README.md","_rev":"1-321c3d0268d52b605caa6c13b3b54b53"}