{"_id":"@apirail/receiver-sdk","name":"@apirail/receiver-sdk","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@apirail/receiver-sdk","version":"0.1.0","description":"Receiver SDK for PoAPW - Proof of API-Work protocol. Register APIs and receive Cardano native token payments.","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","scripts":{"build":"tsc","prepublishOnly":"npm run build"},"keywords":["poapw","cardano","api","payment","blockchain","native-tokens","web3","cryptocurrency","ada","api-monetization","api-provider"],"author":"","license":"MIT","repository":{"type":"git","url":"git+https://github.com/poapw/poapw-sdk.git"},"homepage":"https://github.com/poapw/poapw-sdk#readme","bugs":{"url":"https://github.com/poapw/poapw-sdk/issues"},"engines":{"node":">=18.0.0"},"devDependencies":{"typescript":"^5.0.0"},"gitHead":"e8e844356443e478784b604fcf34f53c1123418c","_id":"@apirail/receiver-sdk@0.1.0","_nodeVersion":"25.5.0","_npmVersion":"11.8.0","dist":{"integrity":"sha512-NWSMo8rpGSMS2jfr4RMBYOTrFtbvao+vKa5kYHK00/CLJD0DnNljT2Y/v1UzQCf9hfruEIIxwNAkYsbZFtV27g==","shasum":"82b4393044ea9bce3e8cd0f0f09da7c1d89f40dd","tarball":"https://registry.npmjs.org/@apirail/receiver-sdk/-/receiver-sdk-0.1.0.tgz","fileCount":4,"unpackedSize":26067,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIF9QgeT7QacS+FWags8Qtiq2pjPc1BB3/KOmqHOkETJuAiBrI7mk4gmNXyiPlu25R+9W+V5LmoOdvOFNNWc+LGJvnQ=="}]},"_npmUser":{"name":"apirail","email":"jog@compucampus.de"},"directories":{},"maintainers":[{"name":"apirail","email":"jog@compucampus.de"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/receiver-sdk_0.1.0_1770295712282_0.10682640298857504"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-05T12:48:32.162Z","0.1.0":"2026-02-05T12:48:32.429Z","modified":"2026-02-05T12:48:32.628Z"},"maintainers":[{"name":"apirail","email":"jog@compucampus.de"}],"description":"Receiver SDK for PoAPW - Proof of API-Work protocol. Register APIs and receive Cardano native token payments.","homepage":"https://github.com/poapw/poapw-sdk#readme","keywords":["poapw","cardano","api","payment","blockchain","native-tokens","web3","cryptocurrency","ada","api-monetization","api-provider"],"repository":{"type":"git","url":"git+https://github.com/poapw/poapw-sdk.git"},"bugs":{"url":"https://github.com/poapw/poapw-sdk/issues"},"license":"MIT","readme":"# @apirail/receiver-sdk\n\nReceiver SDK for PoAPW (Proof of API-Work) - Register your APIs and earn Cardano native tokens for delivering results.\n\n## Installation\n\n```bash\nnpm install @apirail/receiver-sdk\n```\n\n## Quick Start\n\n```typescript\nimport { ReceiverSDK } from '@apirail/receiver-sdk';\n\nconst receiver = new ReceiverSDK({\n  baseUrl: 'https://your-poapw-server.com',\n  walletId: 'your-wallet-id',\n});\n\n// Register an API to earn tokens\nconst api = await receiver.registerApi({\n  name: 'My Weather API',\n  endpoint: 'https://api.myservice.com/weather',\n  method: 'GET',\n  basePrice: '5.00', // tokens per call\n});\n\n// Check your earnings\nconst earnings = await receiver.getEarnings();\nconsole.log('Total earned:', earnings.totalEarnings, 'tokens');\n```\n\n## Features\n\n- **API Registration**: Register your APIs with custom pricing\n- **Earnings Tracking**: Monitor your token earnings in real-time\n- **Analytics**: Get detailed stats on API usage and performance\n- **Type-safe**: Full TypeScript support with exported interfaces\n\n## Configuration\n\n```typescript\nconst receiver = new ReceiverSDK({\n  baseUrl: 'https://your-poapw-server.com',  // Required: PoAPW server URL\n  walletId: 'your-wallet-id',                 // Required: Your receiver wallet ID\n});\n```\n\n## API Reference\n\n### `registerApi(config: ApiRouteConfig): Promise<ApiRoute>`\n\nRegister a new API to earn tokens.\n\n```typescript\nconst api = await receiver.registerApi({\n  name: 'My API',\n  description: 'Does amazing things',\n  endpoint: 'https://api.example.com/endpoint',\n  method: 'POST',\n  basePrice: '10.00',\n  payloadMultiplier: '0.01', // Optional: extra charge per KB of payload\n  headers: { 'X-API-Key': 'secret' }, // Optional: headers to forward\n});\n```\n\n### `updateApi(apiId: string, updates: Partial<ApiRouteConfig>): Promise<ApiRoute>`\n\nUpdate an existing API configuration.\n\n```typescript\nawait receiver.updateApi('api-id', { basePrice: '15.00' });\n```\n\n### `deactivateApi(apiId: string): Promise<ApiRoute>`\n\nTemporarily disable an API.\n\n```typescript\nawait receiver.deactivateApi('api-id');\n```\n\n### `activateApi(apiId: string): Promise<ApiRoute>`\n\nRe-enable a disabled API.\n\n```typescript\nawait receiver.activateApi('api-id');\n```\n\n### `getMyApis(): Promise<ApiRoute[]>`\n\nList all your registered APIs.\n\n```typescript\nconst apis = await receiver.getMyApis();\n// [{ id, name, endpoint, basePrice, callCount, totalEarnings }]\n```\n\n### `getEarnings(): Promise<EarningsInfo>`\n\nGet your total earnings and per-API breakdown.\n\n```typescript\nconst earnings = await receiver.getEarnings();\n// { totalBalance, totalEarnings, apiStats: [{ apiId, name, earnings, calls }] }\n```\n\n### `getApiStats(apiId: string): Promise<ApiStats>`\n\nGet detailed statistics for a specific API.\n\n```typescript\nconst stats = await receiver.getApiStats('api-id');\n// { totalCalls, totalEarnings, successRate, avgResponseTime }\n```\n\n### `getRecentTransactions(limit?: number): Promise<TransactionInfo[]>`\n\nGet recent transactions for your APIs.\n\n```typescript\nconst txs = await receiver.getRecentTransactions(50);\n// [{ id, amount, status, httpStatusCode, responseTimeMs, createdAt }]\n```\n\n### `getWalletInfo(): Promise<WalletInfo>`\n\nGet your wallet information including balance and Cardano address.\n\n```typescript\nconst wallet = await receiver.getWalletInfo();\n// { id, name, balance, cardanoAddress }\n```\n\n## Payment Flow\n\n1. **Register API** - Set your endpoint and pricing\n2. **Payers Call** - Payers use your API through PoAPW\n3. **Off-chain Credits** - Earnings accumulate off-chain\n4. **Threshold Settlement** - Tokens settle on-chain when threshold reached\n5. **Receive Tokens** - Tokens appear in your Cardano wallet\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-b5ea33966472f549e6965fc1c6de52ca"}