|
1 | 1 | # Stats API Routes |
2 | 2 |
|
3 | | -This directory contains the API routes for handling wallet balance snapshots using a batch processing system to avoid timeout issues. |
| 3 | +This directory contains the API route for handling wallet balance snapshots using a batch processing system to avoid timeout issues. |
4 | 4 |
|
5 | | -## Recent Updates |
| 5 | +## Overview |
6 | 6 |
|
7 | | -This batch processing system addresses timeout issues when processing large numbers of wallets: |
| 7 | +The batch processing system addresses timeout issues when processing large numbers of wallets by: |
8 | 8 |
|
9 | 9 | - **Solves**: Timeout issues with large wallet counts |
10 | 10 | - **Improves**: Reliability, monitoring, and error handling |
11 | 11 | - **Adds**: Comprehensive progress tracking and TVL reporting |
| 12 | +- **Consolidates**: All snapshot functionality into a single, efficient endpoint |
12 | 13 |
|
13 | 14 | ## Authentication |
14 | 15 |
|
15 | | -All endpoints require authentication using the `SNAPSHOT_AUTH_TOKEN` environment variable: |
| 16 | +The endpoint requires authentication using the `SNAPSHOT_AUTH_TOKEN` environment variable: |
16 | 17 | - **Header**: `Authorization: Bearer <token>` |
17 | 18 | - **Environment Variable**: `SNAPSHOT_AUTH_TOKEN` |
18 | 19 |
|
19 | | -## Routes |
20 | | - |
21 | | -### `/api/v1/stats/wallets` |
22 | | -- **Method**: GET |
23 | | -- **Purpose**: Returns all wallet information for batch processing |
24 | | -- **Authentication**: Required (Bearer token) |
25 | | -- **Response**: |
26 | | - ```json |
27 | | - { |
28 | | - "wallets": [ |
29 | | - { |
30 | | - "walletId": "string", |
31 | | - "walletName": "string", |
32 | | - "description": "string|null", |
33 | | - "signersAddresses": ["string"], |
34 | | - "signersStakeKeys": ["string"], |
35 | | - "signersDRepKeys": ["string"], |
36 | | - "signersDescriptions": ["string"], |
37 | | - "numRequiredSigners": number, |
38 | | - "verified": ["string"], |
39 | | - "scriptCbor": "string", |
40 | | - "stakeCredentialHash": "string|null", |
41 | | - "type": "string", |
42 | | - "isArchived": boolean, |
43 | | - "clarityApiKey": "string|null", |
44 | | - "network": number |
45 | | - } |
46 | | - ], |
47 | | - "walletCount": number, |
48 | | - "activeWalletCount": number, |
49 | | - "archivedWalletCount": number |
50 | | - } |
51 | | - ``` |
52 | | - |
53 | | -### `/api/v1/stats/balance` |
54 | | -- **Method**: GET |
55 | | -- **Purpose**: Fetches balance for a single wallet (used internally by batch processing) |
56 | | -- **Authentication**: Required (Bearer token) |
57 | | -- **Query Parameters**: |
58 | | - - `walletId` (required) - Wallet ID |
59 | | - - `walletName` (required) - Wallet name |
60 | | - - `signersAddresses` (required) - JSON array of signer addresses |
61 | | - - `numRequiredSigners` (required) - Number of required signers |
62 | | - - `type` (required) - Wallet type |
63 | | - - `stakeCredentialHash` (optional) - Stake credential hash |
64 | | - - `isArchived` (required) - Whether wallet is archived |
65 | | - - `network` (required) - Network ID (0=testnet, 1=mainnet) |
66 | | -- **Response**: |
67 | | - ```json |
68 | | - { |
69 | | - "walletBalance": { |
70 | | - "walletId": "string", |
71 | | - "walletName": "string", |
72 | | - "address": "string", |
73 | | - "balance": { |
74 | | - "lovelace": "string", |
75 | | - "assetId": "quantity" |
76 | | - }, |
77 | | - "adaBalance": number, |
78 | | - "isArchived": boolean |
79 | | - } |
80 | | - } |
81 | | - ``` |
82 | | - |
83 | | -### `/api/v1/stats/snapshots` |
84 | | -- **Method**: POST |
85 | | -- **Purpose**: Stores balance snapshots in the database |
86 | | -- **Authentication**: Required (Bearer token) |
87 | | -- **Content-Type**: `application/json` |
88 | | -- **Body**: |
89 | | - ```json |
90 | | - { |
91 | | - "walletBalances": [ |
92 | | - { |
93 | | - "walletId": "string", |
94 | | - "walletName": "string", |
95 | | - "address": "string", |
96 | | - "balance": { |
97 | | - "lovelace": "string", |
98 | | - "assetId": "quantity" |
99 | | - }, |
100 | | - "adaBalance": number, |
101 | | - "isArchived": boolean |
102 | | - } |
103 | | - ] |
104 | | - } |
105 | | - ``` |
106 | | -- **Response**: |
107 | | - ```json |
108 | | - { |
109 | | - "snapshotsStored": number, |
110 | | - "totalWallets": number |
111 | | - } |
112 | | - ``` |
| 20 | +## Route |
113 | 21 |
|
114 | 22 | ### `/api/v1/stats/run-snapshots-batch` |
115 | 23 | - **Method**: POST |
|
0 commit comments