Skip to main content

Jupiter Python SDK

Project description

🐍 JUPITER PYTHON SDK 🪐





📖 Introduction

Jupiter Python SDK is a Python library that allows you to use most of Jupiter features.
It enables executing swaps, limit orders, DCA, swap pairs, tokens prices, fetching wallet infos, stats, data and more!
This library is using packages like: solana-py, solders, anchorpy.
There is documentation inside each function, however, you can access to the official Jupiter API for more information.

⚠️ Disclaimer

Please note that I'm not responsible for any loss of funds, damages, or other libailities resulting from the use of this software or any associated services.
This tool is provided for educational purposes only and should not be used as financial advice, it is still in expiremental phase so use it at your own risk.

✨ Quickstart

🛠️ Installation

pip install jupiter-python-sdk

📃 General Usage

Providing the private key and RPC client is not mandatory if you only intend to execute functions for retrieving data.
Otherwise, this is required, for instance, to open a DCA account or to close one.

If you encounter ImportError: cannot import name 'sync_native' from 'spl.token.instructions error when trying to import Jupiter, Jupiter_DCA from jupiter_python_sdk.jupiter, follow these steps:

  1. Go to https://github.com/michaelhly/solana-py/tree/master/src/spl/token and download instructions.py
  2. In your packages folder, replace spl/token/instructions.py with the one you just downloaded.
import base58
from solders.pubkey import Pubkey
from solders.keypair import Keypair
from solana.rpc.async_api import AsyncClient
from jupiter_python_sdk.jupiter import Jupiter, Jupiter_DCA

async def main():
    private_key = Keypair.from_bytes(base58.b58decode(os.getenv("PRIVATE_KEY"))) # Private key as string
    async_client = AsyncClient(os.getenv("RPC_API"))
    jupiter = Jupiter(async_client, private_key)
    
    # EXECUTE A SWAP
    swap = await jupiter.swap(
        input_mint=Pubkey.from_string("So11111111111111111111111111111111111111112"),
        output_mint=Pubkey.from_string("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),
        amount=5_000_000,
        slippage_bps=1,
    )
    # Returns str: serialized transactions to execute the swap.

    # OPEN LIMIT ORDER
    open_limit_order = await jupiter.open_order(
        input_mint=Pubkey.from_string("So11111111111111111111111111111111111111112"),
        output_mint=Pubkey.from_string("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),
        in_amount=5_000_000,
        out_amount=100_000,
    )
    # Returns dict: {'transaction_data': serialized transactions to create the limit order, 'signature2': signature of the account that will be opened}

    # CREATE DCA ACCOUNT
    create_dca_account = await jupiter.dca.create_dca(
        input_mint=Pubkey.from_string("So11111111111111111111111111111111111111112"),
        output_mint=Pubkey.from_string("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),
        total_in_amount=5_000_000,
        in_amount_per_cycle=100_000,
        cycle_frequency=60,
        min_out_amount_per_cycle=0,
        max_out_amount_per_cycle=0,
        start=0
    )
    # Returns DCA Account Pubkey and transaction hash.

    # CLOSE DCA ACCOUNT
    close_dca_account = await jupiter.dca.close_dca(
        dca_pubkey=Pubkey.from_string("45iYdjmFUHSJCQHnNpWNFF9AjvzRcsQUP9FDBvJCiNS1")
    )
    # Returns transaction hash.

📜 All available features

- quote
- swap
- open_order
- cancel_orders
- create_dca
- close_dca
- fetch_user_dca_accounts
- fetch_dca_account_fills_history
- get_available_dca_tokens
- fetch_dca_data
- query_open_orders
- query_orders_history
- query_trades_history
- get_jupiter_stats
- get_token_price
- get_indexed_route_map
- get_tokens_list
- get_all_tickers
- get_all_swap_pairs
- get_swap_pairs
- get_token_stats_by_date
- program_id_to_label

📝 TO-DO

  • Bridge 🌉
  • Perpetual 💸

🤝 Contributions

If you are interesting in contributing, fork the repository and submit a pull request in order to merge your improvements into the main repository.
Contact me for any inquiry, I will reach you as soon as possible.
Discord Twitter

👑 Donations

This project doesn't include platform fees. If you find value in it and would like to support its development, your donations are greatly appreciated.
SOLANA ADDRESS

AyWu89SjZBW1MzkxiREmgtyMKxSkS1zVy8Uo23RyLphX

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupiter-python-sdk-0.0.1.6.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupiter_python_sdk-0.0.1.6-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file jupiter-python-sdk-0.0.1.6.tar.gz.

File metadata

  • Download URL: jupiter-python-sdk-0.0.1.6.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for jupiter-python-sdk-0.0.1.6.tar.gz
Algorithm Hash digest
SHA256 9157f971a61bbe6b406af4a6d539abb9cb8c74fe789a640d31cde3bb7fdd96f9
MD5 41950e81c7d0e4f653e3a939606131e8
BLAKE2b-256 3afa055b217ca7531ee35d24f377a4e7dbb9bb96415d8134c3c56b94ef2d04a5

See more details on using hashes here.

File details

Details for the file jupiter_python_sdk-0.0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for jupiter_python_sdk-0.0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1ce085053429d6c465121be013d1951b9908345f4aaffa9297cf08bcc5e488ef
MD5 4442acfb41543b3966a28eb8df9e811b
BLAKE2b-256 e014f8b301fd1ea32018df3d5731ab74b8983d6761fc7457fa87263720518607

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page