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 ratios endpoint to proxy calls to Coingecko coin markets endpoint #1234

Merged
merged 2 commits into from
Mar 3, 2022

Conversation

nvonpentz
Copy link
Contributor

@nvonpentz nvonpentz commented Feb 24, 2022

Summary

Resolves #1225

Add ratios endpoint to proxy calls to Coingecko coin markets endpoint

Client calls to new ratios endpoint /v2/market/provider/coingecko will be proxied to/api/v3/coins/markets on coingecko. The ratios endpoint currently supports two query string parameters limit which specifies the number of results (max 250), and vsCurrency which specifies the currency the results are denominated in.

The results for a given call are saved on Redis for one hour. During that time, calls to the same endpoint will be routed to the Redis cache, not coingecko.

Both the path and query supported query strings are flexible, so let me know if something else is desired.

$ curl {host}/v2/market/provider/coingecko\?vsCurrency\=usd\&limit\=2 | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   641  100   641    0     0    768      0 --:--:-- --:--:-- --:--:--   767
{
  "payload": [
    {
      "id": "bitcoin",
      "symbol": "btc",
      "name": "Bitcoin",
      "image": "https://assets.coingecko.com/coins/images/1/large/bitcoin.png?1547033579",
      "market_cap": 836181040930,
      "market_cap_rank": 1,
      "current_price": 44073,
      "price_change_24h": 80.62,
      "price_change_percentage_24h": 0.18327,
      "total_volume": 25839488245
    },
    {
      "id": "ethereum",
      "symbol": "eth",
      "name": "Ethereum",
      "image": "https://assets.coingecko.com/coins/images/279/large/ethereum.png?1595348880",
      "market_cap": 355144090752,
      "market_cap_rank": 2,
      "current_price": 0,
      "price_change_24h": 12.74,
      "price_change_percentage_24h": 0.43069,
      "total_volume": 17259869597
    }
  ],
  "lastUpdated": "2022-03-02T20:35:53.40707037Z"
}

Type of change ( select one )

  • Product feature
  • Bug fix
  • Performance improvement
  • Refactor
  • Other

Tested Environments

  • Development
  • Staging
  • Production

Before submitting this PR:

  • Does your code build cleanly without any errors or warnings?
  • Have you used auto closing keywords?
  • Have you added tests for new functionality?
  • Have validated query efficiency for new database queries?
  • Have documented new functionality in README or in comments?
  • Have you squashed all intermediate commits?
  • Is there a clear title that explains what the PR does?
  • Have you used intuitive function, variable and other naming?
  • Have you requested security / privacy review if needed
  • Have you performed a self review of this PR?

Manual Test Plan:

@nvonpentz nvonpentz force-pushed the ratios-market-data branch 5 times, most recently from a6da84d to 2fddbd2 Compare March 2, 2022 22:20
@nvonpentz nvonpentz marked this pull request as ready for review March 2, 2022 22:34
Copy link
Contributor

@husobee husobee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only concern is the caching including the user defined limit.

utils/clients/coingecko/client.go Show resolved Hide resolved
@nvonpentz nvonpentz force-pushed the ratios-market-data branch from 2fddbd2 to 2f2d1e3 Compare March 3, 2022 17:16
@nvonpentz nvonpentz requested a review from husobee March 3, 2022 17:42
Copy link
Contributor

@husobee husobee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Market Data Caching in Ratios Service
2 participants