Skip to content

Commit 3195a6e

Browse files
committed
chore: add insight query example to README
1 parent 0b6fd70 commit 3195a6e

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

README.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ pnpm add @sentio/api
1010

1111
## Usage
1212

13+
### Example 1: get project list
14+
1315
```ts
1416
import { Configuration, WebApi } from "@sentio/api";
1517

16-
1718
const config = new Configuration({
1819
apiKey: process.env.SENTIO_API_KEY,
1920
});
@@ -22,6 +23,52 @@ const projects = await api.getProjectList();
2223
console.log(projects);
2324
```
2425

26+
### Example 2: insight query
27+
28+
```ts
29+
import { Configuration, WebApi, DataApi } from "@sentio/api";
30+
31+
const config = new Configuration({
32+
apiKey: process.env.SENTIO_API_KEY,
33+
});
34+
35+
const dataApi = new DataApi(config);
36+
const res = await dataApi.query({
37+
owner: "sentio",
38+
slug: "coinbase",
39+
body: {
40+
timeRange: {
41+
start: "now-30d",
42+
end: "now",
43+
step: 3600,
44+
timezone: "America/Los_Angeles",
45+
},
46+
limit: 20,
47+
queries: [
48+
{
49+
metricsQuery: {
50+
query: "cbETH_price",
51+
alias: "",
52+
id: "a",
53+
labelSelector: {},
54+
aggregate: null,
55+
functions: [],
56+
disabled: false,
57+
},
58+
dataSource: "METRICS",
59+
sourceName: "",
60+
},
61+
],
62+
formulas: [],
63+
cachePolicy: {
64+
noCache: false,
65+
cacheTtlSecs: 1296000,
66+
cacheRefreshTtlSecs: 1800,
67+
},
68+
},
69+
});
70+
```
71+
2572
## Documentation
2673

2774
[Sentio API Reference](https://docs.sentio.xyz/reference)

0 commit comments

Comments
 (0)