Skip to content

Interaction

cyhole.jupiter.Jupiter

Jupiter(headers: Any | None = None)

Bases: Interaction

Class used to connect Jupiter API, one of them most popular Solana DEX. To have access Jupiter API is not required an API key.

Check https://station.jup.ag/docs/api for all the details on the available endpoints.

Example

import asyncio
from cyhole.jupiter import Jupiter
from cyhole.core.token.solana import JUP

jupiter = Jupiter()

# Get current price of JUP on Solana
# synchronous
response = jupiter.client.get_price([JUP.address])
print("Current JUP/USDC:", response.data[JUP.address].price)

# asynchronous
async def main() -> None:
    async with jupiter.async_client as client:
        response = await client.get_price([JUP.address])
        print("Current JUP/USDC:", response.data[JUP.address].price)

asyncio.run(main())
Source code in src/cyhole/jupiter/interaction.py
66
67
68
69
70
71
72
73
74
75
76
77
78
def __init__(self, headers: Any | None = None) -> None:
    super().__init__(headers)

    # clients
    self.client = JupiterClient(self)
    self.async_client = JupiterAsyncClient(self)

    # API urls
    self.url_api_price = "https://api.jup.ag/price/v2"
    self.url_api_quote = "https://api.jup.ag/swap/v1/"
    self.url_api_token = "https://api.jup.ag/tokens/v1/"
    self.url_api_limit = "https://jup.ag/api/limit/v1/"
    return

_get_price

_get_price(
    sync: Literal[True],
    address: list[str],
    extra_info: bool = False,
    vs_address: str | None = None,
) -> GetPriceResponse
_get_price(
    sync: Literal[False],
    address: list[str],
    extra_info: bool = False,
    vs_address: str | None = None,
) -> Coroutine[None, None, GetPriceResponse]
_get_price(
    sync: bool,
    address: list[str],
    extra_info: bool = False,
    vs_address: str | None = None,
) -> (
    GetPriceResponse
    | Coroutine[None, None, GetPriceResponse]
)

This function refers to the GET Price API endpoint, and it is used to get the current price of a list of tokens on Solana chain with respect to another token taken from Jupiter Swap.

The API returns the unit buy price for the tokens; by default, the price is provided according to the value of USDC token. It is also possible to provide another comparison token in the request.

Info

Observe that when the token address or comparison token address are not found, the response provided will have a data object with the token address as key and the value will be None.

Parameters:

Name Type Description Default
address list[str]

list of tokens addresses to get the price. For example, So11111111111111111111111111111111111111112.

required
extra_info bool

flag to include extra information in the response that could be useful fot analysis (e.g., last swap, current quote price). More important, if activated, then vs_address is ignored.

False
vs_address str | None

comparison token address. Default Value: None (USDC)

None

Returns:

Type Description
GetPriceResponse | Coroutine[None, None, GetPriceResponse]

tokens' prices.

Source code in src/cyhole/jupiter/interaction.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
def _get_price(self, sync: bool, address: list[str], extra_info: bool = False, vs_address: str | None = None) -> GetPriceResponse | Coroutine[None, None, GetPriceResponse]:
    """
        This function refers to the GET **[Price](https://station.jup.ag/docs/utility/price-api)** API endpoint, 
        and it is used to get the current price of a list of tokens on Solana chain with respect to another token
        taken from [Jupiter Swap](https://jup.ag).

        The API returns the unit buy price for the tokens; by default, the price is provided according to 
        the value of `USDC` token. It is also possible to provide another comparison token in the request.

        !!! info
            Observe that when the token address or comparison token address are not found, 
            the response provided will have a `data` object with the token address as key and
            the value will be `None`.

        Parameters:
            address: list of tokens addresses to get the price.
                For example, `So11111111111111111111111111111111111111112`.
            extra_info: flag to include extra information in the response
                that could be useful fot analysis (e.g., last swap, current quote price).
                More important, if activated, then `vs_address` is ignored.
            vs_address: comparison token address.
                Default Value: `None` (`USDC`)

        Returns:
            tokens' prices.
    """

    # extra_info consistency
    if extra_info:
        vs_address = None

    # set params
    params = {
        "ids": ",".join(address),
        "vsToken": vs_address,
        "showExtraInfo": "true" if extra_info else "false"
    }

    # execute request
    if sync:
        content_raw = self.client.api(RequestType.GET.value, self.url_api_price, params = params)
        return GetPriceResponse(**content_raw.json())
    else:
        async def async_request():
            content_raw = await self.async_client.api(RequestType.GET.value, self.url_api_price, params = params)
            return GetPriceResponse(**content_raw.json())
        return async_request()

