{"_id":"@acurast/oracle-service-sdk","_rev":"4-be1af24415549dd89821e369c60efe6f","name":"@acurast/oracle-service-sdk","dist-tags":{"latest":"1.1.3"},"versions":{"1.0.0":{"name":"@acurast/oracle-service-sdk","version":"1.0.0","keywords":["acurast","oracle","sdk"],"author":{"name":"Lorenzo Spoleti","email":"l.spoleti@papers.ch"},"license":"MIT","_id":"@acurast/oracle-service-sdk@1.0.0","maintainers":[{"name":"papers_ch","email":"contact@papers.ch"}],"dist":{"shasum":"82617fd52dec9f62bcc8c7eeb0869d021b780aac","tarball":"https://registry.npmjs.org/@acurast/oracle-service-sdk/-/oracle-service-sdk-1.0.0.tgz","fileCount":8,"integrity":"sha512-JRKEDR57V+W2OVsCJFedCdL0PP1ZR/b5f30yZnkHi/JSV86+7/HWsmsQqh05I4QIg9mv1RcyrQHaYfiohjE3ug==","signatures":[{"sig":"MEQCIDO5yobQrG0R7pKYX7G0Vs77rY+tSAZaxf08DaNE5OOgAiAlQeSKWbB64LDY+iZ2lcliw3L0Wl7UN7pVYzwP+YrU5w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":42930},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"0d10e94a1d80e75c5d1bca06db27c517f26fc31f","scripts":{"test":"yarn run ts-node ./test/test.ts","build":"tsc","prepublishOnly":"yarn build"},"_npmUser":{"name":"papers_ch","email":"contact@papers.ch"},"_npmVersion":"10.8.2","description":"The Acurast Oracle SDK is a TypeScript library that provides a simple interface to interact with the Acurast Oracle Service. It allows developers to fetch price data for various cryptocurrency pairs, with signatures from multiple oracles.","directories":{},"_nodeVersion":"20.17.0","dependencies":{"ws":"^8.18.0","uuid":"^10.0.0","buffer":"^6.0.3","elliptic":"^6.5.6","typescript":"^5.5.4","@types/node":"^22.2.0","@types/uuid":"^10.0.0","@acurast/dapp":"^1.0.1-beta.6"},"_hasShrinkwrap":false,"devDependencies":{"ts-node":"^10.9.2","@types/elliptic":"^6.4.18"},"_npmOperationalInternal":{"tmp":"tmp/oracle-service-sdk_1.0.0_1726053369096_0.5086485360556465","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@acurast/oracle-service-sdk","version":"1.1.0","keywords":["acurast","oracle","sdk"],"author":{"name":"Lorenzo Spoleti","email":"l.spoleti@papers.ch"},"license":"MIT","_id":"@acurast/oracle-service-sdk@1.1.0","maintainers":[{"name":"papers_ch","email":"contact@papers.ch"}],"dist":{"shasum":"1a905911a9663141ff3ad247dafd22146db0a1f7","tarball":"https://registry.npmjs.org/@acurast/oracle-service-sdk/-/oracle-service-sdk-1.1.0.tgz","fileCount":8,"integrity":"sha512-XTzLiRo/VNQh8i2DyU+BH1gxHHCvP1QFOeJ1a5LJRROahdb7OSPSqQus99pq3QstghcL3Sh2JHP2nr53ZvLvxw==","signatures":[{"sig":"MEUCIQDKZc4gFHea7f5LXly4+wH+K1BVvBbVXt39RI2Hf8pXWAIgUdRownvVjhpmyVr0uq097AyQL7pbslN93375bgnmNrc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":45892},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"e6fec983903a2d7682e99fabdd03775d4f6901fc","scripts":{"test":"yarn run ts-node ./test/test.ts","build":"tsc","prepublishOnly":"yarn build"},"_npmUser":{"name":"papers_ch","email":"contact@papers.ch"},"_npmVersion":"10.8.2","description":"The Acurast Oracle SDK is a TypeScript library that provides a simple interface to interact with the Acurast Oracle Service. It allows developers to fetch price data for various cryptocurrency pairs, with signatures from multiple oracles.","directories":{},"_nodeVersion":"20.17.0","dependencies":{"ws":"^8.18.0","uuid":"^10.0.0","buffer":"^6.0.3","elliptic":"^6.5.6","typescript":"^5.5.4","@types/node":"^22.2.0","@types/uuid":"^10.0.0","@acurast/dapp":"^1.0.1-beta.6"},"_hasShrinkwrap":false,"devDependencies":{"ts-node":"^10.9.2","@types/elliptic":"^6.4.18"},"_npmOperationalInternal":{"tmp":"tmp/oracle-service-sdk_1.1.0_1726230402126_0.7926241079017975","host":"s3://npm-registry-packages"}},"1.1.1":{"name":"@acurast/oracle-service-sdk","version":"1.1.1","keywords":["acurast","oracle","sdk"],"author":{"name":"Lorenzo Spoleti","email":"l.spoleti@papers.ch"},"license":"MIT","_id":"@acurast/oracle-service-sdk@1.1.1","maintainers":[{"name":"papers_ch","email":"contact@papers.ch"}],"dist":{"shasum":"d86e57f7d87e3a442fe6be285211ac156881bc42","tarball":"https://registry.npmjs.org/@acurast/oracle-service-sdk/-/oracle-service-sdk-1.1.1.tgz","fileCount":8,"integrity":"sha512-BEn3aJMACxJQk0573jIm1P1i7IRLO/LjvLS5mA252Q1vZxo5QAQyQGypt3I2W5hZh8C3dcZCL2I8Ee7iPoicNQ==","signatures":[{"sig":"MEYCIQDZbRTpDZ7h5Moat4ZFK/0dhs+HPW+9KJNZmv5PHMaEawIhAIp4JPVQcXtqKZCZ3nbjXpTdieoO9fYjEbcQfM/F9Qt9","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":45892},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"a648273af51a195aa0ecb1f9738eb9ba2378e7c7","scripts":{"test":"yarn run ts-node ./test/test.ts","build":"tsc","prepublishOnly":"yarn build"},"_npmUser":{"name":"papers_ch","email":"contact@papers.ch"},"_npmVersion":"10.8.2","description":"The Acurast Oracle SDK is a TypeScript library that provides a simple interface to interact with the Acurast Oracle Service. It allows developers to fetch price data for various cryptocurrency pairs, with signatures from multiple oracles.","directories":{},"_nodeVersion":"20.17.0","dependencies":{"ws":"^8.18.0","uuid":"^10.0.0","buffer":"^6.0.3","elliptic":"^6.5.6","typescript":"^5.5.4","@types/node":"^22.2.0","@types/uuid":"^10.0.0","@acurast/dapp":"^1.0.1-beta.6"},"_hasShrinkwrap":false,"devDependencies":{"ts-node":"^10.9.2","@types/elliptic":"^6.4.18"},"_npmOperationalInternal":{"tmp":"tmp/oracle-service-sdk_1.1.1_1726234634428_0.7177464085375556","host":"s3://npm-registry-packages"}},"1.1.2":{"name":"@acurast/oracle-service-sdk","version":"1.1.2","keywords":["acurast","oracle","sdk"],"author":{"name":"Lorenzo Spoleti","email":"l.spoleti@papers.ch"},"license":"MIT","_id":"@acurast/oracle-service-sdk@1.1.2","maintainers":[{"name":"papers_ch","email":"contact@papers.ch"}],"dist":{"shasum":"c7b15e79cb26010f6546ef7a08321da35aa961b0","tarball":"https://registry.npmjs.org/@acurast/oracle-service-sdk/-/oracle-service-sdk-1.1.2.tgz","fileCount":8,"integrity":"sha512-kRBUFXAvx+95u6s+uBSc8t8rNuvuBHrNBHyaBc3pH6Hv3Ve4x1Q1mDcGKQacST6epFibExLtT9qJeAm3ozK30A==","signatures":[{"sig":"MEUCIQCOuAfzjCvL3EgSJWVt5lN8Zlrg6IrwQgdizXQ0RBqXmAIgdEZNvbtalqgAlqFTqZMTITGsm0Pnsu8dzSbnCFnk/bk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":48942},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"50e0d94ca4b85c57c4cacb3c83bf67a908d850a6","scripts":{"test":"yarn run ts-node ./test/test.ts","build":"tsc","prepublishOnly":"yarn build"},"_npmUser":{"name":"papers_ch","email":"contact@papers.ch"},"_npmVersion":"10.8.2","description":"The Acurast Oracle SDK is a TypeScript library that provides a simple interface to interact with the Acurast Oracle Service. It allows developers to fetch price data for various cryptocurrency pairs, with signatures from multiple oracles.","directories":{},"_nodeVersion":"20.17.0","dependencies":{"ws":"^8.18.0","uuid":"^10.0.0","buffer":"^6.0.3","elliptic":"^6.5.6","typescript":"^5.5.4","@types/node":"^22.2.0","@types/uuid":"^10.0.0","@acurast/dapp":"^1.0.1-beta.6"},"_hasShrinkwrap":false,"devDependencies":{"ts-node":"^10.9.2","@types/elliptic":"^6.4.18"},"_npmOperationalInternal":{"tmp":"tmp/oracle-service-sdk_1.1.2_1726498547659_0.7662683719316596","host":"s3://npm-registry-packages"}},"1.1.3":{"name":"@acurast/oracle-service-sdk","version":"1.1.3","author":{"name":"Lorenzo Spoleti","email":"l.spoleti@papers.ch"},"license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","test":"yarn run ts-node ./test/test.ts","prepublishOnly":"yarn build"},"keywords":["acurast","oracle","sdk"],"dependencies":{"@acurast/dapp":"^1.0.1-beta.6","@types/node":"^22.2.0","@types/uuid":"^10.0.0","buffer":"^6.0.3","elliptic":"^6.5.6","typescript":"^5.5.4","uuid":"^10.0.0","ws":"^8.18.0"},"devDependencies":{"@types/elliptic":"^6.4.18","ts-node":"^10.9.2"},"_id":"@acurast/oracle-service-sdk@1.1.3","gitHead":"c2a296fadf486c4f648f26bef96cd545c0b2f905","description":"The Acurast Oracle SDK is a TypeScript library that provides a simple interface to interact with the Acurast Oracle Service. It allows developers to fetch price data for various cryptocurrency pairs, with signatures from multiple oracles.","_nodeVersion":"20.17.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-y0U8iPIMU8MsdnwHLagrhGE6bAvgjHER0+VpFo3DR7Fkc8tPbbPgnzHp0LDJOf+k4c5COQAyLNqdnmiL10j0YA==","shasum":"bda6ff72aae5f9e31735c85b81e89ca2b07270cd","tarball":"https://registry.npmjs.org/@acurast/oracle-service-sdk/-/oracle-service-sdk-1.1.3.tgz","fileCount":8,"unpackedSize":49743,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDkVKQdMDa2xDjbgH6PaxSejWto78swWzQfByWlu/j4iAiEAwhIz4ufn7Qo6TcKoBQG4M3ufQnPZE1m78m/PxbmS/W8="}]},"_npmUser":{"name":"papers_ch","email":"contact@papers.ch"},"directories":{},"maintainers":[{"name":"papers_ch","email":"contact@papers.ch"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/oracle-service-sdk_1.1.3_1726501287960_0.4643234465763415"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-11T11:16:09.012Z","modified":"2024-09-16T15:41:28.295Z","1.0.0":"2024-09-11T11:16:09.287Z","1.1.0":"2024-09-13T12:26:42.289Z","1.1.1":"2024-09-13T13:37:14.576Z","1.1.2":"2024-09-16T14:55:47.808Z","1.1.3":"2024-09-16T15:41:28.130Z"},"author":{"name":"Lorenzo Spoleti","email":"l.spoleti@papers.ch"},"license":"MIT","keywords":["acurast","oracle","sdk"],"description":"The Acurast Oracle SDK is a TypeScript library that provides a simple interface to interact with the Acurast Oracle Service. It allows developers to fetch price data for various cryptocurrency pairs, with signatures from multiple oracles.","maintainers":[{"name":"papers_ch","email":"contact@papers.ch"}],"readme":"# Acurast Oracle SDK\n\nThe Acurast Oracle SDK is a TypeScript library that provides a simple interface to interact with the Acurast Oracle Service. It allows developers to fetch price data for various cryptocurrency pairs, with signatures from multiple oracles.\n\n## Features\n\n- Fetch price data for multiple cryptocurrency pairs\n- Verify price data across multiple oracles\n- Check the health status of supported exchanges\n- Support for different blockchain protocols (Substrate, EVM, WASM, Tezos)\n\n## Installation\n\nTo install the Acurast Oracle SDK, use yarn:\n\n```bash\nyarn add acurast-oracle-service-sdk\n```\n\n## Usage\n\n### Initializing the SDK\n\nFirst, import and initialize the AcurastOracleSDK:\n\n```typescript\nimport { AcurastOracleSDK } from \"acurast-oracle-sdk\"\n\nconst sdk = new AcurastOracleSDK({\n  timeout: 5000, // (optional) default 10 seconds\n  logging: true, // (optional) default false\n  errorThreshold: 0.333, // (optional) default 0.333\n})\n```\n\n### Fetching Price Data\n\nTo fetch price data for cryptocurrency pairs:\n\n```typescript\nconst fetchPricesParams = {\n  pairs: [\n    { from: \"BTC\", to: \"USDT\" },\n    { from: \"ETH\", to: \"USDT\" },\n  ],\n  protocol: \"EVM\",\n  aggregation: \"median\",\n}\n\ntry {\n  const priceData = await sdk.getPrices(fetchPricesParams, 2) // Require 2 verifications\n  console.log(\"Price data:\", priceData)\n} catch (error) {\n  console.error(\"Error fetching prices:\", error)\n}\n```\n\n### Checking Exchange Health\n\nTo check the health status of supported exchanges:\n\n```typescript\ntry {\n  const exchanges = await sdk.getExchanges()\n  console.log(\"Available exchanges:\", exchanges)\n} catch (error) {\n  console.error(\"Error checking exchange health:\", error)\n}\n```\n\n### Closing the Connection\n\nWhen you're done using the SDK, close the connection:\n\n```typescript\nawait sdk.close()\n```\n\n## Response Examples\n\n### getPrices Response\n\n```typescript\n;[\n  {\n    priceData: {\n      from: \"BTC\",\n      to: \"USDT\",\n      decimals: 8,\n      price: 5000000000000,\n      timestamp: 1629300000000,\n      sources: [\n        { exchangeId: \"BNC\", certificate: \"cert1\" },\n        { exchangeId: \"CBP\", certificate: \"cert2\" },\n      ],\n      requestHash: \"0x1234567890abcdef\",\n    },\n    packed: [\"packed_data_1\", \"packed_data_2\"],\n    signatures: [\"signature1\", \"signature2\"],\n    pubKeys: [\"pubKey1\", \"pubKey2\"],\n  },\n  {\n    priceData: {\n      from: \"ETH\",\n      to: \"USDT\",\n      decimals: 8,\n      price: 300000000000,\n      timestamp: 1629300000000,\n      sources: [\n        { exchangeId: \"BNC\", certificate: \"cert1\" },\n        { exchangeId: \"CBP\", certificate: \"cert2\" },\n      ],\n      requestHash: \"0x1234567890abcdef\",\n    },\n    packed: [\"packed_data_3\", \"packed_data_4\"],\n    signatures: [\"signature3\", \"signature4\"],\n    pubKeys: [\"pubKey1\", \"pubKey2\"],\n  },\n]\n```\n\n### getExchanges Response\n\n```typescript\n;[\"BNC\", \"CBP\", \"BFX\", \"KRK\", \"GEM\"]\n```\n\n## Description\n\n### `AcurastOracleSDK`\n\n#### Constructor\n\n```typescript\nconstructor(options: AcurastOracleSDKOptions)\n```\n\n- `options.wssUrls`: (Optional) Array of WebSocket URLs to connect to the Acurast processors.\n- `options.oracles`: (Optional) Array of processor public keys. These have to be public keys of processors that are running the AcurastOracleService. By default it will use the public keys from the AcurastOracleService.\n- `options.timeout`: (Optional) Timeout in milliseconds for the requests. Default: 10 seconds.\n- `options.logging`: (Optional) Enable or disable logs. Default: false.\n- `options.errorThreshold`: (Optional) Value from 0 to 1 that determines the percentage of oracles that have to respond with the same error for it to be thrown by the sdk. Default: 0.333.\n\n#### Methods\n\n##### `getPrices(params: FetchPricesParams, verifications: number = 0): Promise<GetPricesResult[]>`\n\nFetches price data from the oracle network.\n\n- `params`: The parameters for fetching prices. It includes:\n  - `pairs`: Array of Pairs, Pairs to fetch prices for:\n    - `from`: String, from symbol.\n    - `to`: String, to symbol.\n    - `decimals`: Number of decimals for the price.\n    - `price`: (Optional) Price(s) to verify against the oracle price. (Provide a price per aggregatyion type requested)\n    - `timestamp`: (Optional) Number, timestamp of the provided prices.\n  - `protocol`: Protocol to package and sign the price data for.\n  - `exchanges`: (Optional) List of exchange IDs to use as sources on the oracles. Default: all available exchanges.\n  - `minSources`: (Optional) Minimum number of sources required. Default: 3.\n  - `tradeAgeLimit`: (Optional) Maximum age of trade data in seconds. Default: 5 minutes.\n  - `aggregation`: (Optional) Types of price aggregation requested from the oracles. Default: mean.\n  - `maxSourcesDeviation`: (Optional) Maximum allowed standard deviation between prices in the sources. Default: no limit.\n  - `maxValidationDiff`: (Optional) Maximum allowed price difference for validation against client. Default: 0.05%.\n- `verifications`: The number of verifications required. Default: 0.\n\n### getPrices Response\n\n`GetPricesResult[]`\nEach object contains the following properties:\n\n1. `priceData`:\n\n   - `from`: String - From symbol.\n   - `to`: String - To symbol.\n   - `decimals`: Number of decimals for the price.\n   - `price`: Number or Number[] - Aggregated price(s).\n   - `timestamp`: Number - Timestamp of the price data in ms.\n   - `sources`: Array of Objects - Map exchangeID to the certificate for sources used.\n     - `exchangeId`: String - The unique identifier of the exchange.\n     - `certificate`: String - The API certificate.\n   - `requestHash`: String - Hash of the original request parameters.\n\n2. `packed`: String[] - Price data in the packed format for the chosen protocol.\n\n3. `signatures`: String[] - Oracle signatures.\n\n4. `pubKeys`: String[] - Oracle public keys.\n\n##### `getExchanges(params?: CheckExchangeHealthParams, requiredResponses: number = 0): Promise<string[]>`\n\nRetrieves a list of available exchanges.\n\n- `params`: (Optional) The parameters for checking exchange health. It includes:\n  - `exchanges`: (Optional) List of exchange IDs to check. Default: all available exchanges.\n- `requiredResponses`: (Optional) The number of required responses from the oracles. Default: 0.\n\n##### `close(): Promise<void>`\n\nCloses the WebSocket connection.\n\n#### Exchange ID table\n\n| Exchange ID | Exchange Name |\n| ----------- | ------------- |\n| BNU         | Binance US    |\n| BNC         | Binance       |\n| CBP         | Coinbase      |\n| BFX         | Bitfinex      |\n| KRK         | Kraken        |\n| BYB         | Bybit         |\n| GEM         | Gemini        |\n| KUC         | Kucoin        |\n| GIO         | Gate IO       |\n| CRY         | Crypto.com    |\n| HTX         | HTX           |\n| MEXC        | MEXC          |\n| WBIT        | Whitebit      |\n| OKX         | OKX           |\n| UPB         | Upbit         |\n\n## License\n\nThis project is licensed under the MIT License.\n","readmeFilename":"README.md"}