Skip to content

Commit

Permalink
feat: /v1 -> /api/v1
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkersner committed Jul 26, 2024
1 parent 5db839c commit 57709bd
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 54 deletions.
16 changes: 8 additions & 8 deletions datamaxi/datamaxi/candle.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get(
) -> Union[Tuple[Dict, Callable], Tuple[pd.DataFrame, Callable]]:
"""Fetch candle data
`GET /v1/candle`
`GET /api/v1/candle`
<https://docs.datamaxiplus.com/api/datasets/candle/candle>
Expand Down Expand Up @@ -90,7 +90,7 @@ def get(
"sort": sort,
}

res = self.query("/v1/candle", params)
res = self.query("/api/v1/candle", params)
if res["data"] is None:
raise ValueError("no data found")

Expand Down Expand Up @@ -119,7 +119,7 @@ def exchanges(self, market: str = "spot") -> List[str]:
[datamaxi.Candle.get](./#datamaxi.datamaxi.Candle.get)
API.
`GET /v1/candle/exchanges`
`GET /api/v1/candle/exchanges`
<https://docs.datamaxiplus.com/api/datasets/candle/exchanges>
Expand All @@ -135,15 +135,15 @@ def exchanges(self, market: str = "spot") -> List[str]:
raise ValueError("market must be either spot or futures")

params = {"market": market}
url_path = "/v1/candle/exchanges"
url_path = "/api/v1/candle/exchanges"
return self.query(url_path, params)

def symbols(self, exchange: str, market: str = "spot") -> List[str]:
"""Fetch supported symbols accepted by
[datamaxi.Candle.get](./#datamaxi.datamaxi.Candle.get)
API.
`GET /v1/candle/symbols`
`GET /api/v1/candle/symbols`
<https://docs.datamaxiplus.com/api/datasets/candle/symbols>
Expand All @@ -165,15 +165,15 @@ def symbols(self, exchange: str, market: str = "spot") -> List[str]:
raise ValueError("market must be either spot or futures")

params = {"exchange": exchange, "market": market}
url_path = "/v1/candle/symbols"
url_path = "/api/v1/candle/symbols"
return self.query(url_path, params)

def intervals(self, exchange: str, market: str = "spot") -> List[str]:
"""Fetch supported intervals accepted by
[datamaxi.Candle.get](./#datamaxi.datamaxi.Candle.get)
API.
`GET /v1/candle/intervals`
`GET /api/v1/candle/intervals`
<https://docs.datamaxiplus.com/api/datasets/candle/intervals>
Expand All @@ -192,5 +192,5 @@ def intervals(self, exchange: str, market: str = "spot") -> List[str]:
)

params = {"exchange": exchange, "market": market}
url_path = "/v1/candle/intervals"
url_path = "/api/v1/candle/intervals"
return self.query(url_path, params)
8 changes: 4 additions & 4 deletions datamaxi/datamaxi/dex_trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get(
) -> Union[Tuple[Dict, Callable], Tuple[pd.DataFrame, Callable]]:
"""Fetch DEX trade data
`GET /v1/dex/trade`
`GET /api/v1/dex/trade`
<https://docs.datamaxiplus.com/api/datasets/dex-trade/trade>
Expand Down Expand Up @@ -77,7 +77,7 @@ def get(
"sort": sort,
}

res = self.query("/v1/dex/trade", params)
res = self.query("/api/v1/dex/trade", params)
if res["data"] is None:
raise ValueError("no data found")

Expand All @@ -104,12 +104,12 @@ def exchanges(self) -> List[str]:
[datamaxi.DexTrade.get](./#datamaxi.datamaxi.DexTrade.get)
API.
`GET /v1/dex/trade/exchanges`
`GET /api/v1/dex/trade/exchanges`
<https://docs.datamaxiplus.com/api/datasets/dex-trade/exchanges>
Returns:
List of supported exchanges
"""
url_path = "/v1/dex/trade/exchanges"
url_path = "/api/v1/dex/trade/exchanges"
return self.query(url_path)
12 changes: 6 additions & 6 deletions datamaxi/datamaxi/funding_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def get(
) -> Union[Tuple[Dict, Callable], Tuple[pd.DataFrame, Callable]]:
"""Fetch funding rate data
`GET /v1/funding-rate`
`GET /api/v1/funding-rate`
<https://docs.datamaxiplus.com/api/datasets/funding-rate/funding-rate>
Expand Down Expand Up @@ -79,7 +79,7 @@ def get(
"sort": sort,
}

res = self.query("/v1/funding-rate", params)
res = self.query("/api/v1/funding-rate", params)
if res["data"] is None:
raise ValueError("no data found")

Expand All @@ -106,22 +106,22 @@ def exchanges(self) -> List[str]:
[datamaxi.FundingRate.get](./#datamaxi.datamaxi.FundingRate.get)
API.
`GET /v1/funding-rate/exchanges`
`GET /api/v1/funding-rate/exchanges`
<https://docs.datamaxiplus.com/api/datasets/funding-rate/exchanges>
Returns:
List of supported exchanges
"""
url_path = "/v1/funding-rate/exchanges"
url_path = "/api/v1/funding-rate/exchanges"
return self.query(url_path)

def symbols(self, exchange: str, market: str = "spot") -> List[str]:
"""Fetch supported symbols accepted by
[datamaxi.FundingRate.get](./#datamaxi.datamaxi.FundingRate.get)
API.
`GET /v1/funding-rate/symbols`
`GET /api/v1/funding-rate/symbols`
<https://docs.datamaxiplus.com/api/datasets/funding-rate/symbols>
Expand All @@ -133,5 +133,5 @@ def symbols(self, exchange: str, market: str = "spot") -> List[str]:
"""
check_required_parameter(exchange, "exchange")
params = {"exchange": exchange}
url_path = "/v1/funding-rate/symbols"
url_path = "/api/v1/funding-rate/symbols"
return self.query(url_path, params)
56 changes: 28 additions & 28 deletions datamaxi/defillama/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,53 +24,53 @@ def __init__(self, api_key=None, **kwargs: Any):
def protocols(self) -> List[str]:
"""Get supported protocols
`GET /v1/defillama/protocol`
`GET /api/v1/defillama/protocol`
<https://docs.datamaxiplus.com/api/datasets/defillama/protocol>
Returns:
List of supported protocols
"""
url_path = "/v1/defillama/protocol"
url_path = "/api/v1/defillama/protocol"
return self.query(url_path)

def chains(self) -> List[str]:
"""Get supported chains
`GET /v1/defillama/chain`
`GET /api/v1/defillama/chain`
<https://docs.datamaxiplus.com/api/datasets/defillama/chain>
Returns:
List of supported chains
"""
url_path = "/v1/defillama/chain"
url_path = "/api/v1/defillama/chain"
return self.query(url_path)

def pools(self) -> List[str]:
"""Get supported pools
`GET /v1/defillama/pool`
`GET /api/v1/defillama/pool`
<https://docs.datamaxiplus.com/api/datasets/defillama/pool>
Returns:
List of supported pools
"""
url_path = "/v1/defillama/pool"
url_path = "/api/v1/defillama/pool"
return self.query(url_path)

def stablecoins(self) -> List[str]:
"""Get supported stablecoins
`GET /v1/defillama/stablecoin`
`GET /api/v1/defillama/stablecoin`
<https://docs.datamaxiplus.com/api/datasets/defillama/stablecoin>
Returns:
List of supported stablecoins
"""
url_path = "/v1/defillama/stablecoin"
url_path = "/api/v1/defillama/stablecoin"
return self.query(url_path)

@postprocess()
Expand All @@ -79,7 +79,7 @@ def tvl(
) -> Union[List, pd.DataFrame]:
"""Get total TVL across all chains and protocols
`GET /v1/defillama/tvl`
`GET /api/v1/defillama/tvl`
<https://docs.datamaxiplus.com/api/datasets/defillama/tvl>
Expand All @@ -98,7 +98,7 @@ def tvl(
if chain is not None:
params["chain"] = chain

url_path = "/v1/defillama/tvl"
url_path = "/api/v1/defillama/tvl"
return self.query(url_path, params)

@postprocess(num_index=2)
Expand All @@ -107,7 +107,7 @@ def tvl_detail(
) -> Union[List, pd.DataFrame]:
"""Get TVL detail for given protocol and chain
`GET /v1/defillama/tvl/detail`
`GET /api/v1/defillama/tvl/detail`
<https://docs.datamaxiplus.com/api/datasets/defillama/tvl-detail>
Expand All @@ -129,14 +129,14 @@ def tvl_detail(
if token:
params["token"] = str(token).lower()

url_path = "/v1/defillama/tvl/detail"
url_path = "/api/v1/defillama/tvl/detail"
return self.query(url_path, params)

@postprocess()
def mcap(self, protocol: str, pandas: bool = True) -> Union[List, pd.DataFrame]:
"""Get market cap for given protocol
`GET /v1/defillama/mcap`
`GET /api/v1/defillama/mcap`
<https://docs.datamaxiplus.com/api/datasets/defillama/mcap>
Expand All @@ -151,13 +151,13 @@ def mcap(self, protocol: str, pandas: bool = True) -> Union[List, pd.DataFrame]:
params = {
"protocol": protocol,
}
return self.query("/v1/defillama/mcap", params)
return self.query("/api/v1/defillama/mcap", params)

@postprocess()
def pool_yield(self, poolId: str, pandas: bool = True) -> Union[List, pd.DataFrame]:
"""Get yield for given pool
`GET /v1/defillama/pool/yield`
`GET /api/v1/defillama/pool/yield`
<https://docs.datamaxiplus.com/api/datasets/defillama/pool-yield>
Expand All @@ -172,15 +172,15 @@ def pool_yield(self, poolId: str, pandas: bool = True) -> Union[List, pd.DataFra
params = {
"poolId": poolId,
}
return self.query("/v1/defillama/pool/yield", params)
return self.query("/api/v1/defillama/pool/yield", params)

@postprocess()
def stablecoin_mcap(
self, stablecoin: str, chain: str = None, pandas: bool = True
) -> Union[List, pd.DataFrame]:
"""Get market cap for given stablecoin and chain
`GET /v1/defillama/stablecoin/mcap`
`GET /api/v1/defillama/stablecoin/mcap`
<https://docs.datamaxiplus.com/api/datasets/defillama/stablecoin-mcap>
Expand All @@ -200,15 +200,15 @@ def stablecoin_mcap(
if chain is not None:
params["chain"] = chain

return self.query("/v1/defillama/stablecoin/mcap", params)
return self.query("/api/v1/defillama/stablecoin/mcap", params)

@postprocess()
def stablecoin_price(
self, stablecoin: str, pandas: bool = True
) -> Union[List, pd.DataFrame]:
"""Get price for given stablecoin
`GET /v1/defillama/stablecoin/price`
`GET /api/v1/defillama/stablecoin/price`
<https://docs.datamaxiplus.com/api/datasets/defillama/stablecoin-price>
Expand All @@ -223,7 +223,7 @@ def stablecoin_price(
params = {
"stablecoin": stablecoin,
}
return self.query("/v1/defillama/stablecoin/price", params)
return self.query("/api/v1/defillama/stablecoin/price", params)

@postprocess()
def fee(
Expand All @@ -235,7 +235,7 @@ def fee(
) -> Union[List, pd.DataFrame]:
"""Get fee for given protocol or chain
`GET /v1/defillama/fee`
`GET /api/v1/defillama/fee`
<https://docs.datamaxiplus.com/api/datasets/defillama/fee>
Expand Down Expand Up @@ -263,7 +263,7 @@ def fee(
check_required_parameter(chain, "chain")
params["chain"] = chain

return self.query("/v1/defillama/fee", params)
return self.query("/api/v1/defillama/fee", params)

@postprocess()
def revenue(
Expand All @@ -275,7 +275,7 @@ def revenue(
) -> Union[List, pd.DataFrame]:
"""Get revenue for given protocol or chain
`GET /v1/defillama/revenue`
`GET /api/v1/defillama/revenue`
<https://docs.datamaxiplus.com/api/datasets/defillama/revenue>
Expand Down Expand Up @@ -303,7 +303,7 @@ def revenue(
check_required_parameter(chain, "chain")
params["chain"] = chain

return self.query("/v1/defillama/revenue", params)
return self.query("/api/v1/defillama/revenue", params)

@postprocess(num_index=-1)
def fee_detail(
Expand All @@ -315,7 +315,7 @@ def fee_detail(
) -> Union[List, pd.DataFrame]:
"""Get fee detail for given protocol and chain
`GET /v1/defillama/fee/detail`
`GET /api/v1/defillama/fee/detail`
<https://docs.datamaxiplus.com/api/datasets/defillama/fee-detail>
Expand All @@ -340,7 +340,7 @@ def fee_detail(
if chain is not None:
params["chain"] = chain

return self.query("/v1/defillama/fee/detail", params)
return self.query("/api/v1/defillama/fee/detail", params)

@postprocess(num_index=-1)
def revenue_detail(
Expand All @@ -352,7 +352,7 @@ def revenue_detail(
) -> Union[List, pd.DataFrame]:
"""Get revenue detail for given protocol and chain
`GET /v1/defillama/revenue/detail`
`GET /api/v1/defillama/revenue/detail`
<https://docs.datamaxiplus.com/api/datasets/defillama/revenue-detail>
Expand All @@ -377,4 +377,4 @@ def revenue_detail(
if chain is not None:
params["chain"] = chain

return self.query("/v1/defillama/revenue/detail", params)
return self.query("/api/v1/defillama/revenue/detail", params)
Loading

0 comments on commit 57709bd

Please sign in to comment.