-
Notifications
You must be signed in to change notification settings - Fork 236
Open
Labels
bugSomething isn't workingSomething isn't working
Description
[REQUIRED] Environment
- Browser version: -
- Alchemy SDK version: "alchemy-sdk": "^3.6.1",
[REQUIRED] Describe the problem
While using alchemy.portfolio.getTokensByWallet
, I noticed a mismatch between the SDK's type definition and the actual API response.
According to the SDK, the tokenPrices
field in GetTokensByWalletResponse
is typed as a TokenPriceByAddressResult
object.
However, the actual API response returns a TokenPrice[]
array directly.
How to reproduce:
Documentation:
🔗 https://www.alchemy.com/docs/data/portfolio-apis/portfolio-api-endpoints/portfolio-api-endpoints/get-tokens-by-address
Example from documentation:
{
data: {
tokens: [
{
address: 'foo',
network: 'foo',
tokenAddress: 'foo',
tokenBalance: 'foo',
tokenMetadata: {
decimals: 42,
logo: 'foo',
name: 'foo',
symbol: 'foo',
},
tokenPrices: {
network: 'foo',
address: 'foo',
prices: [
{
currency: 'foo',
value: 'foo',
lastUpdatedAt: 'foo',
},
],
error: 'foo',
},
},
],
},
}
Actual API response
{
"data": {
"tokens": [
{
"address": "0x1e6e8695fab3eb382534915ea8d7cc1d1994b152",
"network": "eth-mainnet",
"tokenAddress": null,
"tokenBalance": "0x00000000000000000000000000000000000000000000000009cbebbc25efff3c",
"tokenMetadata": {
"symbol": null,
"decimals": null,
"name": null,
"logo": null
},
"tokenPrices": [
{
"currency": "usd",
"value": "3674.8438483485",
"lastUpdatedAt": "2025-08-05T06:32:39Z"
}
]
}
]
}
}
Expected Behavior
The tokenPrices field in the SDK should be updated to match the actual response shape:
- Change the type to
TokenPrice[]
or - Use a union type for compatibility:
tokenPrices?: TokenPrice[] | TokenPriceByAddressResult;
Relevant code or sample repro:
// Tokens By Wallet (POST /:apiKey/assets/tokens/by-address)
const response = await fetch('https://api.g.alchemy.com/data/v1/docs-demo/assets/tokens/by-address', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
addresses: [
{
address: '0x1E6E8695FAb3Eb382534915eA8d7Cc1D1994B152',
networks: ['eth-mainnet'],
},
],
withMetadata: true,
withPrices: true,
includeNativeTokens: true,
includeErc20Tokens: true,
}),
});
const body = await response.json();
console.log(body);
Notes
Let me know if this is the expected behavior or if a type fix is needed.
If this is a valid issue, I’d be happy to submit a PR to address it.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working