From eaca1098c913497284484687ed737cd1262672af Mon Sep 17 00:00:00 2001
From: Himanshu Aggarwal <aggarwah@mcmaster.ca>
Date: Thu, 24 Feb 2022 15:26:40 -0500
Subject: [PATCH] Add timeseries range API query

---
 src/cryptometrics/queries/queries.js | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/cryptometrics/queries/queries.js b/src/cryptometrics/queries/queries.js
index 16c2d02..c214fd7 100644
--- a/src/cryptometrics/queries/queries.js
+++ b/src/cryptometrics/queries/queries.js
@@ -18,6 +18,23 @@ export function useCryptoTimeSeriesData(name, days = 7, interval = "daily") {
   );
 }
 
+export function useCryptoTimeSeriesRangeData(name, from, to) {
+  return useQuery(
+    `${name}_from_${from}_to_${to}`,
+    () => {
+      return axios
+        .get(
+          `https://api.coingecko.com/api/v3/coins/${name}/market_chart/range?vs_currency=usd&from=${from}&to=${to}`
+        )
+        .then((res) => res.data);
+    },
+    {
+      refetchOnWindowFocus: false,
+      staleTime: 5 * 60000, // 5 minutes,
+    }
+  );
+}
+
 export function useCryptoList(
   currency = "usd",
   numberOfCurrencies = 20,
-- 
GitLab