_get_quote

_get_quote(
    sync: Literal[True], input: GetQuoteInput
) -> GetQuoteResponse
_get_quote(
    sync: Literal[False], input: GetQuoteInput
) -> Coroutine[None, None, GetQuoteResponse]
_get_quote(
    sync: bool, input: GetQuoteInput
) -> (
    GetQuoteResponse
    | Coroutine[None, None, GetQuoteResponse]
)

This function refers to the GET Quote API endpoint, and it is used to get a quote for swapping a specific amount of tokens.
The function can be combined with the post_swap enpdpoint to implement a payment mechanism.

Parameters:

Name Type Description Default
input GetQuoteInput

an input schema used to describe the request. More details in the object definition.

required

Returns:

Type Description
GetQuoteResponse | Coroutine[None, None, GetQuoteResponse]

Quote found by Jupiter API.

Source code in src/cyhole/jupiter/interaction.py
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
def _get_quote(self, sync: bool, input: GetQuoteInput) -> GetQuoteResponse | Coroutine[None, None, GetQuoteResponse]:
    """
        This function refers to the GET **[Quote](https://station.jup.ag/docs/api/quote)** API endpoint, 
        and it is used to get a quote for swapping a specific amount of tokens.  
        The function can be combined with the `post_swap` enpdpoint to implement a payment mechanism.

        Parameters:
            input: an input schema used to describe the request.
                More details in the object definition.

        Returns:
            Quote found by Jupiter API.
    """
    # set params
    url = self.url_api_quote + "quote"
    params = input.model_dump(
        by_alias = True, 
        exclude_defaults = True
    )

    # execute request
    if sync:
        try:
            content_raw = self.client.api(RequestType.GET.value, url, params = params)
        except HTTPError as e:
            raise self._raise(e)
        return GetQuoteResponse(**content_raw.json())
    else:
        async def async_request():
            try:
                content_raw = await self.async_client.api(RequestType.GET.value, url, params = params)
            except HTTPError as e:
                raise self._raise(e)
            return GetQuoteResponse(**content_raw.json())
        return async_request()

_get_quote_tokens

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

This function refers to the GET Quote Tokens API endpoint, and it is used to get the list of the current supported tradable tokens.

Returns:

Type Description
GetQuoteTokensResponse | Coroutine[None, None, GetQuoteTokensResponse]

List of tradable tokens.

Source code in src/cyhole/jupiter/interaction.py
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
def _get_quote_tokens(self, sync: bool) -> GetQuoteTokensResponse | Coroutine[None, None, GetQuoteTokensResponse]:
    """
        This function refers to the GET **[Quote Tokens](https://station.jup.ag/api-v6/get-tokens)** API endpoint, 
        and it is used to get the list of the current supported tradable tokens. 

        Returns:
            List of tradable tokens.
    """
    # set params
    url = self.url_api_quote + "tokens"

    # execute request
    if sync:
        content_raw = self.client.api(RequestType.GET.value, url)
        return GetQuoteTokensResponse(tokens = content_raw.json())
    else:
        async def async_request():
            content_raw = await self.async_client.api(RequestType.GET.value, url)
            return GetQuoteTokensResponse(tokens = content_raw.json())
        return async_request()

_get_quote_program_id_label

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

This function refers to the GET Quote Program ID to Label API endpoint, and it is used to get the list of supported DEXes to use in quote endpoint.

Returns:

Type Description
GetQuoteProgramIdLabelResponse | Coroutine[None, None, GetQuoteProgramIdLabelResponse]

List of DEXs addresses and labels.

Source code in src/cyhole/jupiter/interaction.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
def _get_quote_program_id_label(self, sync: bool) -> GetQuoteProgramIdLabelResponse | Coroutine[None, None, GetQuoteProgramIdLabelResponse]:
    """
        This function refers to the GET **[Quote Program ID to Label](https://api.jup.ag/swap/v1/program-id-to-label)** API endpoint, 
        and it is used to get the list of supported DEXes to use in quote endpoint. 

        Returns:
            List of DEXs addresses and labels.
    """
    # set params
    url = self.url_api_quote + "program-id-to-label"

    # execute request
    if sync:
        content_raw = self.client.api(RequestType.GET.value, url)
        return GetQuoteProgramIdLabelResponse(dexes = content_raw.json())
    else:
        async def async_request():
            content_raw = await self.async_client.api(RequestType.GET.value, url)
            return GetQuoteProgramIdLabelResponse(dexes = content_raw.json())
        return async_request()

