Skip to content

Interaction

cyhole.dex_screener.DexScreener

DexScreener(headers: Any | None = None)

Bases: Interaction


              flowchart TD
              cyhole.dex_screener.DexScreener[DexScreener]
              cyhole.core.interaction.Interaction[Interaction]

                              cyhole.core.interaction.Interaction --> cyhole.dex_screener.DexScreener
                


              click cyhole.dex_screener.DexScreener href "" "cyhole.dex_screener.DexScreener"
              click cyhole.core.interaction.Interaction href "" "cyhole.core.interaction.Interaction"
            

Class used to connect DexScreener API.

No API key is required for the public endpoints documented here.

Example

import asyncio
from cyhole.dex_screener import DexScreener

dex = DexScreener()

# sync
response = dex.client.get_token_profiles_latest()
print(response.root[0].chain_id)

# async
async def main():
    async with dex.async_client as client:
        response = await client.get_search("SOL/USDC")
        print(response.pairs[0].pair_address)

asyncio.run(main())
Source code in src/cyhole/dex_screener/interaction.py
48
49
50
51
52
def __init__(self, headers: Any | None = None) -> None:
    super().__init__(headers)
    self.client = DexScreenerClient(self)
    self.async_client = DexScreenerAsyncClient(self)
    self.url_api = "https://api.dexscreener.com/"

_get_token_profiles_latest

_get_token_profiles_latest(
    sync: Literal[True],
) -> GetTokenProfilesLatestResponse
_get_token_profiles_latest(
    sync: Literal[False],
) -> Coroutine[None, None, GetTokenProfilesLatestResponse]
_get_token_profiles_latest(
    sync: bool,
) -> (
    GetTokenProfilesLatestResponse
    | Coroutine[None, None, GetTokenProfilesLatestResponse]
)

This function refers to the GET Token Profiles Latest API endpoint.

Parameters:

Name Type Description Default
sync bool

if True run synchronously, else return a coroutine.

required

Returns:

Name Type Description
GetTokenProfilesLatestResponse GetTokenProfilesLatestResponse | Coroutine[None, None, GetTokenProfilesLatestResponse]

list of the newest token profiles.

Raises:

Type Description
DexScreenerException

if the API returns an error.

Source code in src/cyhole/dex_screener/interaction.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
def _get_token_profiles_latest(self, sync: bool) -> GetTokenProfilesLatestResponse | Coroutine[None, None, GetTokenProfilesLatestResponse]:
    """
    This function refers to the **GET Token Profiles Latest** API endpoint.

    Parameters:
        sync: if True run synchronously, else return a coroutine.

    Returns:
        GetTokenProfilesLatestResponse: list of the newest token profiles.

    Raises:
        DexScreenerException: if the API returns an error.
    """
    url = self.url_api + "token-profiles/latest/v1"
    return self.api_return_model(sync, RequestType.GET.value, url, GetTokenProfilesLatestResponse)

_get_community_takeover

_get_community_takeover(
    sync: Literal[True],
) -> GetCommunityTakeoverResponse
_get_community_takeover(
    sync: Literal[False],
) -> Coroutine[None, None, GetCommunityTakeoverResponse]
_get_community_takeover(
    sync: bool,
) -> (
    GetCommunityTakeoverResponse
    | Coroutine[None, None, GetCommunityTakeoverResponse]
)

This function refers to the GET Community Takeovers Latest API endpoint.

Parameters:

Name Type Description Default
sync bool

if True run synchronously, else return a coroutine.

required

Returns:

Name Type Description
GetCommunityTakeoverResponse GetCommunityTakeoverResponse | Coroutine[None, None, GetCommunityTakeoverResponse]

list of the latest community takeovers.

Raises:

Type Description
DexScreenerException

if the API returns an error.

Source code in src/cyhole/dex_screener/interaction.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
def _get_community_takeover(self, sync: bool) -> GetCommunityTakeoverResponse | Coroutine[None, None, GetCommunityTakeoverResponse]:
    """
    This function refers to the **GET Community Takeovers Latest** API endpoint.

    Parameters:
        sync: if True run synchronously, else return a coroutine.

    Returns:
        GetCommunityTakeoverResponse: list of the latest community takeovers.

    Raises:
        DexScreenerException: if the API returns an error.
    """
    url = self.url_api + "community-takeovers/latest/v1"
    return self.api_return_model(sync, RequestType.GET.value, url, GetCommunityTakeoverResponse)

