Skip to content

Commit 05e45ab

Browse files
authored
Merge pull request #24 from NEAR-DevHub/intents-tokens
Added intents tokens and networks endpoint
2 parents 80896a4 + 615a218 commit 05e45ab

File tree

5 files changed

+2543
-4
lines changed

5 files changed

+2543
-4
lines changed

README.md

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,20 @@ A comprehensive RESTful API service for NEAR blockchain interactions, treasury m
5050
## Installation
5151

5252
1. **Clone the repository:**
53+
5354
```bash
5455
git clone https://github.com/your-username/ref-sdk-api.git
5556
cd ref-sdk-api
5657
```
5758

5859
2. **Install dependencies:**
60+
5961
```bash
6062
yarn install
6163
```
6264

6365
3. **Setup environment variables:**
66+
6467
```bash
6568
cp .env.example .env
6669
# Edit .env with your configuration
@@ -107,6 +110,7 @@ Server runs on `http://127.0.0.1:3000` by default.
107110
### Token Operations
108111

109112
#### Get Whitelist Tokens
113+
110114
- **Endpoint:** `GET /api/whitelist-tokens`
111115
- **Description:** Returns whitelisted tokens with balances and prices for a specific account
112116
- **Query Parameters:**
@@ -118,12 +122,13 @@ Server runs on `http://127.0.0.1:3000` by default.
118122
```
119123

120124
#### Token Swap
125+
121126
- **Endpoint:** `GET /api/swap`
122127
- **Description:** Generate swap transactions for token exchanges
123128
- **Query Parameters:**
124129
- `accountId` (string, required): Account executing the swap
125130
- `tokenIn` (string, required): Input token contract ID
126-
- `tokenOut` (string, required): Output token contract ID
131+
- `tokenOut` (string, required): Output token contract ID
127132
- `amountIn` (string, required): Amount of input token (in smallest units)
128133
- `slippage` (string, optional): Slippage tolerance (default: "0.01" for 1%)
129134
- **Response:** Swap transaction details and estimated output
@@ -133,6 +138,7 @@ Server runs on `http://127.0.0.1:3000` by default.
133138
```
134139

135140
#### Get NEAR Price
141+
136142
- **Endpoint:** `GET /api/near-price`
137143
- **Description:** Current NEAR token price in USD with database fallback
138144
- **Response:** Number (price in USD)
@@ -142,6 +148,7 @@ Server runs on `http://127.0.0.1:3000` by default.
142148
```
143149

144150
#### Get FT Token Price
151+
145152
- **Endpoint:** `GET /api/ft-token-price`
146153
- **Description:** Get price for a specific fungible token
147154
- **Query Parameters:**
@@ -153,6 +160,7 @@ Server runs on `http://127.0.0.1:3000` by default.
153160
```
154161

155162
#### Get FT Token Metadata
163+
156164
- **Endpoint:** `GET /api/ft-token-metadata`
157165
- **Description:** Fetch metadata for a fungible token
158166
- **Query Parameters:**
@@ -164,6 +172,7 @@ Server runs on `http://127.0.0.1:3000` by default.
164172
```
165173

166174
#### Get FT Tokens
175+
167176
- **Endpoint:** `GET /api/ft-tokens`
168177
- **Description:** Get all fungible tokens held by an account with metadata and USD values
169178
- **Query Parameters:**
@@ -174,9 +183,29 @@ Server runs on `http://127.0.0.1:3000` by default.
174183
GET /api/ft-tokens?account_id=example.near
175184
```
176185

186+
#### Get Token by Defuse Asset ID
187+
188+
- **GET** `/api/token-by-defuse-asset-id?defuseAssetId={id}`
189+
- **Description**: Fetch token data by defuse asset ID. Supports multiple IDs separated by commas.
190+
- **Query Parameters**:
191+
- `defuseAssetId` (required): Single ID or comma-separated list of defuse asset IDs
192+
- **Response**: Array of token objects with metadata, prices, and icons
193+
- **Example**: `/api/token-by-defuse-asset-id?defuseAssetId=nep141:wrap.near,0x123...`
194+
195+
#### Get Blockchain by Network
196+
197+
- **GET** `/api/blockchain-by-network?network={network}&theme={theme}`
198+
- **Description**: Fetch blockchain information by network identifier. Supports multiple networks separated by commas.
199+
- **Query Parameters**:
200+
- `network` (required): Single network or comma-separated list of networks (e.g., "near", "eth", "btc")
201+
- `theme` (optional): "light" or "dark" for icon theme (default: "light")
202+
- **Response**: Array of blockchain objects with name, icon, and network identifier
203+
- **Example**: `/api/blockchain-by-network?network=near,eth&theme=dark`
204+
177205
### Balance & History
178206

179207
#### Get Token Balance History
208+
180209
- **Endpoint:** `GET /api/all-token-balance-history`
181210
- **Description:** Historical balance data for a specific token across multiple time periods
182211
- **Query Parameters:**
@@ -189,6 +218,7 @@ Server runs on `http://127.0.0.1:3000` by default.
189218
```
190219

191220
#### Get Intents Balance History
221+
192222
- **Endpoint:** `GET /api/intents-balance-history`
193223
- **Description:** Historical balance data for tokens held through intents contracts
194224
- **Query Parameters:**
@@ -202,6 +232,7 @@ Server runs on `http://127.0.0.1:3000` by default.
202232
### Treasury Management
203233