_post_swap

_post_swap(
    sync: Literal[True], body: PostSwapBody
) -> PostSwapResponse
_post_swap(
    sync: Literal[False], body: PostSwapBody
) -> Coroutine[None, None, PostSwapResponse]
_post_swap(
    sync: bool, body: PostSwapBody
) -> (
    PostSwapResponse
    | Coroutine[None, None, PostSwapResponse]
)

This function refers to the POST Swap API endpoint, and it is used to recive the transaction to perform the swap initialised from get_quote endopoint for the desired pair.
The function should be combined with the get_quote endpoint.

Parameters:

Name Type Description Default
body PostSwapBody

the body to sent to Jupiter API that describe the swap. More details in the object definition.

required

Returns:

Type Description
PostSwapResponse | Coroutine[None, None, PostSwapResponse]

Transaction found by Jupiter API.

Source code in src/cyhole/jupiter/interaction.py
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
def _post_swap(self, sync: bool, body: PostSwapBody) -> PostSwapResponse | Coroutine[None, None, PostSwapResponse]:
    """
        This function refers to the POST **[Swap](https://station.jup.ag/api-v6/post-swap)** API endpoint, 
        and it is used to recive the transaction to perform the swap initialised from `get_quote` 
        endopoint for the desired pair.  
        The function should be combined with the `get_quote` endpoint.

        Parameters:
            body: the body to sent to Jupiter API that describe the swap.
                More details in the object definition.

        Returns:
            Transaction found by Jupiter API.
    """
    # set params
    url = self.url_api_quote + "swap"
    headers = {
        "Content-Type": "application/json"
    }

    # execute request
    if sync:
        try:
            content_raw = self.client.api(
                type = RequestType.POST.value,
                url = url,
                headers = headers,
                json = body.model_dump(by_alias = True, exclude_defaults = True)
            )
        except HTTPError as e:
            raise self._raise(e)
        return PostSwapResponse(**content_raw.json())
    else:
        async def async_request():
            try:
                content_raw = await self.async_client.api(
                    type = RequestType.POST.value,
                    url = url,
                    headers = headers,
                    json = body.model_dump(by_alias = True, exclude_defaults = True)
                )
            except HTTPError as e:
                raise self._raise(e)
            return PostSwapResponse(**content_raw.json())
        return async_request()

_get_token_info

_get_token_info(
    sync: Literal[True], address: str
) -> GetTokenInfoResponse
_get_token_info(
    sync: Literal[False], address: str
) -> Coroutine[None, None, GetTokenInfoResponse]
_get_token_info(
    sync: bool, address: str
) -> (
    GetTokenInfoResponse
    | Coroutine[None, None, GetTokenInfoResponse]
)

This function refers to the GET Token API endpoint, with a specific focus on retrieving the information of a token given its address.

Parameters:

Name Type Description Default
address str

address of the token to check. For example, So11111111111111111111111111111111111111112.

required

Returns:

Type Description
GetTokenInfoResponse | Coroutine[None, None, GetTokenInfoResponse]

Information of the token.

Source code in src/cyhole/jupiter/interaction.py
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
def _get_token_info(self, sync: bool, address: str) -> GetTokenInfoResponse | Coroutine[None, None, GetTokenInfoResponse]:
    """
        This function refers to the GET **[Token](https://station.jup.ag/docs/api/token-information)** API endpoint,
        with a specific focus on retrieving the information of a token given its address.

        Parameters:
            address: address of the token to check.
                For example, `So11111111111111111111111111111111111111112`.

        Returns:
            Information of the token.
    """
    # set url
    url = self.url_api_token + address

    # execute request
    if sync:
        content_raw = self.client.api(RequestType.GET.value, url)
        return GetTokenInfoResponse(**content_raw.json())
    else:
        async def async_request():
            content_raw = await self.async_client.api(RequestType.GET.value, url)
            return GetTokenInfoResponse(**content_raw.json())
        return async_request()