_get_ads_latest

_get_ads_latest(
    sync: Literal[True],
) -> GetAdsLatestResponse
_get_ads_latest(
    sync: Literal[False],
) -> Coroutine[None, None, GetAdsLatestResponse]
_get_ads_latest(
    sync: bool,
) -> (
    GetAdsLatestResponse
    | Coroutine[None, None, GetAdsLatestResponse]
)

This function refers to the GET Ads Latest API endpoint.

Parameters:

Name Type Description Default
sync bool

if True run synchronously, else return a coroutine.

required

Returns:

Name Type Description
GetAdsLatestResponse GetAdsLatestResponse | Coroutine[None, None, GetAdsLatestResponse]

list of the latest advertisements.

Raises:

Type Description
DexScreenerException

if the API returns an error.

Source code in src/cyhole/dex_screener/interaction.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
def _get_ads_latest(self, sync: bool) -> GetAdsLatestResponse | Coroutine[None, None, GetAdsLatestResponse]:
    """
    This function refers to the **GET Ads Latest** API endpoint.

    Parameters:
        sync: if True run synchronously, else return a coroutine.

    Returns:
        GetAdsLatestResponse: list of the latest advertisements.

    Raises:
        DexScreenerException: if the API returns an error.
    """
    url = self.url_api + "ads/latest/v1"
    return self.api_return_model(sync, RequestType.GET.value, url, GetAdsLatestResponse)

_get_token_boosts_latest

_get_token_boosts_latest(
    sync: Literal[True],
) -> GetTokenBoostsLatestResponse
_get_token_boosts_latest(
    sync: Literal[False],
) -> Coroutine[None, None, GetTokenBoostsLatestResponse]
_get_token_boosts_latest(
    sync: bool,
) -> (
    GetTokenBoostsLatestResponse
    | Coroutine[None, None, GetTokenBoostsLatestResponse]
)

This function refers to the GET Token Boosts Latest API endpoint.

Parameters:

Name Type Description Default
sync bool

if True run synchronously, else return a coroutine.

required

Returns:

Name Type Description
GetTokenBoostsLatestResponse GetTokenBoostsLatestResponse | Coroutine[None, None, GetTokenBoostsLatestResponse]

list of the latest boosted tokens.

Raises:

Type Description
DexScreenerException

if the API returns an error.

Source code in src/cyhole/dex_screener/interaction.py
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
def _get_token_boosts_latest(self, sync: bool) -> GetTokenBoostsLatestResponse | Coroutine[None, None, GetTokenBoostsLatestResponse]:
    """
    This function refers to the **GET Token Boosts Latest** API endpoint.

    Parameters:
        sync: if True run synchronously, else return a coroutine.

    Returns:
        GetTokenBoostsLatestResponse: list of the latest boosted tokens.

    Raises:
        DexScreenerException: if the API returns an error.
    """
    url = self.url_api + "token-boosts/latest/v1"
    return self.api_return_model(sync, RequestType.GET.value, url, GetTokenBoostsLatestResponse)

_get_token_boosts_top

_get_token_boosts_top(
    sync: Literal[True],
) -> GetTokenBoostsTopResponse
_get_token_boosts_top(
    sync: Literal[False],
) -> Coroutine[None, None, GetTokenBoostsTopResponse]
_get_token_boosts_top(
    sync: bool,
) -> (
    GetTokenBoostsTopResponse
    | Coroutine[None, None, GetTokenBoostsTopResponse]
)

This function refers to the GET Token Boosts Top API endpoint.

Parameters:

Name Type Description Default
sync bool

if True run synchronously, else return a coroutine.

required

Returns:

Name Type Description
GetTokenBoostsTopResponse GetTokenBoostsTopResponse | Coroutine[None, None, GetTokenBoostsTopResponse]

list of tokens with the most active boosts.

Raises:

Type Description
DexScreenerException

if the API returns an error.

Source code in src/cyhole/dex_screener/interaction.py
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
def _get_token_boosts_top(self, sync: bool) -> GetTokenBoostsTopResponse | Coroutine[None, None, GetTokenBoostsTopResponse]:
    """
    This function refers to the **GET Token Boosts Top** API endpoint.

    Parameters:
        sync: if True run synchronously, else return a coroutine.

    Returns:
        GetTokenBoostsTopResponse: list of tokens with the most active boosts.

    Raises:
        DexScreenerException: if the API returns an error.
    """
    url = self.url_api + "token-boosts/top/v1"
    return self.api_return_model(sync, RequestType.GET.value, url, GetTokenBoostsTopResponse)

