> ## Documentation Index
> Fetch the complete documentation index at: https://docs.moralis.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Get Pump.fun Tokens, Swaps and Prices

> Learn how to fetch swap data and price information for Pump.fun tokens on Solana using the Moralis API.

## Introduction

In this tutorial, you'll learn how to retrieve swap (trade) data and price information for Pump.fun tokens using the Moralis Solana API. This includes getting recent swaps, price history, and OHLC data for any token launched on Pump.fun. We'll use the following Moralis API endpoint:

* [Get Token Swaps](/data-api/solana/token/swaps/token-swaps) - Fetch swap history and trading data for Solana tokens

## Prerequisites

* Node.js v18+ installed
* A Moralis API key ([get one free](https://admin.moralis.io))

## Step 1: Set Up Your Project

Create a new directory for your project and initialize it:

```bash theme={null}
mkdir pump-fun-swaps && cd pump-fun-swaps
npm init -y
```

## Step 2: Create the Script

Create a file called `index.js` and add the following code:

```javascript theme={null}
// index.js
const API_KEY = 'YOUR_API_KEY';
const TOKEN_ADDRESS = 'YOUR_PUMP_FUN_TOKEN_ADDRESS'; // Solana token mint address

async function getTokenSwaps() {
  const response = await fetch(
    `https://solana-gateway.moralis.io/token/mainnet/${TOKEN_ADDRESS}/swaps`,
    {
      headers: {
        'X-API-Key': API_KEY,
      },
    }
  );

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

getTokenSwaps();
```

Replace `YOUR_API_KEY` and `YOUR_PUMP_FUN_TOKEN_ADDRESS` with your actual values.

## Step 3: Run the Script

```bash theme={null}
node index.js
```

## Example Response

```json theme={null}
{
  "result": [
    {
      "transactionHash": "5abc123...",
      "blockTime": "2024-01-15T10:30:00.000Z",
      "tokenIn": {
        "address": "So11111111111111111111111111111111111111112",
        "symbol": "SOL",
        "amount": "1.5",
        "amountUsd": 150.00
      },
      "tokenOut": {
        "address": "ABC123...",
        "symbol": "PUMP",
        "amount": "1000000",
        "amountUsd": 150.00
      },
      "walletAddress": "7abc...",
      "exchange": "pumpfun",
      "swapType": "buy"
    }
  ]
}
```

## Understanding the Response

| Field             | Description                                    |
| ----------------- | ---------------------------------------------- |
| `transactionHash` | Solana transaction signature                   |
| `blockTime`       | When the swap occurred                         |
| `tokenIn`         | Token being sold (with amount and USD value)   |
| `tokenOut`        | Token being bought (with amount and USD value) |
| `walletAddress`   | Wallet that made the swap                      |
| `exchange`        | DEX where swap occurred                        |
| `swapType`        | Type of trade (buy or sell)                    |

## Next Steps

* [Get Pump.fun New/Bonding/Graduated Tokens](/get-started/tutorials/data-api/tokens-and-markets/get-pump-fun-new-bonding-and-graduated-tokens) - Discover tokens
* [API Reference - Token Swaps](/data-api/solana/token/swaps/token-swaps) - Full API documentation
* [API Reference - Token Price](/data-api/solana/price/token-price) - Price endpoint docs