_get_token_market_mints

_get_token_market_mints(
    sync: Literal[True], address: str
) -> GetTokenMarketMintsResponse
_get_token_market_mints(
    sync: Literal[False], address: str
) -> Coroutine[None, None, GetTokenMarketMintsResponse]
_get_token_market_mints(
    sync: bool, address: str
) -> (
    GetTokenMarketMintsResponse
    | Coroutine[None, None, GetTokenMarketMintsResponse]
)

This function refers to the GET Token Market Mints API endpoint, and can be used to retrieve the list of token addresses that belong to a market/pool address.

Parameters:

Name Type Description Default
address str

address of the market/pool to check.

required

Returns:

Type Description
GetTokenMarketMintsResponse | Coroutine[None, None, GetTokenMarketMintsResponse]

List of token addresses.

Source code in src/cyhole/jupiter/interaction.py
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
def _get_token_market_mints(self, sync: bool, address: str) -> GetTokenMarketMintsResponse | Coroutine[None, None, GetTokenMarketMintsResponse]:
    """
        This function refers to the GET **[Token Market Mints](https://station.jup.ag/docs/api/mints-in-market)** API endpoint,
        and can be used to retrieve the list of token addresses that belong to a market/pool address.

        Parameters:
            address: address of the market/pool to check.

        Returns:
            List of token addresses.
    """
    # set url
    url = self.url_api_token + f"market/{address}/mints"

    # execute request
    if sync:
        content_raw = self.client.api(RequestType.GET.value, url)
        return GetTokenMarketMintsResponse(mints = content_raw.json())
    else:
        async def async_request():
            content_raw = await self.async_client.api(RequestType.GET.value, url)
            return GetTokenMarketMintsResponse(mints = content_raw.json())
        return async_request()

_get_token_tagged

_get_token_tagged(
    sync: Literal[True], tag: str | JupiterTokenTagType
) -> GetTokenTaggedResponse
_get_token_tagged(
    sync: Literal[False], tag: str | JupiterTokenTagType
) -> Coroutine[None, None, GetTokenTaggedResponse]
_get_token_tagged(
    sync: bool, tag: str | JupiterTokenTagType
) -> (
    GetTokenTaggedResponse
    | Coroutine[None, None, GetTokenTaggedResponse]
)

This function refers to the GET Tagged Token API endpoint, and it is used to retrieved the list of tokens eligible for trading, managed by Jupiter.
Choose the tokens list according to tag field.

Parameters:

Name Type Description Default
tag str | JupiterTokenTagType

Jupiter manages the tradable tokens through a set of tags in order to guarantee its core values and provide a secure service. The supported tages are available on JupiterTokenTagType.

required

Returns:

Type Description
GetTokenTaggedResponse | Coroutine[None, None, GetTokenTaggedResponse]

List of Jupiter's tokens list.

Source code in src/cyhole/jupiter/interaction.py
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
def _get_token_tagged(self, sync: bool, tag: str | JupiterTokenTagType) -> GetTokenTaggedResponse | Coroutine[None, None, GetTokenTaggedResponse]:
    """
        This function refers to the GET **[Tagged Token](https://station.jup.ag/docs/api/tagged)** API endpoint, 
        and it is used to retrieved the list of tokens eligible for trading, managed by Jupiter.  
        Choose the tokens list according to `tag` field.

        Parameters:
            tag: Jupiter manages the tradable tokens through a set of tags in order to guarantee its 
                core values and provide a secure service. The supported tages are available on [`JupiterTokenTagType`][cyhole.jupiter.param.JupiterTokenTagType].

        Returns:
            List of Jupiter's tokens list.
    """
    # check param consistency
    tag_str = tag if isinstance(tag, str) else tag.value
    JupiterTokenTagType.check(tag_str)

    # set params
    url = self.url_api_token + "tagged/" + tag_str

    # execute request
    if sync:
        content_raw = self.client.api(RequestType.GET.value, url)
        return GetTokenTaggedResponse(tokens = content_raw.json())
    else:
        async def async_request():
            content_raw = await self.async_client.api(RequestType.GET.value, url)
            return GetTokenTaggedResponse(tokens = content_raw.json())
        return async_request()

_get_token_new

