From 62975b26147583028a62ebec7e47cb77ff5988e1 Mon Sep 17 00:00:00 2001 From: Roman Fasakhov Date: Fri, 26 May 2023 17:14:13 +0800 Subject: [PATCH] v0.4.0 --- README.md | 42 +++++++----------------------------------- package.json | 2 +- src/provider.ts | 7 +++---- 3 files changed, 11 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 6a30137..40d4fbf 100644 --- a/README.md +++ b/README.md @@ -16,13 +16,14 @@ yarn add @ankr.com/ankr.js #### 2. Initialize the provider +_Note: to use Advanced API for free starting from 29.05.2023 you have to register on the platform._ + +Get your individual endpoint here https://www.ankr.com/rpc/advanced-api and provide it to the `AnkrProvider` constructor. + ```javascript import { AnkrProvider } from '@ankr.com/ankr.js'; -const provider = new AnkrProvider(); - -// or if you have a premium account -const provider = new AnkrProvider('YOUR_API_KEY'); +const provider = new AnkrProvider('YOUR_ENDPOINT'); ``` #### 3. Use the provider and call one of the supported methods @@ -184,36 +185,7 @@ const currencies = async () => { }; ``` -#### `getTokenPriceHistory` - -Shows price history for provided token on specific chain -You can provide **only one param**: `fromTimestamp` or `toTimestamp`. Timestamps and intervals must be provided in seconds. -If a `fromTimestamp` is not supplied, the `interval` will be applied in reverse from `toTimestamp` -if no `toTimestamp` => take by period & limit -``` -fromTimestamp----|p1|----|p2|----|pN|----> -<----|pN|----|p2|----|p1|----toTimestamp -``` -Defaults: -defaultInterval - 24 hours -maxInterval - 365 days -maxLimit - 1000 (under testing) -defaultLimit - 100 (under testing) - -```javascript -const prices = async () => { - return await provider.getTokenPriceHistory({ - blockchain: "eth", - contractAddress: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", - fromTimestamp: 1667195581, - interval: 86400, // 24h - limit: 337 - }); -}; -``` - ### About API keys -For now, Ankr is offering _free_ access to these APIs with no request limits i.e. you don't need an API key at this time. - -Later on, these APIs will become a part of Ankr Protocol's [Premium Plan](https://www.ankr.com/protocol/plan/). +Ankr is offering _free_ access to Advanced API, however you have to register on Ankr platform to access it. +Get your individual endpoint here https://www.ankr.com/rpc/advanced-api. \ No newline at end of file diff --git a/package.json b/package.json index dc9f84d..3139cf2 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "blockchain", "sdk" ], - "version": "0.3.1", + "version": "0.4.0", "description": "Compact library for interacting with Ankr APIs.", "main": "./dist/index.js", "files": [ diff --git a/src/provider.ts b/src/provider.ts index 1bd9341..4a009f2 100644 --- a/src/provider.ts +++ b/src/provider.ts @@ -39,11 +39,10 @@ export class AnkrProvider { /** * Constructs an instance of AnkrProvider. - * @param apiKey The API key for authorization. - * @param endpoint Ankr Scan MultiChain RPC endpoint. + * @param endpoint Advanced API endpoint. Example: https://rpc.ankr.com/multichain/YOUR-TOKEN */ - constructor(apiKey: string = "", endpoint: string = "https://rpc.ankr.com/multichain/") { - this.url = endpoint + apiKey + constructor(endpoint: string) { + this.url = endpoint this.requestConfig = {headers: {'Content-Type': 'application/json'}}; this._nextId = 1 }