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

# Trades

> Polymarket websocket trade executions

## Overview

Individual trade executions captured from Polymarket's websocket feed. Each row represents a single trade.

## Columns

| <div style={{minWidth: '240px'}}>Column</div> | Type    | Description                                   |
| --------------------------------------------- | ------- | --------------------------------------------- |
| `exchange_timestamp`                          | integer | Exchange timestamp in milliseconds            |
| `local_timestamp`                             | integer | Local capture timestamp in milliseconds (UTC) |
| `side`                                        | string  | Trade side: `BUY` or `SELL`                   |
| `size`                                        | decimal | Number of contracts traded                    |
| `price`                                       | decimal | Execution price                               |

## Fetching Data

### Using Market Slug + Outcome

<CodeGroup>
  ```python Python theme={null}
  import requests

  def download_trades(market_slug, outcome, date_str, api_key):
      url = f"https://datasets.predictiondata.dev/polymarket/trades/{market_slug}/{outcome}/{date_str}.csv.gz"
      params = {'slug': 'true', 'apikey': api_key}
      
      response = requests.get(url, params=params)
      response.raise_for_status()
      
      with open(f'{market_slug}_{outcome}_{date_str}_trades.csv.gz', 'wb') as f:
          f.write(response.content)
      
      print(f"Downloaded to {market_slug}_{outcome}_{date_str}_trades.csv.gz")

  if __name__ == "__main__":
      api_key = "YOUR_API_KEY"
      market_slug = "ramp-ipo-in-2025"
      outcome = "YES"
      date_str = "2025-11-16"
      
      download_trades(market_slug, outcome, date_str, api_key)
  ```

  ```javascript Node.js theme={null}
  const axios = require('axios');
  const fs = require('fs');

  async function downloadTrades(marketSlug, outcome, dateStr, apiKey) {
      const url = `https://datasets.predictiondata.dev/polymarket/trades/${marketSlug}/${outcome}/${dateStr}.csv.gz`;
      
      const response = await axios.get(url, {
          params: { slug: 'true', apikey: apiKey },
          responseType: 'arraybuffer'
      });
      
      const filename = `${marketSlug}_${outcome}_${dateStr}_trades.csv.gz`;
      fs.writeFileSync(filename, response.data);
      console.log(`Downloaded to ${filename}`);
  }

  (async () => {
      const apiKey = "YOUR_API_KEY";
      const marketSlug = "ramp-ipo-in-2025";
      const outcome = "YES";
      const dateStr = "2025-11-16";
      
      try {
          await downloadTrades(marketSlug, outcome, dateStr, apiKey);
      } catch (error) {
          console.error("Error downloading data:", error.message);
      }
  })();
  ```

  ```rust Rust theme={null}
  use reqwest;
  use std::fs::File;
  use std::io::Write;

  async fn download_trades(
      market_slug: &str,
      outcome: &str,
      date_str: &str,
      api_key: &str,
  ) -> Result<(), Box<dyn std::error::Error>> {
      let url = format!(
          "https://datasets.predictiondata.dev/polymarket/trades/{}/{}/{}.csv.gz",
          market_slug, outcome, date_str
      );
      
      let client = reqwest::Client::new();
      let response = client
          .get(&url)
          .query(&[("slug", "true"), ("apikey", api_key)])
          .send()
          .await?;
      
      let bytes = response.bytes().await?;
      let filename = format!("{}_{}_{}_trades.csv.gz", market_slug, outcome, date_str);
      
      let mut file = File::create(&filename)?;
      file.write_all(&bytes)?;
      
      println!("Downloaded to {}", filename);
      Ok(())
  }

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let api_key = "YOUR_API_KEY";
      let market_slug = "ramp-ipo-in-2025";
      let outcome = "YES";
      let date_str = "2025-11-16";
      
      download_trades(market_slug, outcome, date_str, api_key).await?;
      Ok(())
  }
  ```

  ```go Go theme={null}
  package main

  import (
      "fmt"
      "io"
      "net/http"
      "net/url"
      "os"
  )

  func downloadTrades(marketSlug, outcome, dateStr, apiKey string) error {
      baseURL := fmt.Sprintf(
          "https://datasets.predictiondata.dev/polymarket/trades/%s/%s/%s.csv.gz",
          marketSlug, outcome, dateStr,
      )
      
      params := url.Values{}
      params.Add("slug", "true")
      params.Add("apikey", apiKey)
      
      fullURL := baseURL + "?" + params.Encode()
      
      resp, err := http.Get(fullURL)
      if err != nil {
          return err
      }
      defer resp.Body.Close()
      
      filename := fmt.Sprintf("%s_%s_%s_trades.csv.gz", marketSlug, outcome, dateStr)
      file, err := os.Create(filename)
      if err != nil {
          return err
      }
      defer file.Close()
      
      _, err = io.Copy(file, resp.Body)
      if err != nil {
          return err
      }
      
      fmt.Printf("Downloaded to %s\n", filename)
      return nil
  }

  func main() {
      apiKey := "YOUR_API_KEY"
      marketSlug := "ramp-ipo-in-2025"
      outcome := "YES"
      dateStr := "2025-11-16"
      
      if err := downloadTrades(marketSlug, outcome, dateStr, apiKey); err != nil {
          fmt.Printf("Error downloading data: %v\n", err)
      }
  }
  ```

  ```bash cURL theme={null}
  curl -G "https://datasets.predictiondata.dev/polymarket/trades/ramp-ipo-in-2025/YES/2025-11-16.csv.gz" \
    --data-urlencode "slug=true" \
    --data-urlencode "apikey=YOUR_API_KEY" \
    --output ramp-ipo-in-2025_YES_2025-11-16_trades.csv.gz
  ```
</CodeGroup>

### Using Token ID

<CodeGroup>
  ```python Python theme={null}
  import requests

  def download_trades_by_token(token_id, date_str, api_key):
      url = f"https://datasets.predictiondata.dev/polymarket/trades/{token_id}/{date_str}.csv.gz"
      params = {'apikey': api_key}
      
      response = requests.get(url, params=params)
      response.raise_for_status()
      
      with open(f'{token_id}_{date_str}_trades.csv.gz', 'wb') as f:
          f.write(response.content)
      
      print(f"Downloaded to {token_id}_{date_str}_trades.csv.gz")

  if __name__ == "__main__":
      api_key = "YOUR_API_KEY"
      token_id = "6535996220481600525438454491949371553057652243233032166205012948847090204871"
      date_str = "2025-11-16"
      
      download_trades_by_token(token_id, date_str, api_key)
  ```

  ```javascript Node.js theme={null}
  const axios = require('axios');
  const fs = require('fs');

  async function downloadTradesByToken(tokenId, dateStr, apiKey) {
      const url = `https://datasets.predictiondata.dev/polymarket/trades/${tokenId}/${dateStr}.csv.gz`;
      
      const response = await axios.get(url, {
          params: { apikey: apiKey },
          responseType: 'arraybuffer'
      });
      
      const filename = `${tokenId}_${dateStr}_trades.csv.gz`;
      fs.writeFileSync(filename, response.data);
      console.log(`Downloaded to ${filename}`);
  }

  (async () => {
      const apiKey = "YOUR_API_KEY";
      const tokenId = "6535996220481600525438454491949371553057652243233032166205012948847090204871";
      const dateStr = "2025-11-16";
      
      try {
          await downloadTradesByToken(tokenId, dateStr, apiKey);
      } catch (error) {
          console.error("Error downloading data:", error.message);
      }
  })();
  ```

  ```rust Rust theme={null}
  use reqwest;
  use std::fs::File;
  use std::io::Write;

  async fn download_trades_by_token(
      token_id: &str,
      date_str: &str,
      api_key: &str,
  ) -> Result<(), Box<dyn std::error::Error>> {
      let url = format!(
          "https://datasets.predictiondata.dev/polymarket/trades/{}/{}.csv.gz",
          token_id, date_str
      );
      
      let client = reqwest::Client::new();
      let response = client
          .get(&url)
          .query(&[("apikey", api_key)])
          .send()
          .await?;
      
      let bytes = response.bytes().await?;
      let filename = format!("{}_{}_trades.csv.gz", token_id, date_str);
      
      let mut file = File::create(&filename)?;
      file.write_all(&bytes)?;
      
      println!("Downloaded to {}", filename);
      Ok(())
  }

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let api_key = "YOUR_API_KEY";
      let token_id = "6535996220481600525438454491949371553057652243233032166205012948847090204871";
      let date_str = "2025-11-16";
      
      download_trades_by_token(token_id, date_str, api_key).await?;
      Ok(())
  }
  ```

  ```go Go theme={null}
  package main

  import (
      "fmt"
      "io"
      "net/http"
      "net/url"
      "os"
  )

  func downloadTradesByToken(tokenID, dateStr, apiKey string) error {
      baseURL := fmt.Sprintf(
          "https://datasets.predictiondata.dev/polymarket/trades/%s/%s.csv.gz",
          tokenID, dateStr,
      )
      
      params := url.Values{}
      params.Add("apikey", apiKey)
      
      fullURL := baseURL + "?" + params.Encode()
      
      resp, err := http.Get(fullURL)
      if err != nil {
          return err
      }
      defer resp.Body.Close()
      
      filename := fmt.Sprintf("%s_%s_trades.csv.gz", tokenID, dateStr)
      file, err := os.Create(filename)
      if err != nil {
          return err
      }
      defer file.Close()
      
      _, err = io.Copy(file, resp.Body)
      if err != nil {
          return err
      }
      
      fmt.Printf("Downloaded to %s\n", filename)
      return nil
  }

  func main() {
      apiKey := "YOUR_API_KEY"
      tokenID := "6535996220481600525438454491949371553057652243233032166205012948847090204871"
      dateStr := "2025-11-16"
      
      if err := downloadTradesByToken(tokenID, dateStr, apiKey); err != nil {
          fmt.Printf("Error downloading data: %v\n", err)
      }
  }
  ```

  ```bash cURL theme={null}
  curl -G "https://datasets.predictiondata.dev/polymarket/trades/6535996220481600525438454491949371553057652243233032166205012948847090204871/2025-11-16.csv.gz" \
    --data-urlencode "apikey=YOUR_API_KEY" \
    --output 6535996220481600525438454491949371553057652243233032166205012948847090204871_2025-11-16_trades.csv.gz
  ```
</CodeGroup>

## Notes

* Files are gzip compressed
* Date format: `YYYY-MM-DD`
* Trades are deduplicated across multiple websockets
* Side is from the taker's perspective