_get_token_new(
    sync: Literal[True],
    limit: int = 10,
    offset: int | None = None,
) -> GetTokenNewResponse
_get_token_new(
    sync: Literal[False],
    limit: int = 10,
    offset: int | None = None,
) -> Coroutine[None, None, GetTokenNewResponse]
_get_token_new(
    sync: bool, limit: int = 10, offset: int | None = None
) -> (
    GetTokenNewResponse
    | Coroutine[None, None, GetTokenNewResponse]
)

This function refers to the GET New Token API endpoint, and it is used to retrieved the list of new tokens managed by Jupiter.

Parameters:

Name Type Description Default
limit int

number of tokens to retrieve.

10
offset int | None

number of tokens to skip.

None

Returns:

Type Description
GetTokenNewResponse | Coroutine[None, None, GetTokenNewResponse]

List of Jupiter's tokens list.

Source code in src/cyhole/jupiter/interaction.py
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
def _get_token_new(self, sync: bool, limit: int = 10, offset: int | None = None) -> GetTokenNewResponse | Coroutine[None, None, GetTokenNewResponse]:
    """
        This function refers to the GET **[New Token](https://station.jup.ag/docs/api/new)** API endpoint, 
        and it is used to retrieved the list of new tokens managed by Jupiter.

        Parameters:
            limit: number of tokens to retrieve.
            offset: number of tokens to skip.

        Returns:
            List of Jupiter's tokens list.
    """
    # set params
    url = self.url_api_token + "new"
    params = {
        "limit": limit,
        "offset": offset
    }

    # execute request
    if sync:
        content_raw = self.client.api(RequestType.GET.value, url, params = params)
        return GetTokenNewResponse(tokens = content_raw.json())
    else:
        async def async_request():
            content_raw = await self.async_client.api(RequestType.GET.value, url, params = params)
            return GetTokenNewResponse(tokens = content_raw.json())
        return async_request()

_post_limit_order_create

_post_limit_order_create(
    sync: Literal[True], body: PostLimitOrderCreateBody
) -> PostLimitOrderCreateResponse
_post_limit_order_create(
    sync: Literal[False], body: PostLimitOrderCreateBody
) -> Coroutine[None, None, PostLimitOrderCreateResponse]
_post_limit_order_create(
    sync: bool, body: PostLimitOrderCreateBody
) -> (
    PostLimitOrderCreateResponse
    | Coroutine[None, None, PostLimitOrderCreateResponse]
)

This function refers to the POST Limit Order - Create API endpoint, and it is used to receive the transaction to perform the creation of a Limit Order via Jupiter API.

Parameters:

Name Type Description Default
body PostLimitOrderCreateBody

the body to sent to Jupiter API that describe the swap. More details in the object definition.

required

Returns:

Type Description
PostLimitOrderCreateResponse | Coroutine[None, None, PostLimitOrderCreateResponse]

Transaction created by Jupiter API.

Source code in src/cyhole/jupiter/interaction.py
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
def _post_limit_order_create(self, sync: bool, body: PostLimitOrderCreateBody) -> PostLimitOrderCreateResponse | Coroutine[None, None, PostLimitOrderCreateResponse]:
    """
        This function refers to the POST **[Limit Order - Create](https://station.jup.ag/docs/limit-order/limit-order-api)** API endpoint, 
        and it is used to receive the transaction to perform the creation of a Limit Order via Jupiter API.

        Parameters:
            body: the body to sent to Jupiter API that describe the swap.
                More details in the object definition.

        Returns:
            Transaction created by Jupiter API.
    """

    # set params
    url = self.url_api_limit + "createOrder"
    headers = {
        "Content-Type": "application/json"
    }

    # execute request
    if sync:
        try:
            content_raw = self.client.api(
                type = RequestType.POST.value,
                url = url,
                headers = headers,
                json = body.model_dump(by_alias = True, exclude_defaults = True)
            )
        except HTTPError as e:
            raise self._raise(e)
        return PostLimitOrderCreateResponse(**content_raw.json())
    else:
        async def async_request():
            try:
                content_raw = await self.async_client.api(
                    type = RequestType.POST.value,
                    url = url,
                    headers = headers,
                    json = body.model_dump(by_alias = True, exclude_defaults = True)
                )
            except HTTPError as e:
                raise self._raise(e)
            return PostLimitOrderCreateResponse(**content_raw.json())
        return async_request()

_post_limit_order_cancel

