Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exchange rates #158

Merged
merged 18 commits into from
Jan 21, 2025
Merged

Conversation

chris124567
Copy link
Member

  • Create interface for exchange rate APIs
  • Add CoinGecko and Kraken implementors
  • Add implementor that can average exchange rates from different sources
  • Add API endpoint for exchange rate in USD

The implementors just retrieve the exchange rate every x seconds and cache the results. This way the number of requests doesn't scale with the number of users and we won't exceed rate limits.

@chris124567 chris124567 force-pushed the christopher/add-exchange-rate-endpoints branch from 9aecf23 to 961555f Compare January 12, 2025 23:31
n8maninger

This comment was marked as resolved.

@chris124567
Copy link
Member Author

This seems pretty extensible. We could also respond with the rates for all the currencies at once if you think that'd be better.

@n8maninger
Copy link
Member

n8maninger commented Jan 14, 2025

I think it's fine for our API to return a single rate per request. However, a ticker per source per pair is less than ideal. For example, with Coingecko, you can get all the currencies you need at once:

https://api.coingecko.com/api/v3/simple/price?ids=bitcoin%2Csiacoin%2Csiaprime-coin%2Cbitcoin&vs_currencies=btc%2Cusd%2Ccad%2Ceur%2Cgbp%2Cjpy%2Caus%2Crub%2Ccny%2Ceth&include_market_cap=false&include_24hr_vol=false&include_24hr_change=false&include_last_updated_at=false

Ideally, you could refresh all the sources at the same rate and save on a lot of unnecessary tickers.

ChrisSchinnerl
ChrisSchinnerl previously approved these changes Jan 17, 2025
@n8maninger n8maninger merged commit fde4aa6 into master Jan 21, 2025
8 checks passed
@n8maninger n8maninger deleted the christopher/add-exchange-rate-endpoints branch January 21, 2025 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants