I am trying to build a bot to swap programmatically in python on Jupiter, but could not find any doc for that. Anyone managed to do so please?


1 Answer 1


Use this API: https://station.jup.ag/docs/apis/swap-api to fetching prices and generate the transactions needed.

Along with the solana web3 library for signing and sending transactions.

  • Yes, that's what i am trying to replicate, but I'm stuck at point 6. Get the serialized transactions to perform the swap. I get {'error': 'Parse error: WrongSize at line 1 column 250'}. Maybe, my userPublicKey or destinationTokenAccount are not right. They are Pubkey.from_string('xxx').to_json() and Keypair.from_base58_string('xxx').to_json(). with from solders.pubkey import Pubkey and from solders.keypair import Keypair . Is that correct? Commented Dec 8, 2023 at 18:39
  • You get this error from Jupiter or when signing your transaction? You should pass in Strings to the HTTP request. Can you paste a code snippet
    – Truitt
    Commented Dec 8, 2023 at 18:53
  • from the requests to jupiter, not the transaction Commented Dec 9, 2023 at 19:20
  • Yeah, you should not be converting it to json, leave it as a string.
    – Truitt
    Commented Dec 11, 2023 at 3:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.