_post_limit_order_cancel(
    sync: Literal[True], body: PostLimitOrderCancelBody
) -> PostLimitOrderCancelResponse
_post_limit_order_cancel(
    sync: Literal[False], body: PostLimitOrderCancelBody
) -> Coroutine[None, None, PostLimitOrderCancelResponse]
_post_limit_order_cancel(
    sync: bool, body: PostLimitOrderCancelBody
) -> (
    PostLimitOrderCancelResponse
    | Coroutine[None, None, PostLimitOrderCancelResponse]
)

This function refers to the POST Limit Order - Cancel API endpoint, and it is used to receive the transaction to perform the cancellation of a Limit Order previously opened via Jupiter API.

Parameters:

Name Type Description Default
body PostLimitOrderCancelBody

the body to sent to Jupiter API that describe the limit order to cancel. More details in the object definition.

required

Returns:

Type Description
PostLimitOrderCancelResponse | Coroutine[None, None, PostLimitOrderCancelResponse]

Transaction created by Jupiter API.

Source code in src/cyhole/jupiter/interaction.py
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
def _post_limit_order_cancel(self, sync: bool, body: PostLimitOrderCancelBody) -> PostLimitOrderCancelResponse | Coroutine[None, None, PostLimitOrderCancelResponse]:
    """
        This function refers to the POST **[Limit Order - Cancel](https://station.jup.ag/docs/limit-order/limit-order-api)** API endpoint, 
        and it is used to receive the transaction to perform the cancellation of a Limit Order previously 
        opened via Jupiter API.

        Parameters:
            body: the body to sent to Jupiter API that describe the limit order to cancel.
                More details in the object definition.

        Returns:
            Transaction created by Jupiter API.
    """

    # set params
    url = self.url_api_limit + "cancelOrders"
    headers = {
        "Content-Type": "application/json"
    }

    # execute request
    if sync:
        try:
            content_raw = self.client.api(
                type = RequestType.POST.value,
                url = url,
                headers = headers,
                json = body.model_dump(by_alias = True, exclude_defaults = True)
            )
        except HTTPError as e:
            raise self._raise(e)
        return PostLimitOrderCancelResponse(**content_raw.json())
    else:
        async def async_request():
            try:
                content_raw = await self.async_client.api(
                    type = RequestType.POST.value,
                    url = url,
                    headers = headers,
                    json = body.model_dump(by_alias = True, exclude_defaults = True)
                )
            except HTTPError as e:
                raise self._raise(e)
            return PostLimitOrderCancelResponse(**content_raw.json())
        return async_request()

_get_limit_order_open

_get_limit_order_open(
    sync: Literal[True],
    wallet: str | None = None,
    input_token: str | None = None,
    output_token: str | None = None,
) -> GetLimitOrderOpenResponse
_get_limit_order_open(
    sync: Literal[False],
    wallet: str | None = None,
    input_token: str | None = None,
    output_token: str | None = None,
) -> Coroutine[None, None, GetLimitOrderOpenResponse]
_get_limit_order_open(
    sync: bool,
    wallet: str | None = None,
    input_token: str | None = None,
    output_token: str | None = None,
) -> (
    GetLimitOrderOpenResponse
    | Coroutine[None, None, GetLimitOrderOpenResponse]
)

This function refers to the GET Limit Order - Open API endpoint, and it is used to receive the current open limit orders related to a wallet, input token or output token via Jupiter API.

Observe that all the input parameters are optional; if for example, only the input_token is provided, then all the limit orders having that input token address are returned (if available).

Parameters:

Name Type Description Default
wallet str | None

address of the wallet to check.

None
input_token str | None

address of the input token associated to the limit order.

None
output_token str | None

address of the output token associated to the limit order.

None

Returns:

Type Description
GetLimitOrderOpenResponse | Coroutine[None, None, GetLimitOrderOpenResponse]

Open limit orders created by Jupiter API.

