diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 91abb11..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,11 +0,0 @@ -# To get started with Dependabot version updates, you'll need to specify which -# package ecosystems to update and where the package manifests are located. -# Please see the documentation for all configuration options: -# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates - -version: 2 -updates: - - package-ecosystem: "pip" # See documentation for possible values - directory: "/" # Location of package manifests - schedule: - interval: "weekly" diff --git a/coinpaprika_async_client/__init__.py b/coinpaprika_async_client/__init__.py index 6d2f224..dfaefd6 100644 --- a/coinpaprika_async_client/__init__.py +++ b/coinpaprika_async_client/__init__.py @@ -1,26 +1,19 @@ from .__version__ import __title__, __description__, __version__ -from .api import ( - CoinPaprikaAsyncClient, - CoinpaprikaAPI, - CoinsEndpoint, - ExchangesEndpoint, - KeyEndpoint, - MarketEndpoint, - MiscellaneousEndpoints, - PeopleEndpoint, - TagsEndpoint, - TickersEndpoint, - ApiError, - Result, -) +from .coins import * +from .exchanges import * +from .key import * +from .market import * +from .people import * +from .misc import * +from .tags import * +from .tickers import * + __all__ = [ "__description__", "__title__", "__version__", - "CoinPaprikaAsyncClient", - "CoinpaprikaAPI", "CoinsEndpoint", "ExchangesEndpoint", "KeyEndpoint", @@ -30,5 +23,4 @@ "TagsEndpoint", "TickersEndpoint", "ApiError", - "Result", ] diff --git a/coinpaprika_async_client/api/__init__.py b/coinpaprika_async_client/api/__init__.py deleted file mode 100644 index 7a10a12..0000000 --- a/coinpaprika_async_client/api/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -from .coins import * -from .exchanges import * -from .key import * -from .market import * -from .people import * -from .misc import * -from .tags import * -from .tickers import * - -from .coinpaprika_api import * diff --git a/coinpaprika_async_client/api/coinpaprika_api.py b/coinpaprika_async_client/api/coinpaprika_api.py deleted file mode 100644 index 6f4aa16..0000000 --- a/coinpaprika_async_client/api/coinpaprika_api.py +++ /dev/null @@ -1,7 +0,0 @@ -from typing import Optional -from .networking_layer import CoinPaprikaAsyncClient - - -class CoinpaprikaAPI: - def __init__(self) -> None: - self.internal = CoinPaprikaAsyncClient() diff --git a/coinpaprika_async_client/api/market/api.py b/coinpaprika_async_client/api/market/api.py deleted file mode 100644 index d26acb5..0000000 --- a/coinpaprika_async_client/api/market/api.py +++ /dev/null @@ -1,13 +0,0 @@ -from coinpaprika_async_client.api.networking_layer.http_models import ApiError -from .models import MarketData -from ..coinpaprika_api import CoinpaprikaAPI - - -class MarketEndpoint(CoinpaprikaAPI): - async def get_market_info(self) -> ApiError | MarketData: - res = await self.internal.call_api("global") - - if res.Error: - return res.Error - - return MarketData(**res.Data) diff --git a/coinpaprika_async_client/api/networking_layer/__init__.py b/coinpaprika_async_client/api/networking_layer/__init__.py deleted file mode 100644 index 26cf32e..0000000 --- a/coinpaprika_async_client/api/networking_layer/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .coinpaprika_async_client import CoinPaprikaAsyncClient -from .http_models import ApiError, Result -from .http_async_client import HttpAsyncClient diff --git a/coinpaprika_async_client/client/__init__.py b/coinpaprika_async_client/client/__init__.py new file mode 100644 index 0000000..db457a1 --- /dev/null +++ b/coinpaprika_async_client/client/__init__.py @@ -0,0 +1 @@ +from .coinpaprika_async_client import CoinPaprikaAsyncClient diff --git a/coinpaprika_async_client/api/networking_layer/coinpaprika_async_client.py b/coinpaprika_async_client/client/coinpaprika_async_client.py similarity index 95% rename from coinpaprika_async_client/api/networking_layer/coinpaprika_async_client.py rename to coinpaprika_async_client/client/coinpaprika_async_client.py index 6ff28be..77c9df3 100644 --- a/coinpaprika_async_client/api/networking_layer/coinpaprika_async_client.py +++ b/coinpaprika_async_client/client/coinpaprika_async_client.py @@ -1,6 +1,6 @@ from typing import Any, Optional -from . import Result, HttpAsyncClient +from ..networking_layer import HttpAsyncClient, Result class CoinPaprikaAsyncClient: diff --git a/coinpaprika_async_client/api/coins/__init__.py b/coinpaprika_async_client/coins/__init__.py similarity index 100% rename from coinpaprika_async_client/api/coins/__init__.py rename to coinpaprika_async_client/coins/__init__.py diff --git a/coinpaprika_async_client/api/coins/api.py b/coinpaprika_async_client/coins/api.py similarity index 89% rename from coinpaprika_async_client/api/coins/api.py rename to coinpaprika_async_client/coins/api.py index 12b2e66..eaaa9fd 100644 --- a/coinpaprika_async_client/api/coins/api.py +++ b/coinpaprika_async_client/coins/api.py @@ -1,11 +1,16 @@ +from ..client import CoinPaprikaAsyncClient + from ..networking_layer import Result, ApiError -from ..coinpaprika_api import CoinpaprikaAPI + from .models import * -class CoinsEndpoint(CoinpaprikaAPI): +class CoinsEndpoint: + def __init__(self) -> None: + self.__internal = CoinPaprikaAsyncClient() + async def get_all(self) -> ApiError | list[CoinItem]: - res = await self.internal.call_api("coins") + res = await self.__internal.call_api("coins") if res.Error: return res.Error @@ -13,7 +18,7 @@ async def get_all(self) -> ApiError | list[CoinItem]: return [CoinItem(**e) for e in res.Data] async def coin_by_id(self, coin_id: str) -> Result: - return await self.internal.call_api(f"coins/{coin_id}") + return await self.__internal.call_api(f"coins/{coin_id}") async def tweets_of_coin( self, coin_id: str @@ -23,7 +28,7 @@ async def tweets_of_coin( Args: coin_id: Required id for the coin """ - res = await self.internal.call_api(f"coins/{coin_id}/twitter") + res = await self.__internal.call_api(f"coins/{coin_id}/twitter") if res.Error: return res.Error @@ -38,7 +43,7 @@ async def events_of_coin( Args: coin_id: Required id for the coin """ - res = await self.internal.call_api(f"coins/{coin_id}/events") + res = await self.__internal.call_api(f"coins/{coin_id}/events") if res.Error: return res.Error @@ -53,7 +58,7 @@ async def exchanges_of_coin( Args: coin_id: Required id for the coin """ - res = await self.internal.call_api(f"coins/{coin_id}/exchanges") + res = await self.__internal.call_api(f"coins/{coin_id}/exchanges") if res.Error: return res.Error @@ -77,7 +82,7 @@ async def markets_of_coin( coin_id: Required id for the coin quotes: Comma separated list of quotes to return. Currently allowed values: BTC, ETH, USD, EUR, PLN, KRW, GBP, CAD, JPY, RUB, TRY, NZD, AUD, CHF, UAH, HKD, SGD, NGN, PHP, MXN, BRL, THB, CLP, CNY, CZK, DKK, HUF, IDR, ILS, INR, MYR, NOK, PKR, SEK, TWD, ZAR, VND, BOB, COP, PEN, ARS and ISK. """ - res = await self.internal.call_api( + res = await self.__internal.call_api( f"coins/{coin_id}/markets", quotes=quotes ) @@ -115,7 +120,7 @@ async def latest_ohlcv( coin_id: Required id for the coin quote: returned data quote (available values: usd & btc). """ - res = await self.internal.call_api( + res = await self.__internal.call_api( f"coins/{coin_id}/ohlcv/latest", quote=quote, ) @@ -141,7 +146,7 @@ async def historical_ohlcv( interval: returned OHLCV point interval (available values: 15m, 30m, 1h, 6h, 12h, 24h) quote: returned data quote (available values: usd & btc) """ - res = await self.internal.call_api( + res = await self.__internal.call_api( f"coins/{coin_id}/ohlcv/historical", start=start, end=end, @@ -160,7 +165,7 @@ async def ohlcv_of_today( coin_id: Required id for the coin quote: returned data quote (available values: usd & btc) """ - res = await self.internal.call_api( + res = await self.__internal.call_api( f"coins/{coin_id}/ohlcv/today", quote=quote, ) diff --git a/coinpaprika_async_client/api/coins/models.py b/coinpaprika_async_client/coins/models.py similarity index 100% rename from coinpaprika_async_client/api/coins/models.py rename to coinpaprika_async_client/coins/models.py diff --git a/coinpaprika_async_client/api/exchanges/__init__.py b/coinpaprika_async_client/exchanges/__init__.py similarity index 100% rename from coinpaprika_async_client/api/exchanges/__init__.py rename to coinpaprika_async_client/exchanges/__init__.py diff --git a/coinpaprika_async_client/api/exchanges/api.py b/coinpaprika_async_client/exchanges/api.py similarity index 61% rename from coinpaprika_async_client/api/exchanges/api.py rename to coinpaprika_async_client/exchanges/api.py index 8c4a00e..2bbf34c 100644 --- a/coinpaprika_async_client/api/exchanges/api.py +++ b/coinpaprika_async_client/exchanges/api.py @@ -1,14 +1,18 @@ -from typing import Optional, Any +from typing import Any -from coinpaprika_async_client.api.networking_layer.http_models import ApiError +from ..client import CoinPaprikaAsyncClient + +from ..networking_layer import ApiError -from ..coinpaprika_api import CoinpaprikaAPI from .models import * -class ExchangesEndpoint(CoinpaprikaAPI): +class ExchangesEndpoint: + def __init__(self) -> None: + self.__internal = CoinPaprikaAsyncClient() + async def exchange_list(self, **params: Any) -> ApiError | list[Exchange]: - res = await self.internal.call_api("exchanges", **params) + res = await self.__internal.call_api("exchanges", **params) if res.Error: return res.Error @@ -18,7 +22,9 @@ async def exchange_list(self, **params: Any) -> ApiError | list[Exchange]: async def get_exchange( self, exchange_id: str, **params: Any ) -> ApiError | Exchange: - res = await self.internal.call_api(f"exchanges/{exchange_id}", **params) + res = await self.__internal.call_api( + f"exchanges/{exchange_id}", **params + ) if res.Error: return res.Error @@ -28,7 +34,7 @@ async def get_exchange( async def exchange_markets( self, exchange_id: str, **params: Any ) -> ApiError | ExchangeMarket: - res = await self.internal.call_api( + res = await self.__internal.call_api( f"exchanges/{exchange_id}/markets", **params ) diff --git a/coinpaprika_async_client/api/exchanges/models.py b/coinpaprika_async_client/exchanges/models.py similarity index 100% rename from coinpaprika_async_client/api/exchanges/models.py rename to coinpaprika_async_client/exchanges/models.py diff --git a/coinpaprika_async_client/api/key/__init__.py b/coinpaprika_async_client/key/__init__.py similarity index 100% rename from coinpaprika_async_client/api/key/__init__.py rename to coinpaprika_async_client/key/__init__.py diff --git a/coinpaprika_async_client/api/key/api.py b/coinpaprika_async_client/key/api.py similarity index 78% rename from coinpaprika_async_client/api/key/api.py rename to coinpaprika_async_client/key/api.py index 927500d..051cca5 100644 --- a/coinpaprika_async_client/api/key/api.py +++ b/coinpaprika_async_client/key/api.py @@ -1,13 +1,18 @@ from typing import Dict, Any +from ..client import CoinPaprikaAsyncClient + from ..networking_layer import ApiError -from ..coinpaprika_api import CoinpaprikaAPI + from .models import KeyInfo, APIUsage, CurrentMonthUsage -class KeyEndpoint(CoinpaprikaAPI): +class KeyEndpoint: + def __init__(self) -> None: + self.__internal = CoinPaprikaAsyncClient() + async def get_key_info(self) -> ApiError | KeyInfo: - res = await self.internal.call_api("key/info") + res = await self.__internal.call_api("key/info") if res.Error: return res.Error diff --git a/coinpaprika_async_client/api/key/models.py b/coinpaprika_async_client/key/models.py similarity index 100% rename from coinpaprika_async_client/api/key/models.py rename to coinpaprika_async_client/key/models.py diff --git a/coinpaprika_async_client/api/market/__init__.py b/coinpaprika_async_client/market/__init__.py similarity index 100% rename from coinpaprika_async_client/api/market/__init__.py rename to coinpaprika_async_client/market/__init__.py diff --git a/coinpaprika_async_client/market/api.py b/coinpaprika_async_client/market/api.py new file mode 100644 index 0000000..570c090 --- /dev/null +++ b/coinpaprika_async_client/market/api.py @@ -0,0 +1,18 @@ +from ..client import CoinPaprikaAsyncClient + +from ..networking_layer import ApiError + +from .models import MarketData + + +class MarketEndpoint: + def __init__(self) -> None: + self.__internal = CoinPaprikaAsyncClient() + + async def get_market_info(self) -> ApiError | MarketData: + res = await self.__internal.call_api("global") + + if res.Error: + return res.Error + + return MarketData(**res.Data) diff --git a/coinpaprika_async_client/api/market/models.py b/coinpaprika_async_client/market/models.py similarity index 100% rename from coinpaprika_async_client/api/market/models.py rename to coinpaprika_async_client/market/models.py diff --git a/coinpaprika_async_client/api/misc/__init__.py b/coinpaprika_async_client/misc/__init__.py similarity index 100% rename from coinpaprika_async_client/api/misc/__init__.py rename to coinpaprika_async_client/misc/__init__.py diff --git a/coinpaprika_async_client/api/misc/api.py b/coinpaprika_async_client/misc/api.py similarity index 90% rename from coinpaprika_async_client/api/misc/api.py rename to coinpaprika_async_client/misc/api.py index 87f162d..14e5619 100644 --- a/coinpaprika_async_client/api/misc/api.py +++ b/coinpaprika_async_client/misc/api.py @@ -1,13 +1,18 @@ from typing import Optional, Any, Dict, List +from ..client import CoinPaprikaAsyncClient + from ..networking_layer import ApiError -from ..coinpaprika_api import CoinpaprikaAPI + from .models import * -class MiscellaneousEndpoints(CoinpaprikaAPI): +class MiscellaneousEndpoints: + def __init__(self) -> None: + self.__internal = CoinPaprikaAsyncClient() + async def people(self, person_id: str) -> ApiError | list[PeopleItem]: - res = await self.internal.call_api(f"people/{person_id}") + res = await self.__internal.call_api(f"people/{person_id}") if res.Error: return res.Error @@ -58,7 +63,7 @@ async def search( Returns: A list of the search result items. """ - res = await self.internal.call_api( + res = await self.__internal.call_api( "search", q=q, c=categories, @@ -87,7 +92,7 @@ async def price_converter( quote_currency_id: str, amount: Optional[int] = 0, ) -> ApiError | ConvertResult: - res = await self.internal.call_api( + res = await self.__internal.call_api( "price-converter", base_currency_id=base_currency_id, quote_currency_id=quote_currency_id, diff --git a/coinpaprika_async_client/api/misc/models.py b/coinpaprika_async_client/misc/models.py similarity index 100% rename from coinpaprika_async_client/api/misc/models.py rename to coinpaprika_async_client/misc/models.py diff --git a/coinpaprika_async_client/networking_layer/__init__.py b/coinpaprika_async_client/networking_layer/__init__.py new file mode 100644 index 0000000..c7f4f5a --- /dev/null +++ b/coinpaprika_async_client/networking_layer/__init__.py @@ -0,0 +1,2 @@ +from .http_async_client import * +from .http_models import * diff --git a/coinpaprika_async_client/api/networking_layer/http_async_client.py b/coinpaprika_async_client/networking_layer/http_async_client.py similarity index 100% rename from coinpaprika_async_client/api/networking_layer/http_async_client.py rename to coinpaprika_async_client/networking_layer/http_async_client.py diff --git a/coinpaprika_async_client/api/networking_layer/http_models.py b/coinpaprika_async_client/networking_layer/http_models.py similarity index 100% rename from coinpaprika_async_client/api/networking_layer/http_models.py rename to coinpaprika_async_client/networking_layer/http_models.py diff --git a/coinpaprika_async_client/api/people/__init__.py b/coinpaprika_async_client/people/__init__.py similarity index 100% rename from coinpaprika_async_client/api/people/__init__.py rename to coinpaprika_async_client/people/__init__.py diff --git a/coinpaprika_async_client/api/people/api.py b/coinpaprika_async_client/people/api.py similarity index 82% rename from coinpaprika_async_client/api/people/api.py rename to coinpaprika_async_client/people/api.py index 2f91bbc..1163872 100644 --- a/coinpaprika_async_client/api/people/api.py +++ b/coinpaprika_async_client/people/api.py @@ -1,13 +1,18 @@ from typing import Any, Dict, List +from ..client import CoinPaprikaAsyncClient + from ..networking_layer import ApiError -from ..coinpaprika_api import CoinpaprikaAPI + from .models import * -class PeopleEndpoint(CoinpaprikaAPI): +class PeopleEndpoint: + def __init__(self) -> None: + self.__internal = CoinPaprikaAsyncClient() + async def people(self, person_id: str) -> ApiError | list[PeopleItem]: - res = await self.internal.call_api(f"people/{person_id}") + res = await self.__internal.call_api(f"people/{person_id}") if res.Error: return res.Error diff --git a/coinpaprika_async_client/api/people/models.py b/coinpaprika_async_client/people/models.py similarity index 100% rename from coinpaprika_async_client/api/people/models.py rename to coinpaprika_async_client/people/models.py diff --git a/coinpaprika_async_client/api/tags/__init__.py b/coinpaprika_async_client/tags/__init__.py similarity index 100% rename from coinpaprika_async_client/api/tags/__init__.py rename to coinpaprika_async_client/tags/__init__.py diff --git a/coinpaprika_async_client/api/tags/api.py b/coinpaprika_async_client/tags/api.py similarity index 75% rename from coinpaprika_async_client/api/tags/api.py rename to coinpaprika_async_client/tags/api.py index 5677f16..c292acf 100644 --- a/coinpaprika_async_client/api/tags/api.py +++ b/coinpaprika_async_client/tags/api.py @@ -1,15 +1,20 @@ from typing import Dict, List, Any, Optional +from ..client import CoinPaprikaAsyncClient + from ..networking_layer import ApiError -from ..coinpaprika_api import CoinpaprikaAPI + from .models import * -class TagsEndpoint(CoinpaprikaAPI): +class TagsEndpoint: + def __init__(self) -> None: + self.__internal = CoinPaprikaAsyncClient() + async def tags( self, additional_fields: Optional[str] = None ) -> ApiError | list[Tag]: - res = await self.internal.call_api( + res = await self.__internal.call_api( "tags", additional_fields=additional_fields ) @@ -23,7 +28,7 @@ async def tags( async def tag( self, tag_id: str, additional_fields: Optional[str] = None ) -> ApiError | Tag: - res = await self.internal.call_api( + res = await self.__internal.call_api( f"tags/{tag_id}", additional_fields=additional_fields ) diff --git a/coinpaprika_async_client/api/tags/models.py b/coinpaprika_async_client/tags/models.py similarity index 100% rename from coinpaprika_async_client/api/tags/models.py rename to coinpaprika_async_client/tags/models.py diff --git a/coinpaprika_async_client/api/tickers/__init__.py b/coinpaprika_async_client/tickers/__init__.py similarity index 100% rename from coinpaprika_async_client/api/tickers/__init__.py rename to coinpaprika_async_client/tickers/__init__.py diff --git a/coinpaprika_async_client/api/tickers/api.py b/coinpaprika_async_client/tickers/api.py similarity index 85% rename from coinpaprika_async_client/api/tickers/api.py rename to coinpaprika_async_client/tickers/api.py index 3ea007f..489460f 100644 --- a/coinpaprika_async_client/api/tickers/api.py +++ b/coinpaprika_async_client/tickers/api.py @@ -1,13 +1,18 @@ from typing import Optional, List, Dict, Any +from ..client import CoinPaprikaAsyncClient + from ..networking_layer import ApiError -from ..coinpaprika_api import CoinpaprikaAPI + from .models import * -class TickersEndpoint(CoinpaprikaAPI): +class TickersEndpoint: + def __init__(self) -> None: + self.__internal = CoinPaprikaAsyncClient() + async def tickers(self, quotes: str = "USD") -> ApiError | list[TickerItem]: - res = await self.internal.call_api("tickers", quotes=quotes) + res = await self.__internal.call_api("tickers", quotes=quotes) if res.Error: return res.Error @@ -33,7 +38,9 @@ async def tickers(self, quotes: str = "USD") -> ApiError | list[TickerItem]: async def ticker_by_coin( self, coin_id: str, quotes: str = "USD" ) -> ApiError | list[TickerItem]: - res = await self.internal.call_api(f"tickers/{coin_id}", quotes=quotes) + res = await self.__internal.call_api( + f"tickers/{coin_id}", quotes=quotes + ) if res.Error: return res.Error @@ -66,7 +73,7 @@ async def historical_ticks( quotes: str = "USD", interval: str = "5m", ) -> ApiError | list[HistoryTickerItem]: - res = await self.internal.call_api( + res = await self.__internal.call_api( f"tickers/{coin_id}/historical", start=start, end=end, diff --git a/coinpaprika_async_client/api/tickers/models.py b/coinpaprika_async_client/tickers/models.py similarity index 100% rename from coinpaprika_async_client/api/tickers/models.py rename to coinpaprika_async_client/tickers/models.py diff --git a/pyproject.toml b/pyproject.toml index abee3fa..b0990e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] -name = "coinpaprika-async-client" -version = "0.1.0" -description = "" +name = "coinpaprika-async" +version = "3.1.0" +description = "An asynchronous library for interacting with the Coinpaprika.com API, written with httpx in Python." authors = ["DroidZed <41507665+DroidZed@users.noreply.github.com>"] readme = "README.md" packages = [{ include = "coinpaprika_async_client" }] @@ -27,7 +27,7 @@ build-backend = "poetry.core.masonry.api" [tool.black] line-length = 80 -target-version = ['py310'] +target-version = ['py311'] include = '\.pyi?$' [tool.isort]