> This page is for API Reference.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://okx-demo.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://okx-demo.ferndocs.com/_mcp/server.

# Get transaction details 3 months

GET https://www.okx.com/api/v5/trade/fills-history

This endpoint can retrieve data from the last 3 months.

Reference: https://okx-demo.ferndocs.com/api/api-reference/trade/get-fills-history

## Authentication

- `OK-ACCESS-KEY` header (required) — Your API key.
- `OK-ACCESS-SIGN` header (required) — Base64-encoded HMAC-SHA256 signature of the prehash string.
- `OK-ACCESS-TIMESTAMP` header (required) — ISO 8601 UTC timestamp, e.g. 2020-12-08T09:08:57.715Z.
- `OK-ACCESS-PASSPHRASE` header (required) — The passphrase you set when creating the API key.

## Request

### Query parameters

- `instType` (enum, required) — Instrument type `SPOT` `MARGIN` `SWAP` `FUTURES` `OPTION` `EVENTS`
  - Allowed values: `SPOT`, `MARGIN`, `SWAP`, `FUTURES`, `OPTION`
- `uly` (string, optional) — Underlying. Applicable to FUTURES/SWAP/OPTION.
- `instFamily` (string, optional) — Instrument family Applicable to `FUTURES`/`SWAP`/`OPTION`
- `instId` (string, optional) — Instrument ID, e.g. `BTC-USDT`
- `ordId` (string, optional) — Order ID
- `after` (string, optional) — Pagination of data to return records earlier than the requested `billId`
- `before` (string, optional) — Pagination of data to return records newer than the requested `billId`
- `begin` (string, optional) — Filter with a begin timestamp `ts`. Unix timestamp format in milliseconds, e.g. `1597026383085`
- `end` (string, optional) — Filter with an end timestamp `ts`. Unix timestamp format in milliseconds, e.g. `1597026383085`
- `limit` (string, optional) — Number of results per request. The maximum is `100`; The default is `100`

## Response

### 200

Successful response

- `code` (string, optional) — Result code. `0` means success; any other value is an error code.
- `msg` (string, optional) — Error message. Empty on success.
- `data` (list of ApiV5TradeFillsHistoryGetResponsesContentApplicationJsonSchemaDataItems, optional)

## Types

### ApiV5TradeFillsHistoryGetResponsesContentApplicationJsonSchemaDataItems

- `instType` (string, optional) — Instrument type
- `instId` (string, optional) — Instrument ID
- `tradeId` (string, optional) — Last trade ID
- `ordId` (string, optional) — Order ID
- `clOrdId` (string, optional) — Client Order ID as assigned by the client
- `billId` (string, optional) — Bill ID
- `fillPx` (string, optional) — Last filled price
- `fillSz` (string, optional) — Last filled quantity
- `side` (string, optional) — Order side `buy` `sell`
- `posSide` (string, optional) — Position side `long` `short` it returns `net` in`net` mode.
- `execType` (string, optional) — Liquidity taker or maker `T`: taker `M`: maker Not applicable to system orders such as ADL and liquidation
- `feeCcy` (string, optional) — Trading fee or rebate currency
- `fee` (string, optional) — The amount of trading fee or rebate. The trading fee deduction is negative, such as '-0.01'; the rebate is positive, such as '0.01'.
- `ts` (string, optional) — Data generation time, Unix timestamp format in milliseconds, e.g. `1597026383085`.

## Examples

**Response**

```json
{
  "code": "0",
  "msg": "",
  "data": [
    {
      "instType": "SPOT",
      "instId": "BTC-USDT",
      "tradeId": "744876980",
      "ordId": "680800019749904384",
      "clOrdId": "",
      "billId": "680800019754098688",
      "fillPx": "51858",
      "fillSz": "0.00192834",
      "side": "buy",
      "posSide": "net",
      "execType": "T",
      "feeCcy": "BTC",
      "fee": "-0.00000192834",
      "ts": "1708587373362",
      "feeRate": "-0.001",
      "fillFwdPx": "",
      "fillIdxPx": "",
      "fillMarkPx": "",
      "fillMarkVol": "",
      "fillPnl": "0",
      "fillPxUsd": "",
      "fillPxVol": "",
      "fillTime": "1708587373361",
      "subType": "1",
      "tag": "",
      "tradeQuoteCcy": "USDT"
    }
  ]
}
```

**SDK Code**

```python trade_getFillsHistory_example
import requests

url = "https://www.okx.com/api/v5/trade/fills-history"

querystring = {"instType":"SPOT"}

headers = {"OK-ACCESS-KEY": "<apiKey>"}

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

print(response.json())
```

```javascript trade_getFillsHistory_example
const url = 'https://www.okx.com/api/v5/trade/fills-history?instType=SPOT';
const options = {method: 'GET', headers: {'OK-ACCESS-KEY': '<apiKey>'}};

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

```go trade_getFillsHistory_example
package main

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

func main() {

	url := "https://www.okx.com/api/v5/trade/fills-history?instType=SPOT"

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

	req.Header.Add("OK-ACCESS-KEY", "<apiKey>")

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

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

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

}
```

```ruby trade_getFillsHistory_example
require 'uri'
require 'net/http'

url = URI("https://www.okx.com/api/v5/trade/fills-history?instType=SPOT")

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

request = Net::HTTP::Get.new(url)
request["OK-ACCESS-KEY"] = '<apiKey>'

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

```java trade_getFillsHistory_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://www.okx.com/api/v5/trade/fills-history?instType=SPOT")
  .header("OK-ACCESS-KEY", "<apiKey>")
  .asString();
```

```php trade_getFillsHistory_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://www.okx.com/api/v5/trade/fills-history?instType=SPOT', [
  'headers' => [
    'OK-ACCESS-KEY' => '<apiKey>',
  ],
]);

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

```csharp trade_getFillsHistory_example
using RestSharp;

var client = new RestClient("https://www.okx.com/api/v5/trade/fills-history?instType=SPOT");
var request = new RestRequest(Method.GET);
request.AddHeader("OK-ACCESS-KEY", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift trade_getFillsHistory_example
import Foundation

let headers = ["OK-ACCESS-KEY": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://www.okx.com/api/v5/trade/fills-history?instType=SPOT")! 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()
```