Source code in src/cyhole/jupiter/interaction.py
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
def _get_limit_order_open(
    self,
    sync: bool,
    wallet: str | None = None,
    input_token: str | None = None,
    output_token: str | None = None
) -> GetLimitOrderOpenResponse | Coroutine[None, None, GetLimitOrderOpenResponse]:
    """
        This function refers to the GET **[Limit Order - Open](https://station.jup.ag/docs/limit-order/limit-order-api)** 
        API endpoint, and it is used to receive the current open limit orders related to a wallet, input token 
        or output token via Jupiter API. 

        Observe that all the input parameters are optional; if for example, only the `input_token` is provided, 
        then **all** the limit orders having that input token address are returned (if available).

        Parameters:
            wallet: address of the wallet to check.
            input_token: address of the input token associated to the limit order.
            output_token: address of the output token associated to the limit order.

        Returns:
            Open limit orders created by Jupiter API.
    """
    # set params
    url = self.url_api_limit + "openOrders"
    params = {
        "wallet": wallet,
        "inputMint": input_token,
        "outputMint": output_token
    }

    # execute request
    if sync:
        content_raw = self.client.api(RequestType.GET.value, url, params = params)
        return GetLimitOrderOpenResponse(orders = content_raw.json())
    else:
        async def async_request():
            content_raw = await self.async_client.api(RequestType.GET.value, url, params = params)
            return GetLimitOrderOpenResponse(orders = content_raw.json())
        return async_request()

_get_limit_order_history

_get_limit_order_history(
    sync: Literal[True],
    wallet: str,
    cursor: int | None = None,
    skip: int | None = None,
    take: int | None = None,
) -> GetLimitOrderHistoryResponse
_get_limit_order_history(
    sync: Literal[False],
    wallet: str,
    cursor: int | None = None,
    skip: int | None = None,
    take: int | None = None,
) -> Coroutine[None, None, GetLimitOrderHistoryResponse]
_get_limit_order_history(
    sync: bool,
    wallet: str,
    cursor: int | None = None,
    skip: int | None = None,
    take: int | None = None,
) -> (
    GetLimitOrderHistoryResponse
    | Coroutine[None, None, GetLimitOrderHistoryResponse]
)

This function refers to the GET Limit Order - History API endpoint, and it is used to retrieve the history of Limit Orders associated to a wallet via Jupiter API.

Parameters:

Name Type Description Default
wallet str

address of the wallet to check.

required
cursor int | None

specify which 'page' of orders to return.

None
skip int | None

specify the number of order to skip (from the top).

None
take int | None

specify the number of orders to return.

None

Returns:

Type Description
GetLimitOrderHistoryResponse | Coroutine[None, None, GetLimitOrderHistoryResponse]

History of limit orders associated to the input wallet.

Source code in src/cyhole/jupiter/interaction.py
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
def _get_limit_order_history(
    self,
    sync: bool,
    wallet: str,
    cursor: int | None = None,
    skip: int | None = None,
    take: int | None = None
) -> GetLimitOrderHistoryResponse | Coroutine[None, None, GetLimitOrderHistoryResponse]:
    """
        This function refers to the GET **[Limit Order - History](https://station.jup.ag/docs/limit-order/limit-order-api)** 
        API endpoint, and it is used to retrieve the history of Limit Orders associated to a wallet via Jupiter API. 

        Parameters:
            wallet: address of the wallet to check.
            cursor: specify which 'page' of orders to return.
            skip: specify the number of order to skip (from the top).
            take: specify the number of orders to return.

        Returns:
            History of limit orders associated to the input wallet.
    """
    # set params
    url = self.url_api_limit + "orderHistory"
    params = {
        "wallet": wallet,
        "cursor": cursor,
        "skip": skip,
        "take": take
    }

    # execute request
    if sync:
        content_raw = self.client.api(RequestType.GET.value, url, params = params)
        return GetLimitOrderHistoryResponse(orders = content_raw.json())
    else:
        async def async_request():
            content_raw = await self.async_client.api(RequestType.GET.value, url, params = params)
            return GetLimitOrderHistoryResponse(orders = content_raw.json())
        return async_request()

_get_limit_order_trade_history

_get_limit_order_trade_history(
    sync: Literal[True],
    wallet: str | None = None,
    input_token: str | None = None,
    output_token: str | None = None,
    cursor: int | None = None,
    skip: int | None = None,
    take: int | None = None,
) -> GetLimitOrderTradeHistoryResponse
_get_limit_order_trade_history(
    sync: Literal[False],
    wallet: str | None = None,
    input_token: str | None = None,
    output_token: str | None = None,
    cursor: int | None = None,
    skip: int | None = None,
    take: int | None = None,
) -> Coroutine[
    None, None, GetLimitOrderTradeHistoryResponse
]
_get_limit_order_trade_history(
    sync: bool,
    wallet: str | None = None,
    input_token: str | None = None,
    output_token: str | None = None,
    cursor: int | None = None,
    skip: int | None = None,
    take: int | None = None,
) -> (
    GetLimitOrderTradeHistoryResponse
    | Coroutine[
        None, None, GetLimitOrderTradeHistoryResponse
    ]
)

