text: import { get as getAPI } from "./api"
  
  export const hourlyOHLCV = async ( params = {} ) => {
      //TODO: remove default fsym and tsym??
      let { fsym = "BTC", tsym = "USD", aggregate = 1, limit, batchFetchLimit = 1, responses = [], toTs } = params
  
      let searchParams = new URLSearchParams()
      searchParams.set("fsym", fsym)
      searchParams.set("tsym", tsym)
      searchParams.set("aggregate", aggregate)
      if (Number.isFinite(limit)) {
          searchParams.set("limit", limit)
      }
      if (Number.isFinite(toTs)) {
          searchParams.set("toTs", toTs)
      }
  
      const response = await getAPI("v2/histohour", {
          searchParams
      })
  
  
      let { Data = {} } = response
      let { TimeFrom: start, TimeTo: end, Data: items = [] } = Data
  
      responses.push({
          start,
          end,
          items
      })
      if (responses.length < batchFetchLimit) {
          const beforeStartOneMillisecond = start - 1
          return hourlyOHLCV({
              ...params,
              toTs: beforeStartOneMillisecond,
              responses
          })
      }
  
      let result = {
          start,
          end,
          items: []
      }
      return responses.reduceRight(
          ( result, response ) => {
              result.items.push( ...response.items )
              result.end = response.end
              return result
          },
          result
      )
  }