Fetch Wallet Tokens
This API endpoint allows you to fetch tokens associated with a specific wallet in your organization.
HTTP Method
GET
/wallets/:address/tokens
Param Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
address | String | Yes | The Ethereum address of the wallet. |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | String | No | The blockchain chain ID. |
testnet | Boolean | No | Whether the query is for a testnet. |
type | Enum | No | Token type (ERC20, ERC721, ERC1155, NATIVE). |
sort | Enum | No | The field to sort by. Options: balance, createdAt, updatedAt. |
order | Enum | No | Sorting order (asc, desc). Defaults to asc. |
page | Integer | No | Page number for pagination. Defaults to 1. |
limit | Integer | No | Number of wallets to fetch per page. Defaults to 10. |
Request Sample
- Node.js (Fetch)
- Node.js (Axios)
const fetch = require("node-fetch");
const fetchWalletTokens = async (address,query) => {
// Construct the query string
const queryString = new URLSearchParams(query).toString();
const response = await fetch(`https://api-staging.samudera.blox.my/v1/wallets/${address}/tokens?${queryString}`, {
method: "GET",
headers: {
"client_id": process.env.SAMUDERA_CLIENT_ID,
"client_secret": process.env.SAMUDERA_CLIENT_SECRET,
"Content-Type": "application/json",
},
});
if (!response.ok) {
const error = await response.json();
console.error("Error:", error);
return;
}
const result = await response.json();
return result;
};
// Example Usage
fetchWalletTokens("0x1234567890abcdef1234567890abcdef12345678", {
chainId: "1",
type: "ERC20",
sort: "balance",
order: "desc",
page: 1,
limit: 10,
})
.then((data) => console.log("Wallets:", data))
.catch((error) => console.error("Error:", error));
const axios = require("axios");
const fetchWalletTokens = async (address,query) => {
try {
const response = await axios.get(
`https://api-staging.samudera.blox.my/v1/wallets/${address}/tokens`,
{
headers: {
"client_id": process.env.SAMUDERA_CLIENT_ID,
"client_secret": process.env.SAMUDERA_CLIENT_SECRET,
"Content-Type": "application/json",
},
params: query,
}
);
console.log("Wallets:", response.data);
} catch (error) {
console.error("Error:", error.response.data);
}
};
// Example Usage
fetchWalletTokens("0x1234567890abcdef1234567890abcdef12345678", {
chainId: "1",
type: "ERC20",
sort: "balance",
order: "desc",
page: 1,
limit: 10,
})
.then((data) => console.log("Wallets:", data))
.catch((error) => console.error("Error:", error));
Response
Success Response
Status Code:
200
| Field | Type | Description |
|---|---|---|
data | Array | List of wallets matching the query parameters. |
count | Integer | Total number of wallets matching the query. |
Example Response:
{
"data": [
{
"walletAddress": "0x1234567890abcdef1234567890abcdef12345678",
"chainId": "1",
"tokenAddress": "0xabcdefabcdefabcdefabcdefabcdefabcdef",
"balance": "500000000000000000",
"token": {
"name": "token1",
"displayName": "Token 1",
"symbol": "TK1",
"type": "ERC20",
"decimals": 18,
"address": "0xabcdefabcdefabcdefabcdefabcdefabcdef",
"ownerAddress": "0x0000000000000000000000000000000000000000",
"active": true,
"public": false,
"maxSupply": "0",
"version": "1",
"logoUrl": "https://example.com/token1-logo.png",
"organizationId": "org_12345",
"chainId": "1",
"chain": {
"id": "1",
"chainId": "1",
"name": "Ethereum",
"testnet": true,
"confirmationsRequired": 12,
"active": true,
"logoUrl": "https://example.com/ethereum-logo.png"
},
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-12-10T12:00:00.000Z"
}
}
],
"count": 1
}