Websocket subscription
Streams are available with Websocket. Subscriptions are created using the RPC call subscribe
with the stream (feed) name and subscription options set as parameters. Each stream has a different subscription name and can accept different subscription options. Please refer to the specific stream page for info
Available streams
NewPools
New pools (tokens) creation
Trades
New trades on pump.fun
Token
New trades for specified token
Account
New trades for specified account
Publications
Publications tokens on Raydium
Methods
To subscribe to the stream, you need to specify the action "subscribe" and stream type.
subscribeNewPools
New pools (tokens) creation
subscribeTrades
New trades on pump.fun
subscribeToken
New trades for specified token (to specify the token, fill the array params)
subscribeAccount
New trades for specified account (to specify the account, fill the array params)
subscribePublications
Publications tokens on Raydium
To unsubscribe from the stream, you need to specify the action "unsubscribe" and stream type.
unsubscribeNewPools
New pools (tokens) creation
unsubscribeTrades
New trades on pump.fun
unsubscribeToken
New trades for specified token
unsubscribeAccount
New trades for specified account
unsubscribePublications
Publications tokens on Raydium
Examples
package main
import (
"encoding/json"
"log"
"github.com/gorilla/websocket"
)
func main() {
ws, _, err := websocket.DefaultDialer.Dial("wss://rpc.api-pump.fun/ws", nil)
if err != nil {
log.Fatal("Dial error:", err)
}
defer ws.Close()
payload := map[string]interface{}{
"method": "subscribeTrades",
"params": []interface{}{},
}
if err := ws.WriteJSON(payload); err != nil {
log.Println("WriteJSON error:", err)
return
}
payload = map[string]interface{}{
"method": "subscribeNewPools",
"keys": []interface{}{},
}
if err := ws.WriteJSON(payload); err != nil {
log.Println("WriteJSON error:", err)
return
}
payload = map[string]interface{}{
"method": "subscribeToken",
"params": []interface{}{"8LPjGAPtCywvo51UACHxDg3ygzbrm9qi2XxhB2Ropump"},
}
if err := ws.WriteJSON(payload); err != nil {
log.Println("WriteJSON error:", err)
return
}
for {
_, message, err := ws.ReadMessage()
if err != nil {
log.Println("ReadMessage error:", err)
return
}
var data map[string]interface{}
if err := json.Unmarshal(message, &data); err != nil {
log.Println("Unmarshal error:", err)
return
}
log.Println(data)
}
}
Last updated