This function refers to the GET Limit Order - Trade History API endpoint, and it is used to retrieve the trades history related to Limit Orders extracted with specific requirements via Jupiter API.

Parameters:

Name Type Description Default
wallet str | None

address of the wallet to check.

None
input_token str | None

address of the input token associated to the limit order.

None
output_token str | None

address of the output token associated to the limit order.

None
cursor int | None

specify which 'page' of orders to return.

None
skip int | None

specify the number of order to skip (from the top).

None
take int | None

specify the number of orders to return.

None

Returns:

Type Description
GetLimitOrderTradeHistoryResponse | Coroutine[None, None, GetLimitOrderTradeHistoryResponse]

Hostory of limit orders associated to the input wallet.

Source code in src/cyhole/jupiter/interaction.py
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
def _get_limit_order_trade_history(
    self,
    sync: bool,
    wallet: str | None = None,
    input_token: str | None = None,
    output_token: str | None = None,
    cursor: int | None = None,
    skip: int | None = None,
    take: int | None = None
) -> GetLimitOrderTradeHistoryResponse | Coroutine[None, None, GetLimitOrderTradeHistoryResponse]:
    """
        This function refers to the GET **[Limit Order - Trade History](https://station.jup.ag/docs/limit-order/limit-order-api)** 
        API endpoint, and it is used to retrieve the trades history related to Limit Orders extracted with specific 
        requirements via Jupiter API. 

        Parameters:
            wallet: address of the wallet to check.
            input_token: address of the input token associated to the limit order.
            output_token: address of the output token associated to the limit order.
            cursor: specify which 'page' of orders to return.
            skip: specify the number of order to skip (from the top).
            take: specify the number of orders to return.

        Returns:
            Hostory of limit orders associated to the input wallet.
    """
    # set params
    url = self.url_api_limit + "tradeHistory"
    params = {
        "wallet": wallet,
        "inputMint": input_token,
        "outputMint": output_token,
        "cursor": cursor,
        "skip": skip,
        "take": take
    }

    # execute request
    if sync:
        content_raw = self.client.api(RequestType.GET.value, url, params = params)
        return GetLimitOrderTradeHistoryResponse(orders = content_raw.json())
    else:
        async def async_request():
            content_raw = await self.async_client.api(RequestType.GET.value, url, params = params)
            return GetLimitOrderTradeHistoryResponse(orders = content_raw.json())
        return async_request()

_raise

_raise(exception: HTTPError) -> JupiterException

Internal function used to raise the correct Jupiter exception according to the error code provided by the API.

Parameters:

Name Type Description Default
exception HTTPError

the HTTP error returned from Jupiter API.

required

Raises:

Type Description
JupiterNoRouteFoundError

for error code COULD_NOT_FIND_ANY_ROUTE during the creation of a quote.

JupiterInvalidRequest

for error code INVALID_REQUEST.

JupiterException

general exception raised when an unknown error code is found or a different error is found.

Source code in src/cyhole/jupiter/interaction.py
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
def _raise(self, exception: HTTPError) -> JupiterException:
    """
        Internal function used to raise the correct 
        Jupiter exception according to the error code 
        provided by the API.

        Parameters:
            exception: the HTTP error returned from Jupiter API.

        Raises:
            JupiterNoRouteFoundError: for error code `COULD_NOT_FIND_ANY_ROUTE` 
                during the creation of a quote.
            JupiterInvalidRequest: for error code `INVALID_REQUEST`.
            JupiterException: general exception raised when an unknown 
                error code is found or a different error is found.
    """
    try:
        error = JupiterHTTPError(**exception.response.json())
        match error.code:
            case "COULD_NOT_FIND_ANY_ROUTE":
                return JupiterNoRouteFoundError(error.msg)
            case "INVALID_REQUEST":
                return JupiterInvalidRequest(error.msg)
            case _:
                return JupiterException(error.model_dump_json())
    except Exception:
        return JupiterException(exception.response.content.decode())