_get_orders

_get_orders(
    sync: Literal[True], chain_id: str, token_address: str
) -> GetOrdersResponse
_get_orders(
    sync: Literal[False], chain_id: str, token_address: str
) -> Coroutine[None, None, GetOrdersResponse]
_get_orders(
    sync: bool, chain_id: str, token_address: str
) -> (
    GetOrdersResponse
    | Coroutine[None, None, GetOrdersResponse]
)

This function refers to the GET Orders API endpoint.

Parameters:

Name Type Description Default
sync bool

if True run synchronously, else return a coroutine.

required
chain_id str

blockchain identifier (e.g. "solana", "ethereum").

required
token_address str

token contract address.

required

Returns:

Name Type Description
GetOrdersResponse GetOrdersResponse | Coroutine[None, None, GetOrdersResponse]

list of paid orders for the given token.

Raises:

Type Description
DexScreenerException

if the API returns an error.

Source code in src/cyhole/dex_screener/interaction.py
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
def _get_orders(self, sync: bool, chain_id: str, token_address: str) -> GetOrdersResponse | Coroutine[None, None, GetOrdersResponse]:
    """
    This function refers to the **GET Orders** API endpoint.

    Parameters:
        sync: if True run synchronously, else return a coroutine.
        chain_id: blockchain identifier (e.g. ``"solana"``, ``"ethereum"``).
        token_address: token contract address.

    Returns:
        GetOrdersResponse: list of paid orders for the given token.

    Raises:
        DexScreenerException: if the API returns an error.
    """
    url = self.url_api + f"orders/v1/{chain_id}/{token_address}"
    return self.api_return_model(sync, RequestType.GET.value, url, GetOrdersResponse)

_get_pairs

_get_pairs(
    sync: Literal[True], chain_id: str, pair_id: str
) -> GetPairsResponse
_get_pairs(
    sync: Literal[False], chain_id: str, pair_id: str
) -> Coroutine[None, None, GetPairsResponse]
_get_pairs(
    sync: bool, chain_id: str, pair_id: str
) -> (
    GetPairsResponse
    | Coroutine[None, None, GetPairsResponse]
)

This function refers to the GET Pairs API endpoint.

Parameters:

Name Type Description Default
sync bool

if True run synchronously, else return a coroutine.

required
chain_id str

blockchain identifier (e.g. "solana").

required
pair_id str

pair contract address.

required

Returns:

Name Type Description
GetPairsResponse GetPairsResponse | Coroutine[None, None, GetPairsResponse]

pair data for the given chain and pair address.

Raises:

Type Description
DexScreenerException

if the API returns an error.

Source code in src/cyhole/dex_screener/interaction.py
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
def _get_pairs(self, sync: bool, chain_id: str, pair_id: str) -> GetPairsResponse | Coroutine[None, None, GetPairsResponse]:
    """
    This function refers to the **GET Pairs** API endpoint.

    Parameters:
        sync: if True run synchronously, else return a coroutine.
        chain_id: blockchain identifier (e.g. ``"solana"``).
        pair_id: pair contract address.

    Returns:
        GetPairsResponse: pair data for the given chain and pair address.

    Raises:
        DexScreenerException: if the API returns an error.
    """
    url = self.url_api + f"latest/dex/pairs/{chain_id}/{pair_id}"
    return self.api_return_model(sync, RequestType.GET.value, url, GetPairsResponse)

_get_tokens

_get_tokens(
    sync: Literal[True], chain_id: str, token_addresses: str
) -> GetTokensResponse
_get_tokens(
    sync: Literal[False],
    chain_id: str,
    token_addresses: str,
) -> Coroutine[None, None, GetTokensResponse]
_get_tokens(
    sync: bool, chain_id: str, token_addresses: str
) -> (
    GetTokensResponse
    | Coroutine[None, None, GetTokensResponse]
)

This function refers to the GET Tokens API endpoint.

Parameters:

Name Type Description Default
sync bool

if True run synchronously, else return a coroutine.

required
chain_id str

