feat: change jup api to fetch token directly (#122)

# Pull Request Description

## Related Issue
Fixes # (issue number)

## Changes Made
This PR adds the following changes:
<!-- List the key changes made in this PR -->
- change jup api to fetch token directly
  
## Implementation Details
<!-- Provide technical details about the implementation -->
doc api: https://station.jup.ag/docs/token-list/token-list-api

## Transaction executed by agent 
<!-- If applicable, provide example usage, transactions, or screenshots
-->
Example transaction: 

## Prompt Used
<!-- If relevant, include the prompt or configuration used -->
```
Get token data from either a token address or ticker symbol
```

## Additional Notes
<!-- Any additional information that reviewers should know -->
<img width="1455" alt="image"
src="https://github.com/user-attachments/assets/1a95ec16-ad10-461e-8ca9-90f4f89616aa"
/>


## Checklist
- [x] I have tested these changes locally
- [ ] I have updated the documentation
- [ ] I have added a transaction link
- [x] I have added the prompt used to test it
This commit is contained in:
aryan
2025-01-10 05:02:39 +05:30
committed by GitHub

View File

@@ -9,17 +9,14 @@ export async function getTokenDataByAddress(
throw new Error("Mint address is required");
}
const response = await fetch("https://tokens.jup.ag/tokens?tags=verified", {
const response = await fetch(`https://tokens.jup.ag/token/${mint}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
const data = (await response.json()) as JupiterTokenData[];
const token = data.find((token: JupiterTokenData) => {
return token.address === mint.toBase58();
});
const token = (await response.json()) as JupiterTokenData;
return token;
} catch (error: any) {
throw new Error(`Error fetching token data: ${error.message}`);