> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.0x.org/llms.txt.
> For full documentation content, see https://docs.0x.org/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.0x.org/_mcp/server.

# getSwapTrades

GET https://api.0x.org/trade-analytics/swap

Get the list of completed swap trades. Returns a maximum of 200 trades per request. Visit [here](https://docs.0x.org/docs/trade-analytics-api/introduction) for more details about how the API works.

Reference: https://docs.0x.org/api-reference/0-x-api/trade-analytics/trade-analytics-swap

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: 0x API
  version: 1.0.0
paths:
  /trade-analytics/swap:
    get:
      operationId: trade-analytics-swap
      summary: getSwapTrades
      description: >-
        Get the list of completed swap trades. Returns a maximum of 200 trades
        per request. Visit
        [here](https://docs.0x.org/docs/trade-analytics-api/introduction) for
        more details about how the API works.
      tags:
        - subpackage_tradeAnalytics
      parameters:
        - name: cursor
          in: query
          description: >-
            A pagination cursor used to fetch the next page of trades. It should
            be set to `null` for the initial request; otherwise, it should be
            the value of `nextCursor` that is returned from `getSwapTrades` or
            `getGaslessTrades` calls.
          required: false
          schema:
            type: string
        - name: startTimestamp
          in: query
          description: >-
            Unix timestamp in seconds, specifying the starting point of the time
            range filter. Only trades completed on or after this timestamp will
            be included in the response.
          required: false
          schema:
            type: integer
        - name: endTimestamp
          in: query
          description: >-
            Unix timestamp in seconds, specifying the end point of the time
            range filter. Only trades completed on or before this timestamp will
            be included in the response.
          required: false
          schema:
            type: integer
        - name: 0x-api-key
          in: header
          description: Visit dashboard.0x.org to get your API Key
          required: true
          schema:
            type: string
        - name: 0x-version
          in: header
          description: API version
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Trade
                  Analytics_tradeAnalytics::swap_Response_200
        '400':
          description: 400 error response
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/TradeAnalytics::swapRequestBadRequestError
        '500':
          description: 500 error response
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/TradeAnalytics::swapRequestInternalServerError
servers:
  - url: https://api.0x.org
components:
  schemas:
    TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsFeesIntegratorFee:
      type: object
      properties:
        token:
          type:
            - string
            - 'null'
          description: >-
            The contract address of the token in which the integrator collected
            a fee
        amount:
          type:
            - string
            - 'null'
          description: The amount of the integrator fee, formatted by the token decimals
        amountUsd:
          type:
            - string
            - 'null'
          description: The amount of the integrator fee in USD.
      required:
        - token
        - amount
        - amountUsd
      description: The details about the fee collected by integrator
      title: >-
        TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsFeesIntegratorFee
    TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsFeesZeroExFee:
      type: object
      properties:
        token:
          type:
            - string
            - 'null'
          description: The contract address of the token in which 0x collected a fee
        amount:
          type:
            - string
            - 'null'
          description: The amount of the 0x fee, formatted by the token decimals
        amountUsd:
          type:
            - string
            - 'null'
          description: The amount of the 0x fee in USD.
      required:
        - token
        - amount
        - amountUsd
      description: The details about the fee collected by 0x
      title: >-
        TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsFeesZeroExFee
    TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsFees:
      type: object
      properties:
        integratorFee:
          oneOf:
            - $ref: >-
                #/components/schemas/TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsFeesIntegratorFee
            - type: 'null'
          description: The details about the fee collected by integrator
        zeroExFee:
          oneOf:
            - $ref: >-
                #/components/schemas/TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsFeesZeroExFee
            - type: 'null'
          description: The details about the fee collected by 0x
      required:
        - integratorFee
        - zeroExFee
      description: The details about fees collected for the trade
      title: >-
        TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsFees
    TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsProtocolVersion:
      type: string
      enum:
        - 0xv4
        - Settler
      description: The version of the 0x protocol used to execute the trade
      title: >-
        TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsProtocolVersion
    TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsTokensItems:
      type: object
      properties:
        address:
          type: string
          description: The contract address of the token
        symbol:
          type:
            - string
            - 'null'
          description: The symbol of the token
      required:
        - address
        - symbol
      description: Properties of the token involved in the trade
      title: >-
        TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsTokensItems
    TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsService:
      type: string
      enum:
        - swap
      title: >-
        TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsService
    TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItems:
      type: object
      properties:
        appName:
          type: string
          description: The name of the app that initiated the trade
        blockNumber:
          type: string
          description: The block number at which the trade was executed
        buyToken:
          type: string
          description: The contract address of the token received by the taker
        buyAmount:
          type:
            - string
            - 'null'
          description: >-
            The settled amount on the `buyToken`, formatted by the token
            decimals
        chainId:
          type: integer
          description: The ID of the chain where the trade was executed
        chainName:
          type: string
          description: The name of the chain where the trade was executed
        fees:
          $ref: >-
            #/components/schemas/TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsFees
          description: The details about fees collected for the trade
        gasUsed:
          type: string
          description: The amount of gas used in the trade
        protocolVersion:
          $ref: >-
            #/components/schemas/TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsProtocolVersion
          description: The version of the 0x protocol used to execute the trade
        sellToken:
          type: string
          description: The contract address of the token spent by the taker
        sellAmount:
          type:
            - string
            - 'null'
          description: The amount of the `sellToken`, formatted by the token decimals
        slippageBps:
          type:
            - string
            - 'null'
          description: The slippage of the `buyToken` in bps
        taker:
          type: string
          description: The wallet address of the taker​
        timestamp:
          type: integer
          description: The timestamp of the block containing the trade
        tokens:
          type: array
          items:
            $ref: >-
              #/components/schemas/TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsTokensItems
          description: Properties of the tokens involved in the trade
        transactionHash:
          type: string
          description: The trade's transaction hash
        volumeUsd:
          type:
            - string
            - 'null'
          description: >-
            The total volume of the trade in USD. This value is based on an
            estimate of the token price at the point of execution.
        zid:
          type: string
          description: The `zid` corresponding to the trade
        service:
          $ref: >-
            #/components/schemas/TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItemsService
      required:
        - appName
        - blockNumber
        - buyToken
        - buyAmount
        - chainId
        - chainName
        - fees
        - gasUsed
        - protocolVersion
        - sellToken
        - sellAmount
        - slippageBps
        - taker
        - timestamp
        - tokens
        - transactionHash
        - volumeUsd
        - zid
        - service
      title: TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItems
    Trade Analytics_tradeAnalytics::swap_Response_200:
      type: object
      properties:
        nextCursor:
          type:
            - string
            - 'null'
          description: >-
            The cursor to fetch the next page of trades. If not present, there
            are no more trades to fetch for given parameters.
        trades:
          type: array
          items:
            $ref: >-
              #/components/schemas/TradeAnalyticsSwapGetResponsesContentApplicationJsonSchemaTradesItems
        zid:
          type: string
          description: The unique ZeroEx identifier of the request
      required:
        - nextCursor
        - trades
        - zid
      title: Trade Analytics_tradeAnalytics::swap_Response_200
    InputInvalidName:
      type: string
      enum:
        - INPUT_INVALID
      title: InputInvalidName
    InputInvalidDataDetailsItems:
      type: object
      properties:
        field:
          type: string
          description: The input field name
        reason:
          type: string
          description: The validation failure reason
      required:
        - field
        - reason
      title: InputInvalidDataDetailsItems
    InputInvalidData:
      type: object
      properties:
        zid:
          type: string
          description: The unique ZeroEx identifier of the request
        details:
          type: array
          items:
            $ref: '#/components/schemas/InputInvalidDataDetailsItems'
          description: The list of invalid inputs
      required:
        - zid
        - details
      title: InputInvalidData
    INPUT_INVALID:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/InputInvalidName'
        message:
          type: string
        data:
          $ref: '#/components/schemas/InputInvalidData'
      required:
        - name
        - message
        - data
      title: INPUT_INVALID
    TradeAnalytics::swapRequestBadRequestError:
      oneOf:
        - $ref: '#/components/schemas/INPUT_INVALID'
      title: TradeAnalytics::swapRequestBadRequestError
    InternalServerErrorName:
      type: string
      enum:
        - INTERNAL_SERVER_ERROR
      title: InternalServerErrorName
    InternalServerErrorData:
      type: object
      properties:
        zid:
          type: string
          description: The unique ZeroEx identifier of the request
      required:
        - zid
      title: InternalServerErrorData
    INTERNAL_SERVER_ERROR:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/InternalServerErrorName'
        message:
          type: string
        data:
          $ref: '#/components/schemas/InternalServerErrorData'
      required:
        - name
        - message
        - data
      title: INTERNAL_SERVER_ERROR
    UncategorizedName:
      type: string
      enum:
        - UNCATEGORIZED
      title: UncategorizedName
    UncategorizedData:
      type: object
      properties:
        zid:
          type: string
          description: The unique ZeroEx identifier of the request
      required:
        - zid
      title: UncategorizedData
    UNCATEGORIZED:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/UncategorizedName'
        message:
          type: string
        data:
          $ref: '#/components/schemas/UncategorizedData'
      required:
        - name
        - message
        - data
      title: UNCATEGORIZED
    TradeAnalytics::swapRequestInternalServerError:
      oneOf:
        - $ref: '#/components/schemas/INTERNAL_SERVER_ERROR'
        - $ref: '#/components/schemas/UNCATEGORIZED'
      title: TradeAnalytics::swapRequestInternalServerError

```

## SDK Code Examples

```python Trade Analytics_tradeAnalytics::swap_example
import requests

url = "https://api.0x.org/trade-analytics/swap"

querystring = {"cursor":"eyJ0aW1lc3RhbXAiOjE3MjkwMzIyMTAsInppZCI6IjB4N2FjM2NlMzExNjA2NzU5MGY5M2U3MWVmIn0=","startTimestamp":"1729032210","endTimestamp":"1729032211"}

headers = {
    "0x-api-key": "0x-api-key",
    "0x-version": "v2"
}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript Trade Analytics_tradeAnalytics::swap_example
const url = 'https://api.0x.org/trade-analytics/swap?cursor=eyJ0aW1lc3RhbXAiOjE3MjkwMzIyMTAsInppZCI6IjB4N2FjM2NlMzExNjA2NzU5MGY5M2U3MWVmIn0%3D&startTimestamp=1729032210&endTimestamp=1729032211';
const options = {method: 'GET', headers: {'0x-api-key': '0x-api-key', '0x-version': 'v2'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Trade Analytics_tradeAnalytics::swap_example
package main

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

func main() {

	url := "https://api.0x.org/trade-analytics/swap?cursor=eyJ0aW1lc3RhbXAiOjE3MjkwMzIyMTAsInppZCI6IjB4N2FjM2NlMzExNjA2NzU5MGY5M2U3MWVmIn0%3D&startTimestamp=1729032210&endTimestamp=1729032211"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("0x-api-key", "0x-api-key")
	req.Header.Add("0x-version", "v2")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Trade Analytics_tradeAnalytics::swap_example
require 'uri'
require 'net/http'

url = URI("https://api.0x.org/trade-analytics/swap?cursor=eyJ0aW1lc3RhbXAiOjE3MjkwMzIyMTAsInppZCI6IjB4N2FjM2NlMzExNjA2NzU5MGY5M2U3MWVmIn0%3D&startTimestamp=1729032210&endTimestamp=1729032211")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["0x-api-key"] = '0x-api-key'
request["0x-version"] = 'v2'

response = http.request(request)
puts response.read_body
```

```java Trade Analytics_tradeAnalytics::swap_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.0x.org/trade-analytics/swap?cursor=eyJ0aW1lc3RhbXAiOjE3MjkwMzIyMTAsInppZCI6IjB4N2FjM2NlMzExNjA2NzU5MGY5M2U3MWVmIn0%3D&startTimestamp=1729032210&endTimestamp=1729032211")
  .header("0x-api-key", "0x-api-key")
  .header("0x-version", "v2")
  .asString();
```

```php Trade Analytics_tradeAnalytics::swap_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.0x.org/trade-analytics/swap?cursor=eyJ0aW1lc3RhbXAiOjE3MjkwMzIyMTAsInppZCI6IjB4N2FjM2NlMzExNjA2NzU5MGY5M2U3MWVmIn0%3D&startTimestamp=1729032210&endTimestamp=1729032211', [
  'headers' => [
    '0x-api-key' => '0x-api-key',
    '0x-version' => 'v2',
  ],
]);

echo $response->getBody();
```

```csharp Trade Analytics_tradeAnalytics::swap_example
using RestSharp;

var client = new RestClient("https://api.0x.org/trade-analytics/swap?cursor=eyJ0aW1lc3RhbXAiOjE3MjkwMzIyMTAsInppZCI6IjB4N2FjM2NlMzExNjA2NzU5MGY5M2U3MWVmIn0%3D&startTimestamp=1729032210&endTimestamp=1729032211");
var request = new RestRequest(Method.GET);
request.AddHeader("0x-api-key", "0x-api-key");
request.AddHeader("0x-version", "v2");
IRestResponse response = client.Execute(request);
```

```swift Trade Analytics_tradeAnalytics::swap_example
import Foundation

let headers = [
  "0x-api-key": "0x-api-key",
  "0x-version": "v2"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.0x.org/trade-analytics/swap?cursor=eyJ0aW1lc3RhbXAiOjE3MjkwMzIyMTAsInppZCI6IjB4N2FjM2NlMzExNjA2NzU5MGY5M2U3MWVmIn0%3D&startTimestamp=1729032210&endTimestamp=1729032211")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```