└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # What is PumpPortal? 2 | 3 | **A 3rd-Party (unofficial) API for Pump.fun**. We provide HTTPS endpoints that allow you to programmatically trade on, and gather data from, the Pump.fun bonding curve. 4 | 5 | PumpPortal is designed to be easy to use, so you can start building in minutes: there are no libraries to install and nothing to configure. If you can send an HTTP request or connect to Websockets you can use PumpPortal! 6 | 7 | Our Data API is free (subject to rate limits). Read the next section to get started building right away! 8 | 9 | Our Trading API is gated by an API key and charges a 0.5% fee per trade. API keys can be created at [PumpPortal.fun](https://pumpportal.fun) 10 | 11 | We're excited to see your trading bots, websites, or any other applications you integrate with Pump.fun! Connect with us in [Telegram](https://t.me/PumpPortalAPI) to ask questions or show off what you're building. If you build something cool we might feature your project on this page! 12 | 13 | # Local Trading API Docs 14 | 15 | To get a transaction for signing locally and sending with a custom RPC, send a POST request to 16 | 17 | `https://pumpportal.fun/api/trade-local` 18 | 19 | Your request body must contain the following options: 20 | 21 | - `publicKey`: Your wallet public key 22 | - `action`: "buy" or "sell" 23 | - `mint`: The contract address of the token you want to trade (this is the text after the '/' in the pump.fun url for the token.) 24 | - `amount`: The amount of SOL or tokens to trade. If selling, amount can be a percentage of tokens in your wallet (ex. amount: "100%") 25 | - `denominatedInSol`: "true" if amount is SOL, "false" if amount is tokens 26 | - `slippage`: The percent slippage allowed 27 | - `priorityFee`: Amount to use as priority fee 28 | - `pool`: (optional) Currently 'pump' and 'raydium' are supported options. Default is 'pump'. 29 | 30 | If your parameters are valid, you will receive a serialized transaction in response. See the example below for how to send this transaction with Web3.js. 31 | 32 | ### Examples 33 | 34 | 35 | ```js 36 | import { VersionedTransaction, Connection, Keypair } from '@solana/web3.js'; 37 | import bs58 from "bs58"; 38 | 39 | const RPC_ENDPOINT = "Your RPC Endpoint"; 40 | const web3Connection = new Connection( 41 | RPC_ENDPOINT, 42 | 'confirmed', 43 | ); 44 | 45 | async function sendPortalTransaction(){ 46 | const response = await fetch(`https://pumpportal.fun/api/trade-local`, { 47 | method: "POST", 48 | headers: { 49 | "Content-Type": "application/json" 50 | }, 51 | body: JSON.stringify({ 52 | "publicKey": "your-public-key", // Your wallet public key 53 | "action": "buy", // "buy" or "sell" 54 | "mint": "token-ca-here", // contract address of the token you want to trade 55 | "denominatedInSol": "false", // "true" if amount is amount of SOL, "false" if amount is number of tokens 56 | "amount": 1000, // amount of SOL or tokens 57 | "slippage": 1, // percent slippage allowed 58 | "priorityFee": 0.00001, // priority fee 59 | "pool": "pump" // exchange to trade on. "pump" or "raydium" 60 | }) 61 | }); 62 | if(response.status === 200){ // successfully generated transaction 63 | const data = await response.arrayBuffer(); 64 | const tx = VersionedTransaction.deserialize(new Uint8Array(data)); 65 | const signerKeyPair = Keypair.fromSecretKey(bs58.decode("your-wallet-private-key")); 66 | tx.sign([signerKeyPair]); 67 | const signature = await web3Connection.sendTransaction(tx) 68 | console.log("Transaction: https://solscan.io/tx/" + signature); 69 | } else { 70 | console.log(response.statusText); // log error 71 | } 72 | } 73 | 74 | sendPortalTransaction(); 75 | ``` 76 | # Real-time Updates 77 | 78 | Stream real-time trading and token creation data by connecting to the PumpPortal Websocket at `wss://pumpportal.fun/api/data`. 79 | 80 | Once you connect, you can subscribe to different data streams. The following methods are available: 81 | 82 | - `subscribeNewToken` For token creation events. 83 | 84 | - `subscribeTokenTrade` For all trades made on specific token(s). 85 | 86 | - `subscribeAccountTrade` For all trades made by specific account(s). 87 | 88 | ### Examples: 89 | 90 | ```js 91 | import WebSocket from 'ws'; 92 | 93 | const ws = new WebSocket('wss://pumpportal.fun/api/data'); 94 | 95 | ws.on('open', function open() { 96 | 97 | // Subscribing to token creation events 98 | let payload = { 99 | method: "subscribeNewToken", 100 | } 101 | ws.send(JSON.stringify(payload)); 102 | 103 | // Subscribing to trades made by accounts 104 | payload = { 105 | method: "subscribeAccountTrade", 106 | keys: ["AArPXm8JatJiuyEffuC1un2Sc835SULa4uQqDcaGpAjV"] // array of accounts to watch 107 | } 108 | ws.send(JSON.stringify(payload)); 109 | 110 | // Subscribing to trades on tokens 111 | payload = { 112 | method: "subscribeTokenTrade", 113 | keys: ["91WNez8D22NwBssQbkzjy4s2ipFrzpmn5hfvWVe2aY5p"] // array of token CAs to watch 114 | } 115 | ws.send(JSON.stringify(payload)); 116 | }); 117 | 118 | ws.on('message', function message(data) { 119 | console.log(JSON.parse(data)); 120 | }); 121 | ``` 122 | # Fees 123 | 124 | ### Data API 125 | 126 | There is no charge to use the Data API. 127 | 128 | ### Trading API 129 | 130 | We take a 0.5% fee on each trade. (Note: the fee is calculated before any slippage, so the actual fee amount may not be exactly 0.5% of the final trade value.) 131 | 132 | This does not include Solana network fees, or any fees charged by the Pump.fun bonding curve. 133 | --------------------------------------------------------------------------------