blockchain identifier (e.g. "solana").

required
token_addresses str

comma-separated token addresses (up to 30).

required

Returns:

Name Type Description
GetTokensResponse GetTokensResponse | Coroutine[None, None, GetTokensResponse]

list of pairs for the given token addresses.

Raises:

Type Description
DexScreenerException

if the API returns an error.

Source code in src/cyhole/dex_screener/interaction.py
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
def _get_tokens(self, sync: bool, chain_id: str, token_addresses: str) -> GetTokensResponse | Coroutine[None, None, GetTokensResponse]:
    """
    This function refers to the **GET Tokens** API endpoint.

    Parameters:
        sync: if True run synchronously, else return a coroutine.
        chain_id: blockchain identifier (e.g. ``"solana"``).
        token_addresses: comma-separated token addresses (up to 30).

    Returns:
        GetTokensResponse: list of pairs for the given token addresses.

    Raises:
        DexScreenerException: if the API returns an error.
    """
    url = self.url_api + f"tokens/v1/{chain_id}/{token_addresses}"
    return self.api_return_model(sync, RequestType.GET.value, url, GetTokensResponse)

_get_token_pairs

_get_token_pairs(
    sync: Literal[True], chain_id: str, token_address: str
) -> GetTokenPairsResponse
_get_token_pairs(
    sync: Literal[False], chain_id: str, token_address: str
) -> Coroutine[None, None, GetTokenPairsResponse]
_get_token_pairs(
    sync: bool, chain_id: str, token_address: str
) -> (
    GetTokenPairsResponse
    | Coroutine[None, None, GetTokenPairsResponse]
)

This function refers to the GET Token Pairs API endpoint.

Parameters:

Name Type Description Default
sync bool

if True run synchronously, else return a coroutine.

required
chain_id str

blockchain identifier (e.g. "solana").

required
token_address str

token contract address.

required

Returns:

Name Type Description
GetTokenPairsResponse GetTokenPairsResponse | Coroutine[None, None, GetTokenPairsResponse]

list of all pools for the given token.

Raises:

Type Description
DexScreenerException

if the API returns an error.

Source code in src/cyhole/dex_screener/interaction.py
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
def _get_token_pairs(self, sync: bool, chain_id: str, token_address: str) -> GetTokenPairsResponse | Coroutine[None, None, GetTokenPairsResponse]:
    """
    This function refers to the **GET Token Pairs** API endpoint.

    Parameters:
        sync: if True run synchronously, else return a coroutine.
        chain_id: blockchain identifier (e.g. ``"solana"``).
        token_address: token contract address.

    Returns:
        GetTokenPairsResponse: list of all pools for the given token.

    Raises:
        DexScreenerException: if the API returns an error.
    """
    url = self.url_api + f"token-pairs/v1/{chain_id}/{token_address}"
    return self.api_return_model(sync, RequestType.GET.value, url, GetTokenPairsResponse)
_get_search(
    sync: Literal[True], query: str
) -> GetSearchResponse
_get_search(
    sync: Literal[False], query: str
) -> Coroutine[None, None, GetSearchResponse]
_get_search(
    sync: bool, query: str
) -> (
    GetSearchResponse
    | Coroutine[None, None, GetSearchResponse]
)

This function refers to the GET Search API endpoint.

Parameters:

Name Type Description Default
sync bool

if True run synchronously, else return a coroutine.

required
query str

search query string (e.g. "SOL/USDC").

required

Returns:

Name Type Description
GetSearchResponse GetSearchResponse | Coroutine[None, None, GetSearchResponse]

matching pairs for the given query.

Raises:

Type Description
DexScreenerException

if the API returns an error.

Source code in src/cyhole/dex_screener/interaction.py
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
def _get_search(self, sync: bool, query: str) -> GetSearchResponse | Coroutine[None, None, GetSearchResponse]:
    """
    This function refers to the **GET Search** API endpoint.

    Parameters:
        sync: if True run synchronously, else return a coroutine.
        query: search query string (e.g. ``"SOL/USDC"``).

    Returns:
        GetSearchResponse: matching pairs for the given query.

    Raises:
        DexScreenerException: if the API returns an error.
    """
    url = self.url_api + "latest/dex/search"
    params = {"q": query}
    return self.api_return_model(sync, RequestType.GET.value, url, GetSearchResponse, params = params)