Skip to content

Commit c07ff58

Browse files
author
Amine Afia
committed
Update page.mdx
1 parent ecf5835 commit c07ff58

File tree

2 files changed

+109
-134
lines changed

2 files changed

+109
-134
lines changed

apps/portal/src/app/insight/agents-and-llms/llmstxt/page.mdx

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Insight is a powerful tool that lets you retrieve blockchain data from any EVM c
3838
## API URL
3939

4040
```typescript
41-
const baseUrl = `https://${chainId}.insight.thirdweb.com`;
41+
const baseUrl = `https://{{chainId}}.insight.thirdweb.com`;
4242
```
4343

4444
## Authentication
@@ -48,22 +48,22 @@ The API supports three authentication methods:
4848
```typescript
4949
// 1. Header Authentication
5050
const headers = {
51-
"x-client-id": "YOUR_CLIENT_ID", // thirdweb Client ID
51+
"x-client-id": "{{clientId}}", // thirdweb Client ID
5252
};
5353

5454
// 2. Query Parameter
55-
const url = `https://${chainId}.insight.thirdweb.com/v1/events?clientId=YOUR_CLIENT_ID`;
55+
const url = `https://{{chainId}}.insight.thirdweb.com/v1/events?clientId={{clientId}}`;
5656

5757
// 3. Bearer Token
5858
const headers = {
59-
Authorization: "Bearer YOUR_JWT_TOKEN",
59+
Authorization: "Bearer {{jwtToken}}",
6060
};
6161

