@@ -13,87 +13,82 @@ Make sure you already have an account on [The Graph Market](https://thegraph.com
1313
1414Raw API endpoints are authenticated using a header, and the TypeScript Node.js SDK accepts the token as a configuration option.
1515
16- <CodeTabs >
17- <CodeTab label = " cURL" >
18- ``` shell
19- curl --request GET \
20- --url " https://token-api.thegraph.com/v1/evm/balances?network=mainnet&address=0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208" \
21- --header ' Accept: application/json' \
22- --header ' Authorization: Bearer YOUR_TOKEN'
23- ```
24- </CodeTab >
25- <CodeTab label = " Node.js" >
26- ``` typescript
27- import {EVMChains , TokenAPI } from " @pinax/token-api" ;
28-
29- const client = new TokenAPI ({
30- apiToken: process .env .TOKEN_API_KEY || " "
31- });
32-
33- const result = await client .evm .tokens .getBalances ({
34- network: EVMChains .Ethereum ,
35- address: [' 0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208' ]
36- })
37- ```
38- </CodeTab >
39- <CodeTab label = " Python" >
40- ``` python
41- import requests
42-
43- res = requests.get(
16+ <CodeBlockTabs tabs = { [' cURL' , ' Node.js' , ' Python' , ' Go' , ' Rust' ]} >
17+
18+ ``` shell
19+ curl --request GET \
20+ --url " https://token-api.thegraph.com/v1/evm/balances?network=mainnet&address=0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208" \
21+ --header ' Accept: application/json' \
22+ --header ' Authorization: Bearer YOUR_TOKEN'
23+ ```
24+
25+ ``` typescript
26+ import {EVMChains , TokenAPI } from " @pinax/token-api" ;
27+
28+ const client = new TokenAPI ({
29+ apiToken: process .env .TOKEN_API_KEY || " "
30+ });
31+
32+ const result = await client .evm .tokens .getBalances ({
33+ network: EVMChains .Ethereum ,
34+ address: [' 0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208' ]
35+ })
36+ ```
37+
38+ ``` python
39+ import requests
40+
41+ res = requests.get(
42+ " https://token-api.thegraph.com/v1/evm/balances?network=mainnet&address=0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208" ,
43+ headers = {" Authorization" : " Bearer YOUR_TOKEN" },
44+ )
45+
46+ print (res.json())
47+ ```
48+
49+ ``` go
50+ package main
51+
52+ import (
53+ " fmt"
54+ " encoding/json"
55+ " net/http"
56+ )
57+
58+ func main () {
59+ req , _ := http.NewRequest (" GET" ,
4460 " https://token-api.thegraph.com/v1/evm/balances?network=mainnet&address=0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208" ,
45- headers = { " Authorization " : " Bearer YOUR_TOKEN " } ,
61+ nil ,
4662 )
63+ req.Header .Set (" Authorization" , " Bearer YOUR_TOKEN" )
4764
48- print (res.json())
49- ```
50- </CodeTab >
51- <CodeTab label = " Go" >
52- ``` go
53- package main
54-
55- import (
56- " fmt"
57- " encoding/json"
58- " net/http"
59- )
65+ res , _ := http.DefaultClient .Do (req)
66+ defer res.Body .Close ()
67+
68+ var data any
69+ json.NewDecoder (res.Body ).Decode (&data)
70+
71+ fmt.Printf (" %#v \n " , data)
72+ }
73+ ```
74+
75+ ``` rust
76+ use reqwest :: Client ;
77+
78+ #[tokio:: main]
79+ async fn main () -> reqwest :: Result <()> {
80+ let res = Client :: new ()
81+ . get (" https://token-api.thegraph.com/v1/evm/balances?network=mainnet&address=0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208" )
82+ . bearer_auth (" YOUR_TOKEN" )
83+ . send ()
84+ . await ? ;
85+
86+ println! (" {}" , res . text (). await ? );
87+ Ok (())
88+ }
89+ ```
6090
61- func main () {
62- req , _ := http.NewRequest (" GET" ,
63- " https://token-api.thegraph.com/v1/evm/balances?network=mainnet&address=0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208" ,
64- nil ,
65- )
66- req.Header .Set (" Authorization" , " Bearer YOUR_TOKEN" )
67-
68- res , _ := http.DefaultClient .Do (req)
69- defer res.Body .Close ()
70-
71- var data any
72- json.NewDecoder (res.Body ).Decode (&data)
73-
74- fmt.Printf (" %#v \n " , data)
75- }
76- ```
77- </CodeTab >
78- <CodeTab label = " Rust" >
79- ``` rust
80- use reqwest :: Client ;
81-
82- #[tokio:: main]
83- async fn main () -> reqwest :: Result <()> {
84- let res = Client :: new ()
85- . get (" https://token-api.thegraph.com/v1/evm/balances?network=mainnet&address=0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208" )
86- . bearer_auth (" YOUR_TOKEN" )
87- . send ()
88- . await ? ;
89-
90- println! (" {}" , res . text (). await ? );
91- Ok (())
92- }
93- ```
94- </CodeTab >
95-
96- </CodeTabs >
91+ </CodeBlockTabs >
9792
9893## What's next?
9994
0 commit comments