@@ -13,18 +13,27 @@ pip install ankr-sdk
1313#### 2. Initialize the SDK
1414
1515``` python3
16- from ankr import AnkrAdvancedAPI, types
16+ from ankr import AnkrWeb3
1717
18- ankr_api = AnkrAdvancedAPI ()
18+ ankr_w3 = AnkrWeb3 ()
1919```
2020
2121#### 3. Use the sdk and call one of the supported methods
2222
23+ #### Node's API
2324``` python3
24- from ankr.types import BlockchainName
25+ eth_block = ankr_w3.eth.get_block(" latest" )
26+ bsc_block = ankr_w3.bsc.get_block(" latest" )
27+ polygon_block = ankr_w3.polygon.get_block(" latest" )
28+ ```
29+
30+ #### Ankr NFT API: get all addresses' NFTs
2531
26- nfts = ankr_api.get_nfts(
27- blockchain = BlockchainName.ETH ,
32+ ``` python3
33+ from ankr.types import Blockchain
34+
35+ nfts = ankr_w3.nft.get_nfts(
36+ blockchain = [Blockchain.ETH , Blockchain.BSC ],
2837 wallet_address = " 0x0E11A192d574b342C51be9e306694C41547185DD" ,
2938 filter = [
3039 {" 0x700b4b9f39bb1faf5d0d16a20488f2733550bff4" : []},
@@ -33,7 +42,29 @@ nfts = ankr_api.get_nfts(
3342)
3443```
3544
36- ## Supported chains
45+ #### Ankr Token API: get all wallet's tokens on every supported chain
46+ ``` python3
47+ assets = ankr_w3.token.get_account_balance(
48+ wallet_address = " 0x77A859A53D4de24bBC0CC80dD93Fbe391Df45527"
49+ )
50+ ```
51+
52+ #### Ankr Query API: search for logs without range limits
53+ ``` python3
54+ logs = ankr_w3.query.get_logs(
55+ blockchain = " eth" ,
56+ from_block = " 0xdaf6b1" ,
57+ to_block = 14350010 ,
58+ address = [" 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" ],
59+ topics = [
60+ [],
61+ [" 0x000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff" ],
62+ ],
63+ decode_logs = True ,
64+ )
65+ ```
66+
67+ ## Ankr Advanced APIs supported chains
3768
3869` ankr-sdk ` supports the following chains at this time:
3970
@@ -49,16 +80,95 @@ nfts = ankr_api.get_nfts(
4980
5081` ankr-sdk ` supports the following methods:
5182
52- - [ ` get_nfts ` ] ( #get_nfts )
53- - [ ` get_logs ` ] ( #get_logs )
54- - [ ` get_blocks ` ] ( #get_blocks )
83+ - [ ` nft.get_nfts ` ] ( #get_nfts )
84+ - [ ` nft.get_nft_metadata ` ] ( #get_nft_metadata )
85+ - [ ` token.get_token_holders ` ] ( #get_token_holders )
86+ - [ ` token.get_token_holders_count_history ` ] ( #get_token_holders_count_history )
87+ - [ ` token.get_token_holders_count ` ] ( #get_token_holders_count )
88+ - [ ` token.get_account_balance ` ] ( #get_account_balance )
89+ - [ ` query.get_logs ` ] ( #get_logs )
90+ - [ ` query.get_blocks ` ] ( #get_blocks )
91+ - [ ` query.get_transaction ` ] ( #get_transaction )
92+
93+ #### ` get_nfts `
94+
95+ Get data about all the NFTs (collectibles) owned by a wallet.
96+
97+ ```` python3
98+ nfts = ankr_w3.nft.get_nfts(
99+ blockchain = " eth" ,
100+ wallet_address = " 0x0E11A192d574b342C51be9e306694C41547185DD" ,
101+ filter = [
102+ {" 0x700b4b9f39bb1faf5d0d16a20488f2733550bff4" : []},
103+ {" 0xd8682bfa6918b0174f287b888e765b9a1b4dc9c3" : [" 8937" ]},
104+ ],
105+ )
106+ ````
107+
108+ #### ` get_nft_metadata `
109+
110+ Get metadata of NFT.
111+
112+ ```` python3
113+ nfts = ankr_w3.nft.get_nft_metadata(
114+ blockchain = " eth" ,
115+ contract_address = " 0x4100670ee2f8aef6c47a4ed13c7f246e621228ec" ,
116+ token_id = " 4" ,
117+ )
118+ ````
119+
120+ #### ` get_token_holders `
121+
122+ Get holders of a token.
123+
124+ ```` python3
125+ holders = ankr_w3.token.get_token_holders(
126+ blockchain = " bsc" ,
127+ contract_address = " 0xf307910A4c7bbc79691fD374889b36d8531B08e3" ,
128+ limit = 10 ,
129+ )
130+ ````
131+
132+ #### ` get_token_holders_count_history `
133+
134+ Get token holders count daily history.
135+
136+ ```` python3
137+ daily_holders_history = ankr_w3.token..get_token_holders_count_history(
138+ blockchain = " bsc" ,
139+ contract_address = " 0xf307910A4c7bbc79691fD374889b36d8531B08e3" ,
140+ limit = 10 , # last 10 days history
141+ )
142+ ````
143+
144+ #### ` get_token_holders_count `
145+
146+ Get token holders count at the latest block.
147+
148+ ```` python3
149+ holders_count = ankr_w3.token..get_token_holders_count(
150+ blockchain = " bsc" ,
151+ contract_address = " 0xf307910A4c7bbc79691fD374889b36d8531B08e3" ,
152+ )
153+ ````
154+
155+ #### ` get_account_balance `
156+
157+ Get account assets.
158+
159+ ```` python3
160+ assets = ankr_w3.token..get_account_balance(
161+ wallet_address = " 0x77A859A53D4de24bBC0CC80dD93Fbe391Df45527" ,
162+ blockchain = [" eth" , " bsc" ],
163+ )
164+ ````
55165
56166#### ` get_logs `
57167
58168Get logs matching the filter.
59169
60170``` python3
61- logs = ankr_api .get_logs(
171+ logs = ankr_w3.query .get_logs(
62172 blockchain = " eth" ,
63173 from_block = " 0xdaf6b1" ,
64174 to_block = 14350010 ,
@@ -76,7 +186,7 @@ logs = ankr_api.get_logs(
76186Query data about blocks within a specified range.
77187
78188``` python3
79- blocks = ankr_api .get_blocks(
189+ blocks = ankr_w3.query .get_blocks(
80190 blockchain = " eth" ,
81191 from_block = 14500001 ,
82192 to_block = 14500001 ,
@@ -87,24 +197,23 @@ blocks = ankr_api.get_blocks(
87197)
88198```
89199
90- #### ` get_nfts `
200+ #### ` get_transaction `
91201
92- Get data about all the NFTs (collectibles) owned by a wallet .
202+ Get Transaction by hash .
93203
94204```` python3
95- nfts = ankr_api.get_nfts(
96- blockchain = " eth" ,
97- wallet_address = " 0x0E11A192d574b342C51be9e306694C41547185DD" ,
98- filter = [
99- {" 0x700b4b9f39bb1faf5d0d16a20488f2733550bff4" : []},
100- {" 0xd8682bfa6918b0174f287b888e765b9a1b4dc9c3" : [" 8937" ]},
101- ],
205+ tx = ankr_w3.query.get_transaction(
206+ transaction_hash = " 0x82c13aaac6f0b6471afb94a3a64ae89d45baa3608ad397621dbb0d847f51196f" ,
207+ include_logs = True ,
208+ decode_logs = True ,
209+ decode_tx_data = True ,
102210)
103211````
104212
105213
106214### About API keys
107215
108- 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.
216+ 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
217+ time.
109218
110219Later on, these APIs will become a part of Ankr Protocol's [ Premium Plan] ( https://www.ankr.com/protocol/plan/ ) .
0 commit comments