204234
#### Get Transactions Transfer History
235+
205236
- **Endpoint:** `GET /api/transactions-transfer-history`
206237
- **Description:** Transfer transaction history for a treasury DAO
207238
- **Query Parameters:**
@@ -213,29 +244,34 @@ Server runs on `http://127.0.0.1:3000` by default.
213244
```
214245

215246
#### Store Treasuries
247+
216248
- **Endpoint:** `GET /db/store-treasuries`
217249
- **Description:** Fetch and store treasury data from factory contract
218250
- **Response:** Success message with operation results
219251

220252
#### Insert Treasury
253+
221254
- **Endpoint:** `POST /db/insert-treasury`
222255
- **Description:** Manually insert treasury data
223256
- **Body:** Treasury object or array of treasury objects
224257
- **Response:** Operation results for each treasury
225258

226259
#### Treasuries Report
260+
227261
- **Endpoint:** `GET /db/treasuries-report`
228262
- **Description:** Generate comprehensive treasury analytics report
229263
- **Response:** Treasury metrics and Google Sheets update status
230264

231265
#### Treasuries Transactions Report
266+
232267
- **Endpoint:** `GET /db/treasuries-transactions-report`
233268
- **Description:** Generate treasury transaction analytics report
234269
- **Response:** Transaction metrics and Google Sheets update status
235270

236271
### Validator Information
237272

238273
#### Get Validators
274+
239275
- **Endpoint:** `GET /api/validators`
240276
- **Description:** List of current NEAR validators with formatted fee information
241277
- **Response:** Array of validator objects with pool_id and fee percentage
@@ -245,6 +281,7 @@ Server runs on `http://127.0.0.1:3000` by default.
245281
```
246282

247283
#### Get Validator Details
284+
248285
- **Endpoint:** `GET /api/validator-details`
249286
- **Description:** Detailed information for a specific validator
250287
- **Query Parameters:**
@@ -258,6 +295,7 @@ Server runs on `http://127.0.0.1:3000` by default.
258295
### Search & Discovery
259296

260297
#### Search FT Tokens
298+
261299
- **Endpoint:** `GET /api/search-ft`
262300
- **Description:** Search for fungible tokens by name or symbol
263301
- **Query Parameters:**
@@ -269,6 +307,7 @@ Server runs on `http://127.0.0.1:3000` by default.
269307
```
270308

271309
#### Get User DAOs
310+
272311
- **Endpoint:** `GET /api/user-daos`
273312
- **Description:** List of DAOs that a user is a member of
274313
- **Query Parameters:**
@@ -282,21 +321,23 @@ Server runs on `http://127.0.0.1:3000` by default.
282321
### OneClick Treasury
283322

284323
#### OneClick Quote
324+
285325
- **Endpoint:** `POST /api/treasury/oneclick-quote`
286326
- **Description:** Generate treasury proposal for cross-chain token operations
287327
- **Body Parameters:**
288328
- `treasuryDaoID` (string, required): Treasury DAO contract ID (must end with .sputnik-dao.near)
289329
- `inputToken` (object, required): Input token details
290-
- `outputToken` (object, required): Output token details
330+
- `outputToken` (object, required): Output token details
291331
- `amountIn` (string, required): Input amount
292332
- `slippageTolerance` (string, required): Slippage tolerance
293333
- `networkOut` (string, optional): Output network
294334
- **Response:** Formatted proposal payload for DAO submission
295335
- **Example:**
336+
296337
```http
297338
POST /api/treasury/oneclick-quote
298339
Content-Type: application/json
299-
340+
300341
{
301342
"treasuryDaoID": "example.sputnik-dao.near",
302343
"inputToken": {"id": "wrap.near", "symbol": "WNEAR"},
@@ -311,11 +352,13 @@ Server runs on `http://127.0.0.1:3000` by default.
311352
## Caching & Rate Limiting
312353

313354
### Caching
355+
314356
- **NodeCache:** 2-minute TTL for most endpoints
315357
- **Specialized caching:** Longer TTL for validator data (7 days) and search results (1 day)
316358
- **RPC caching:** Request-based caching with error handling for rate limits
317359

318360
### Rate Limiting
361+
319362
- **Limit:** 180 requests per 30 seconds per IP
320363
- **Scope:** All `/api/*` endpoints
321364
- **Headers:** Standard rate limit headers included in responses

0 commit comments

Comments
 (0)