6262
// Example using fetch with header auth
6363
async function getEvents() {
64-
const response = await fetch(`https://${chainId}.insight.thirdweb.com/v1/events`, {
64+
const response = await fetch(`https://{{chainId}}.insight.thirdweb.com/v1/events`, {
6565
headers: {
66-
"x-client-id": "YOUR_CLIENT_ID",
66+
"x-client-id": "{{clientId}}",
6767
},
6868
});
6969
return await response.json();
@@ -74,14 +74,16 @@ async function getEvents() {
7474

7575
### Chain IDs
7676

77-
The API supports the following chain IDs (with 1 as default):
77+
The API supports chain IDs in the following format:
7878

7979
```typescript
80-
type ChainId = string; // Chain ID of the network you want to query
80+
interface ChainConfig {
81+
chainId: number; // Chain ID of the network you want to query
82+
}
8183

8284
// Example: Using a specific chain
83-
const chainId = "<chainId>"; // Replace with your desired chain ID
84-
const baseUrl = `https://${chainId}.insight.thirdweb.com`;
85+
const chainId = "{{chainId}}"; // Replace with your desired chain ID
86+
const baseUrl = `https://{{chainId}}.insight.thirdweb.com`;
8587
```
8688

8789
### Base Response Structure
@@ -128,25 +130,25 @@ interface BaseResponse<T> {
128130

129131
```typescript
130132
// 1. Get All Events
131-
async function getAllEvents() {
132-
const response = await fetch(`https://${chainId}.insight.thirdweb.com/v1/events`, {
133-
headers: { "x-client-id": "YOUR_CLIENT_ID" },
133+
async function getAllEvents(): Promise<BaseResponse<Event>> {
134+
const response = await fetch(`https://{{chainId}}.insight.thirdweb.com/v1/events`, {
135+
headers: { "x-client-id": "{{clientId}}" },
134136
});
135137
return await response.json();
136138
}
137139

138140
// 2. Get Contract Events with Filtering
139-
async function getContractEvents(contractAddress: string) {
141+
async function getContractEvents(contractAddress: string): Promise<BaseResponse<Event>> {
140142
const params = new URLSearchParams({
141-
filter_block_number_gte: "17000000",
143+
filter_block_number_gte: "{{blockNumber}}",
142144
sort_by: "block_timestamp",
143145
sort_order: "desc",
144146
limit: "50",
145147
});
146148

147-
const url = `https://${chainId}.insight.thirdweb.com/v1/events/${contractAddress}?${params}`;
149+
const url = `https://{{chainId}}.insight.thirdweb.com/v1/events/${contractAddress}?${params}`;
148150
const response = await fetch(url, {
149-
headers: { "x-client-id": "YOUR_CLIENT_ID" },
151+
headers: { "x-client-id": "{{clientId}}" },
150152
});
151153
return await response.json();
152154
}
@@ -156,10 +158,10 @@ async function getContractEvents(contractAddress: string) {
156158

157159
```typescript
158160
// 1. Get ERC20 Balances
159-
async function getERC20Balances(ownerAddress: string) {
161+
async function getERC20Balances(ownerAddress: string): Promise<ERC20Response> {
160162
const response = await fetch(
161-
`https://${chainId}.insight.thirdweb.com/v1/tokens/erc20/${ownerAddress}`,
162-
{ headers: { "x-client-id": "YOUR_CLIENT_ID" } },
163+
`https://{{chainId}}.insight.thirdweb.com/v1/tokens/erc20/${ownerAddress}`,
164+
{ headers: { "x-client-id": "{{clientId}}" } },
163165
);
164166
const data = await response.json();
165167
// Example response:
@@ -177,8 +179,8 @@ async function getERC20Balances(ownerAddress: string) {
177179
// 2. Get NFT Balances
178180
async function getNFTBalances(ownerAddress: string) {
179181
const response = await fetch(
180-
`https://${chainId}.insight.thirdweb.com/v1/tokens/erc721/${ownerAddress}`,
181-
{ headers: { "x-client-id": "YOUR_CLIENT_ID" } },
182+
`https://{{chainId}}.insight.thirdweb.com/v1/tokens/erc721/${ownerAddress}`,
183+
{ headers: { "x-client-id": "{{clientId}}" } },
182184
);
183185
const data = await response.json();
184186
// Example response:
@@ -202,15 +204,15 @@ async function getNFTBalances(ownerAddress: string) {
202204
async function getFilteredEvents() {
203205
const params = new URLSearchParams({
204206
// Block filters
205-
filter_block_number_gte: "17000000",
206-
filter_block_number_lte: "17859301",
207+
filter_block_number_gte: "{{startBlock}}",
208+
filter_block_number_lte: "{{endBlock}}",
207209

208210
// Time filters
209-
filter_block_timestamp_gte: "1715222400",
211+
filter_block_timestamp_gte: "{{startTimestamp}}",
210212

211213
// Transaction filters
212-
filter_from_address: "0x123...",
213-
filter_value_gte: "1000000000000000000", // 1 ETH
214+
filter_from_address: "{{fromAddress}}",
215+
filter_value_gte: "{{minValue}}", // 1 ETH
214216

215217
// Pagination
216218
page: "0",
@@ -222,8 +224,8 @@ async function getFilteredEvents() {
222224
});
223225

224226
const response = await fetch(
225-
`https://${chainId}.insight.thirdweb.com/v1/events?${params}`,
226-
{ headers: { "x-client-id": "YOUR_CLIENT_ID" } },
227+
`https://{{chainId}}.insight.thirdweb.com/v1/events?${params}`,
228+
{ headers: { "x-client-id": "{{clientId}}" } },
227229
);
228230
return await response.json();
229231
}
@@ -234,8 +236,8 @@ async function getFilteredEvents() {
234236
```typescript
235237
async function safeApiCall() {
236238
try {
237-
const response = await fetch(`https://${chainId}.insight.thirdweb.com/v1/events`, {
238-
headers: { "x-client-id": "YOUR_CLIENT_ID" },
239+
const response = await fetch(`https://{{chainId}}.insight.thirdweb.com/v1/events`, {
240+
headers: { "x-client-id": "{{clientId}}" },
239241
});
240242

241243
if (!response.ok) {
@@ -260,69 +262,73 @@ async function safeApiCall() {
260262
1. **Get All Events**
261263

262264
```typescript
263-
GET /v1/events
265+
GET https://{{chainId}}.insight.thirdweb.com/v1/events
264266
```
265267

266268
2. **Get Contract Events**
267269

268270
```typescript
269-
GET /v1/events/:contractAddress
271+
GET https://{{chainId}}.insight.thirdweb.com/v1/events/:contractAddress
270272
```
271273

272274
3. **Get Specific Event Type**
273275

274276
```typescript
275-
GET /v1/events/:contractAddress/:signature
277+
GET https://{{chainId}}.insight.thirdweb.com/v1/events/:contractAddress/:signature
276278
```
277279

278280
### Transactions API
279281

280282
1. **Get All Transactions**
281283

282284
```typescript
283-
GET /v1/transactions
284-
GET /v1/transactions;
285+
GET https://{{chainId}}.insight.thirdweb.com/v1/transactions
285286
```
286287

287288
2. **Get Contract Transactions**
288289

289290
```typescript
290-
GET /v1/transactions/:contractAddress
291+
GET https://{{chainId}}.insight.thirdweb.com/v1/transactions/:contractAddress
291292
```
292293

293294
3. **Get Specific Transaction Type**
294295

295296
```typescript
296-
GET /v1/transactions/:contractAddress/:signature
297+
GET https://{{chainId}}.insight.thirdweb.com/v1/transactions/:contractAddress/:signature
297298
```
298299

299300
### Token Balance API
300301

301302
1. **ERC20 Balances**
302303

303304
```typescript
304-
GET /v1/tokens/erc20/:ownerAddress
305+
GET https://{{chainId}}.insight.thirdweb.com/v1/tokens/erc20/:ownerAddress
305306

306307
interface ERC20Response {
307-
data: {
308-
tokenAddress: string; // Required
309-
balance: string; // Required
310-
}[];
308+
data: ERC20Balance[];
309+
}
310+
311+
interface ERC20Balance {
312+
tokenAddress: string;
313+
balance: string;
311314
}
312315
```
313316

314317
2. **ERC721 & ERC1155 Balances**
315318

316319
```typescript
317-
GET /v1/tokens/erc721/:ownerAddress
318-
GET /v1/tokens/erc1155/:ownerAddress
320+
GET https://{{chainId}}.insight.thirdweb.com/v1/tokens/erc721/:ownerAddress
321+
GET https://{{chainId}}.insight.thirdweb.com/v1/tokens/erc1155/:ownerAddress
322+
GET https://{{chainId}}.insight.thirdweb.com/v1/transactions
319323

320324
interface TokenBalance {
321-
data: {
322-
collectionAddress: string; // Required
323-
tokenId: string; // Required
324-
balance: string; // Required
325-
}[];
325+
data: NFTBalance[];
326+
}
327+
328+
interface NFTBalance {
329+
collectionAddress: string;
330+
tokenId: string;
331+
balance: string;
326332
}
327333
```
328334

0 commit comments

Comments
 (0)