# Websocket

The API delivers real-time updates on coin events like new launches, trades, and migrations. Each coin event follows a common schema, **Coin**. Specifically, the **CoinTradeEvent** event includes a **trade\_data** attribute, defined by **CoinTradeData**.

### SDKs

To make integration easier, we provide official SDKs:

* [**Node.js SDK**](https://www.npmjs.com/package/sugar-money)
* [**Rust SDK**](https://crates.io/crates/sugar-money)

Please open an issue [here](https://github.com/Sugar-Money/sdk-issues) if you run into issues using any of the SDKs.

### **Generic Message Format**

All events are sent as generic messages with the following format:

```typoscript
{
  type: string;
  data: object;
};
```

### **Available Event Types:**

* **SolanaPrice**: `'solana_price'`
* **NewCoin**: `'new_coin'`
* **CoinCreate**: `'coin_create'`
* **CoinTrade**: `'coin_trade'`
* **CoinMigrated**: `'coin_migrate'`
* **CoinCompleted**: `'coin_complete'`
* **CoinFeatured**: `'coin_featured'`
* **CoinComment**: `'coin_comment'`

## The SolanaPrice object

```json
{"openapi":"3.1.0","info":{"title":"WebSocket API","version":"1.0.0"},"components":{"schemas":{"SolanaPrice":{"type":"object","properties":{"price":{"type":"number"}}}}}}
```

## The Coin object

```json
{"openapi":"3.1.0","info":{"title":"WebSocket API","version":"1.0.0"},"components":{"schemas":{"Coin":{"type":"object","properties":{"mint":{"type":"string"},"user_public_key":{"type":"string"},"metadata_uri":{"type":"string"},"raydium_pool":{"type":"string","nullable":true},"twitter":{"type":"string","nullable":true},"website":{"type":"string","nullable":true},"bonding_curve":{"type":"string"},"name":{"type":"string"},"symbol":{"type":"string"},"description":{"type":"string","nullable":true},"image_uri":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"featured_at":{"type":"string","format":"date-time","nullable":true},"migrated_to_raydium_at":{"type":"string","format":"date-time","nullable":true},"is_live":{"type":"boolean"},"nsfw":{"type":"boolean"},"slot":{"type":"integer"},"timestamp":{"type":"integer"},"sol_price":{"type":"string"},"real_sol_reserves":{"type":"string"},"real_coin_reserves":{"type":"string"},"virtual_sol_reserves":{"type":"string"},"virtual_coin_reserves":{"type":"string"},"created_off_chain":{"type":"boolean"},"signature":{"type":"string","nullable":true},"instruction_index":{"type":"integer","nullable":true},"versioned":{"type":"boolean","nullable":true},"duplicated_tx_signature":{"type":"boolean","nullable":true},"bonding_curve_progress":{"type":"string"},"largest_trade_sol_amount":{"type":"string"},"largest_trade_usd_amount":{"type":"string"},"holders":{"type":"integer"},"volume_sol":{"type":"string"},"volume_usd":{"type":"string"},"migration_in_psol":{"type":"boolean"}}}}}}
```

## The CoinTradeData object

```json
{"openapi":"3.1.0","info":{"title":"WebSocket API","version":"1.0.0"},"components":{"schemas":{"CoinTradeData":{"type":"object","properties":{"is_buy":{"type":"boolean"},"total_usd":{"type":"string"},"sol_amount":{"type":"string"},"coin_amount":{"type":"string"},"timestamp":{"type":"integer"},"signature":{"type":"string"},"user":{"type":"string"}}}}}}
```

## The CoinWithTradeData object

```json
{"openapi":"3.1.0","info":{"title":"WebSocket API","version":"1.0.0"},"components":{"schemas":{"CoinWithTradeData":{"allOf":[{"$ref":"#/components/schemas/Coin"},{"type":"object","properties":{"trade_data":{"$ref":"#/components/schemas/CoinTradeData"}}}]},"Coin":{"type":"object","properties":{"mint":{"type":"string"},"user_public_key":{"type":"string"},"metadata_uri":{"type":"string"},"raydium_pool":{"type":"string","nullable":true},"twitter":{"type":"string","nullable":true},"website":{"type":"string","nullable":true},"bonding_curve":{"type":"string"},"name":{"type":"string"},"symbol":{"type":"string"},"description":{"type":"string","nullable":true},"image_uri":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"featured_at":{"type":"string","format":"date-time","nullable":true},"migrated_to_raydium_at":{"type":"string","format":"date-time","nullable":true},"is_live":{"type":"boolean"},"nsfw":{"type":"boolean"},"slot":{"type":"integer"},"timestamp":{"type":"integer"},"sol_price":{"type":"string"},"real_sol_reserves":{"type":"string"},"real_coin_reserves":{"type":"string"},"virtual_sol_reserves":{"type":"string"},"virtual_coin_reserves":{"type":"string"},"created_off_chain":{"type":"boolean"},"signature":{"type":"string","nullable":true},"instruction_index":{"type":"integer","nullable":true},"versioned":{"type":"boolean","nullable":true},"duplicated_tx_signature":{"type":"boolean","nullable":true},"bonding_curve_progress":{"type":"string"},"largest_trade_sol_amount":{"type":"string"},"largest_trade_usd_amount":{"type":"string"},"holders":{"type":"integer"},"volume_sol":{"type":"string"},"volume_usd":{"type":"string"},"migration_in_psol":{"type":"boolean"}}},"CoinTradeData":{"type":"object","properties":{"is_buy":{"type":"boolean"},"total_usd":{"type":"string"},"sol_amount":{"type":"string"},"coin_amount":{"type":"string"},"timestamp":{"type":"integer"},"signature":{"type":"string"},"user":{"type":"string"}}}}}}
```

## The CoinComment object

```json
{"openapi":"3.1.0","info":{"title":"WebSocket API","version":"1.0.0"},"components":{"schemas":{"CoinComment":{"type":"object","properties":{"mint":{"type":"string"},"id":{"type":"integer"},"image_uri":{"type":"string"},"message":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"user":{"type":"object","properties":{"username":{"type":"string"},"image":{"type":"string"},"public_key":{"type":"string"}}}}}}}}
```

## The SolanaPriceEvent object

```json
{"openapi":"3.1.0","info":{"title":"WebSocket API","version":"1.0.0"},"components":{"schemas":{"SolanaPriceEvent":{"type":"object","properties":{"type":{"type":"string","enum":["solana_price"]},"data":{"$ref":"#/components/schemas/SolanaPrice"}}},"SolanaPrice":{"type":"object","properties":{"price":{"type":"number"}}}}}}
```

## The NewCoinEvent object

```json
{"openapi":"3.1.0","info":{"title":"WebSocket API","version":"1.0.0"},"components":{"schemas":{"NewCoinEvent":{"type":"object","properties":{"type":{"type":"string","enum":["new_coin"]},"data":{"$ref":"#/components/schemas/Coin"}}},"Coin":{"type":"object","properties":{"mint":{"type":"string"},"user_public_key":{"type":"string"},"metadata_uri":{"type":"string"},"raydium_pool":{"type":"string","nullable":true},"twitter":{"type":"string","nullable":true},"website":{"type":"string","nullable":true},"bonding_curve":{"type":"string"},"name":{"type":"string"},"symbol":{"type":"string"},"description":{"type":"string","nullable":true},"image_uri":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"featured_at":{"type":"string","format":"date-time","nullable":true},"migrated_to_raydium_at":{"type":"string","format":"date-time","nullable":true},"is_live":{"type":"boolean"},"nsfw":{"type":"boolean"},"slot":{"type":"integer"},"timestamp":{"type":"integer"},"sol_price":{"type":"string"},"real_sol_reserves":{"type":"string"},"real_coin_reserves":{"type":"string"},"virtual_sol_reserves":{"type":"string"},"virtual_coin_reserves":{"type":"string"},"created_off_chain":{"type":"boolean"},"signature":{"type":"string","nullable":true},"instruction_index":{"type":"integer","nullable":true},"versioned":{"type":"boolean","nullable":true},"duplicated_tx_signature":{"type":"boolean","nullable":true},"bonding_curve_progress":{"type":"string"},"largest_trade_sol_amount":{"type":"string"},"largest_trade_usd_amount":{"type":"string"},"holders":{"type":"integer"},"volume_sol":{"type":"string"},"volume_usd":{"type":"string"},"migration_in_psol":{"type":"boolean"}}}}}}
```

## The CoinCreateEvent object

```json
{"openapi":"3.1.0","info":{"title":"WebSocket API","version":"1.0.0"},"components":{"schemas":{"CoinCreateEvent":{"type":"object","properties":{"type":{"type":"string","enum":["coin_create"]},"data":{"$ref":"#/components/schemas/Coin"}}},"Coin":{"type":"object","properties":{"mint":{"type":"string"},"user_public_key":{"type":"string"},"metadata_uri":{"type":"string"},"raydium_pool":{"type":"string","nullable":true},"twitter":{"type":"string","nullable":true},"website":{"type":"string","nullable":true},"bonding_curve":{"type":"string"},"name":{"type":"string"},"symbol":{"type":"string"},"description":{"type":"string","nullable":true},"image_uri":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"featured_at":{"type":"string","format":"date-time","nullable":true},"migrated_to_raydium_at":{"type":"string","format":"date-time","nullable":true},"is_live":{"type":"boolean"},"nsfw":{"type":"boolean"},"slot":{"type":"integer"},"timestamp":{"type":"integer"},"sol_price":{"type":"string"},"real_sol_reserves":{"type":"string"},"real_coin_reserves":{"type":"string"},"virtual_sol_reserves":{"type":"string"},"virtual_coin_reserves":{"type":"string"},"created_off_chain":{"type":"boolean"},"signature":{"type":"string","nullable":true},"instruction_index":{"type":"integer","nullable":true},"versioned":{"type":"boolean","nullable":true},"duplicated_tx_signature":{"type":"boolean","nullable":true},"bonding_curve_progress":{"type":"string"},"largest_trade_sol_amount":{"type":"string"},"largest_trade_usd_amount":{"type":"string"},"holders":{"type":"integer"},"volume_sol":{"type":"string"},"volume_usd":{"type":"string"},"migration_in_psol":{"type":"boolean"}}}}}}
```

## The CoinTradeEvent object

```json
{"openapi":"3.1.0","info":{"title":"WebSocket API","version":"1.0.0"},"components":{"schemas":{"CoinTradeEvent":{"type":"object","properties":{"type":{"type":"string","enum":["coin_trade"]},"data":{"$ref":"#/components/schemas/CoinWithTradeData"}}},"CoinWithTradeData":{"allOf":[{"$ref":"#/components/schemas/Coin"},{"type":"object","properties":{"trade_data":{"$ref":"#/components/schemas/CoinTradeData"}}}]},"Coin":{"type":"object","properties":{"mint":{"type":"string"},"user_public_key":{"type":"string"},"metadata_uri":{"type":"string"},"raydium_pool":{"type":"string","nullable":true},"twitter":{"type":"string","nullable":true},"website":{"type":"string","nullable":true},"bonding_curve":{"type":"string"},"name":{"type":"string"},"symbol":{"type":"string"},"description":{"type":"string","nullable":true},"image_uri":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"featured_at":{"type":"string","format":"date-time","nullable":true},"migrated_to_raydium_at":{"type":"string","format":"date-time","nullable":true},"is_live":{"type":"boolean"},"nsfw":{"type":"boolean"},"slot":{"type":"integer"},"timestamp":{"type":"integer"},"sol_price":{"type":"string"},"real_sol_reserves":{"type":"string"},"real_coin_reserves":{"type":"string"},"virtual_sol_reserves":{"type":"string"},"virtual_coin_reserves":{"type":"string"},"created_off_chain":{"type":"boolean"},"signature":{"type":"string","nullable":true},"instruction_index":{"type":"integer","nullable":true},"versioned":{"type":"boolean","nullable":true},"duplicated_tx_signature":{"type":"boolean","nullable":true},"bonding_curve_progress":{"type":"string"},"largest_trade_sol_amount":{"type":"string"},"largest_trade_usd_amount":{"type":"string"},"holders":{"type":"integer"},"volume_sol":{"type":"string"},"volume_usd":{"type":"string"},"migration_in_psol":{"type":"boolean"}}},"CoinTradeData":{"type":"object","properties":{"is_buy":{"type":"boolean"},"total_usd":{"type":"string"},"sol_amount":{"type":"string"},"coin_amount":{"type":"string"},"timestamp":{"type":"integer"},"signature":{"type":"string"},"user":{"type":"string"}}}}}}
```

## The CoinMigratedEvent object

```json
{"openapi":"3.1.0","info":{"title":"WebSocket API","version":"1.0.0"},"components":{"schemas":{"CoinMigratedEvent":{"type":"object","properties":{"type":{"type":"string","enum":["coin_migrate"]},"data":{"$ref":"#/components/schemas/Coin"}}},"Coin":{"type":"object","properties":{"mint":{"type":"string"},"user_public_key":{"type":"string"},"metadata_uri":{"type":"string"},"raydium_pool":{"type":"string","nullable":true},"twitter":{"type":"string","nullable":true},"website":{"type":"string","nullable":true},"bonding_curve":{"type":"string"},"name":{"type":"string"},"symbol":{"type":"string"},"description":{"type":"string","nullable":true},"image_uri":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"featured_at":{"type":"string","format":"date-time","nullable":true},"migrated_to_raydium_at":{"type":"string","format":"date-time","nullable":true},"is_live":{"type":"boolean"},"nsfw":{"type":"boolean"},"slot":{"type":"integer"},"timestamp":{"type":"integer"},"sol_price":{"type":"string"},"real_sol_reserves":{"type":"string"},"real_coin_reserves":{"type":"string"},"virtual_sol_reserves":{"type":"string"},"virtual_coin_reserves":{"type":"string"},"created_off_chain":{"type":"boolean"},"signature":{"type":"string","nullable":true},"instruction_index":{"type":"integer","nullable":true},"versioned":{"type":"boolean","nullable":true},"duplicated_tx_signature":{"type":"boolean","nullable":true},"bonding_curve_progress":{"type":"string"},"largest_trade_sol_amount":{"type":"string"},"largest_trade_usd_amount":{"type":"string"},"holders":{"type":"integer"},"volume_sol":{"type":"string"},"volume_usd":{"type":"string"},"migration_in_psol":{"type":"boolean"}}}}}}
```

## The CoinCompletedEvent object

```json
{"openapi":"3.1.0","info":{"title":"WebSocket API","version":"1.0.0"},"components":{"schemas":{"CoinCompletedEvent":{"type":"object","properties":{"type":{"type":"string","enum":["coin_complete"]},"data":{"$ref":"#/components/schemas/Coin"}}},"Coin":{"type":"object","properties":{"mint":{"type":"string"},"user_public_key":{"type":"string"},"metadata_uri":{"type":"string"},"raydium_pool":{"type":"string","nullable":true},"twitter":{"type":"string","nullable":true},"website":{"type":"string","nullable":true},"bonding_curve":{"type":"string"},"name":{"type":"string"},"symbol":{"type":"string"},"description":{"type":"string","nullable":true},"image_uri":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"featured_at":{"type":"string","format":"date-time","nullable":true},"migrated_to_raydium_at":{"type":"string","format":"date-time","nullable":true},"is_live":{"type":"boolean"},"nsfw":{"type":"boolean"},"slot":{"type":"integer"},"timestamp":{"type":"integer"},"sol_price":{"type":"string"},"real_sol_reserves":{"type":"string"},"real_coin_reserves":{"type":"string"},"virtual_sol_reserves":{"type":"string"},"virtual_coin_reserves":{"type":"string"},"created_off_chain":{"type":"boolean"},"signature":{"type":"string","nullable":true},"instruction_index":{"type":"integer","nullable":true},"versioned":{"type":"boolean","nullable":true},"duplicated_tx_signature":{"type":"boolean","nullable":true},"bonding_curve_progress":{"type":"string"},"largest_trade_sol_amount":{"type":"string"},"largest_trade_usd_amount":{"type":"string"},"holders":{"type":"integer"},"volume_sol":{"type":"string"},"volume_usd":{"type":"string"},"migration_in_psol":{"type":"boolean"}}}}}}
```

## The CoinFeaturedEvent object

```json
{"openapi":"3.1.0","info":{"title":"WebSocket API","version":"1.0.0"},"components":{"schemas":{"CoinFeaturedEvent":{"type":"object","properties":{"type":{"type":"string","enum":["coin_featured"]},"data":{"$ref":"#/components/schemas/Coin"}}},"Coin":{"type":"object","properties":{"mint":{"type":"string"},"user_public_key":{"type":"string"},"metadata_uri":{"type":"string"},"raydium_pool":{"type":"string","nullable":true},"twitter":{"type":"string","nullable":true},"website":{"type":"string","nullable":true},"bonding_curve":{"type":"string"},"name":{"type":"string"},"symbol":{"type":"string"},"description":{"type":"string","nullable":true},"image_uri":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"featured_at":{"type":"string","format":"date-time","nullable":true},"migrated_to_raydium_at":{"type":"string","format":"date-time","nullable":true},"is_live":{"type":"boolean"},"nsfw":{"type":"boolean"},"slot":{"type":"integer"},"timestamp":{"type":"integer"},"sol_price":{"type":"string"},"real_sol_reserves":{"type":"string"},"real_coin_reserves":{"type":"string"},"virtual_sol_reserves":{"type":"string"},"virtual_coin_reserves":{"type":"string"},"created_off_chain":{"type":"boolean"},"signature":{"type":"string","nullable":true},"instruction_index":{"type":"integer","nullable":true},"versioned":{"type":"boolean","nullable":true},"duplicated_tx_signature":{"type":"boolean","nullable":true},"bonding_curve_progress":{"type":"string"},"largest_trade_sol_amount":{"type":"string"},"largest_trade_usd_amount":{"type":"string"},"holders":{"type":"integer"},"volume_sol":{"type":"string"},"volume_usd":{"type":"string"},"migration_in_psol":{"type":"boolean"}}}}}}
```

## The CoinCommentEvent object

```json
{"openapi":"3.1.0","info":{"title":"WebSocket API","version":"1.0.0"},"components":{"schemas":{"CoinCommentEvent":{"type":"object","properties":{"type":{"type":"string","enum":["coin_comment"]},"data":{"$ref":"#/components/schemas/CoinComment"}}},"CoinComment":{"type":"object","properties":{"mint":{"type":"string"},"id":{"type":"integer"},"image_uri":{"type":"string"},"message":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"user":{"type":"object","properties":{"username":{"type":"string"},"image":{"type":"string"},"public_key":{"type":"string"}}}}}}}}
```

## The Message object

```json
{"openapi":"3.1.0","info":{"title":"WebSocket API","version":"1.0.0"},"components":{"schemas":{"Message":{"oneOf":[{"$ref":"#/components/schemas/SolanaPriceEvent"},{"$ref":"#/components/schemas/NewCoinEvent"},{"$ref":"#/components/schemas/CoinCreateEvent"},{"$ref":"#/components/schemas/CoinTradeEvent"},{"$ref":"#/components/schemas/CoinMigratedEvent"},{"$ref":"#/components/schemas/CoinCompletedEvent"},{"$ref":"#/components/schemas/CoinFeaturedEvent"},{"$ref":"#/components/schemas/CoinCommentEvent"}]},"SolanaPriceEvent":{"type":"object","properties":{"type":{"type":"string","enum":["solana_price"]},"data":{"$ref":"#/components/schemas/SolanaPrice"}}},"SolanaPrice":{"type":"object","properties":{"price":{"type":"number"}}},"NewCoinEvent":{"type":"object","properties":{"type":{"type":"string","enum":["new_coin"]},"data":{"$ref":"#/components/schemas/Coin"}}},"Coin":{"type":"object","properties":{"mint":{"type":"string"},"user_public_key":{"type":"string"},"metadata_uri":{"type":"string"},"raydium_pool":{"type":"string","nullable":true},"twitter":{"type":"string","nullable":true},"website":{"type":"string","nullable":true},"bonding_curve":{"type":"string"},"name":{"type":"string"},"symbol":{"type":"string"},"description":{"type":"string","nullable":true},"image_uri":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"featured_at":{"type":"string","format":"date-time","nullable":true},"migrated_to_raydium_at":{"type":"string","format":"date-time","nullable":true},"is_live":{"type":"boolean"},"nsfw":{"type":"boolean"},"slot":{"type":"integer"},"timestamp":{"type":"integer"},"sol_price":{"type":"string"},"real_sol_reserves":{"type":"string"},"real_coin_reserves":{"type":"string"},"virtual_sol_reserves":{"type":"string"},"virtual_coin_reserves":{"type":"string"},"created_off_chain":{"type":"boolean"},"signature":{"type":"string","nullable":true},"instruction_index":{"type":"integer","nullable":true},"versioned":{"type":"boolean","nullable":true},"duplicated_tx_signature":{"type":"boolean","nullable":true},"bonding_curve_progress":{"type":"string"},"largest_trade_sol_amount":{"type":"string"},"largest_trade_usd_amount":{"type":"string"},"holders":{"type":"integer"},"volume_sol":{"type":"string"},"volume_usd":{"type":"string"},"migration_in_psol":{"type":"boolean"}}},"CoinCreateEvent":{"type":"object","properties":{"type":{"type":"string","enum":["coin_create"]},"data":{"$ref":"#/components/schemas/Coin"}}},"CoinTradeEvent":{"type":"object","properties":{"type":{"type":"string","enum":["coin_trade"]},"data":{"$ref":"#/components/schemas/CoinWithTradeData"}}},"CoinWithTradeData":{"allOf":[{"$ref":"#/components/schemas/Coin"},{"type":"object","properties":{"trade_data":{"$ref":"#/components/schemas/CoinTradeData"}}}]},"CoinTradeData":{"type":"object","properties":{"is_buy":{"type":"boolean"},"total_usd":{"type":"string"},"sol_amount":{"type":"string"},"coin_amount":{"type":"string"},"timestamp":{"type":"integer"},"signature":{"type":"string"},"user":{"type":"string"}}},"CoinMigratedEvent":{"type":"object","properties":{"type":{"type":"string","enum":["coin_migrate"]},"data":{"$ref":"#/components/schemas/Coin"}}},"CoinCompletedEvent":{"type":"object","properties":{"type":{"type":"string","enum":["coin_complete"]},"data":{"$ref":"#/components/schemas/Coin"}}},"CoinFeaturedEvent":{"type":"object","properties":{"type":{"type":"string","enum":["coin_featured"]},"data":{"$ref":"#/components/schemas/Coin"}}},"CoinCommentEvent":{"type":"object","properties":{"type":{"type":"string","enum":["coin_comment"]},"data":{"$ref":"#/components/schemas/CoinComment"}}},"CoinComment":{"type":"object","properties":{"mint":{"type":"string"},"id":{"type":"integer"},"image_uri":{"type":"string"},"message":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"user":{"type":"object","properties":{"username":{"type":"string"},"image":{"type":"string"},"public_key":{"type":"string"}}}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sugar.money/documentation/websocket.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
