Skip to main content
POST
/
graphql
Live Position By GraphQL
curl --request POST \
  --url https://api.copin.io/graphql \
  --header 'Content-Type: application/json' \
  --data '
{
  "operationName": "<string>",
  "variables": {
    "index": "<string>",
    "body": {
      "filter": {
        "and": [
          {}
        ]
      },
      "sorts": [
        {}
      ],
      "paging": {
        "size": 123,
        "from": 123
      }
    }
  },
  "query": "<string>"
}
'
{
  "data": [
    {
      "id": "<string>",
      "account": "<string>",
      "key": "<string>",
      "logId": 123,
      "openBlockNumber": 123,
      "openBlockTime": "<string>",
      "closeBlockNumber": 123,
      "closeBlockTime": "<string>",
      "indexToken": "<string>",
      "pair": "<string>",
      "size": 123,
      "fee": 123,
      "collateral": 123,
      "averagePrice": 123,
      "funding": 123,
      "pnl": 123,
      "realisedPnl": 123,
      "roi": 123,
      "realisedRoi": 123,
      "isLong": true,
      "isWin": true,
      "isLiquidate": true,
      "leverage": 123,
      "orderCount": 123,
      "orderIncreaseCount": 123,
      "orderDecreaseCount": 123,
      "durationInSecond": 123,
      "status": "<string>",
      "createdAt": "<string>",
      "protocol": "<string>"
    }
  ],
  "meta": {
    "limit": 123,
    "offset": 123,
    "total": 123,
    "totalPages": 123
  }
}

Authentication

This endpoint requires authentication using a JWT token or API-KEY in the header.
Authorization
string
JWT token in the format: Authorization {token}
x-api-key
string
Token in the format: x-api-key {api-key}

Request Query

Query name: livePosition

Request Body

operationName
string
required
Name of the GraphQL operation (e.g., “Search”)
variables
object
required
Variables for the GraphQL query
query
string
required
GraphQL query string

Request Example

curl 'https://api.copin.io/graphql' \
  -H 'accept: */*' \
  -H 'accept-language: en-US,en;q=0.9,vi;q=0.8' \
  -H 'x-api-key: u9jpUfrTAukk45QjWVg7DBtQYxdGgy' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  --data-raw $'{"operationName":"Search","variables":{"index":"copin.positions","body":{"filter":{"and":[{"or":[{"field":"openBlockTime","lte":"2025-08-28T08:41:54.337Z","gte":"2025-08-27T08:41:54.337Z"},{"field":"closeBlockTime","lte":"2025-08-28T08:41:54.337Z","gte":"2025-08-27T08:41:54.337Z"}]}]},"sorts":{"field":"openBlockTime","direction":"desc"},"paging":{"size":20,"from":0}},"protocols":["GMX_V2","GNS_APE"]},"query":"query Search($index: String\u0021, $protocols: [String\u0021]\u0021, $body: SearchPayload\u0021) {\\n  livePosition(index: $index, protocols: $protocols, body: $body) {\\n    data {\\n      id\\n      synthetixPositionId\\n      account\\n      smartAccount\\n      protocol\\n      indexToken\\n      collateralToken\\n      key\\n      reverseIndex\\n      logId\\n      collateralInToken\\n      collateral\\n      lastCollateral\\n      size\\n      lastSizeNumber\\n      lastSize\\n      lastSizeInToken\\n      sizeInToken\\n      averagePrice\\n      fee\\n      feeInToken\\n      lastFunding\\n      funding\\n      fundingInToken\\n      pnl\\n      roi\\n      leverage\\n      orderCount\\n      orderIncreaseCount\\n      orderDecreaseCount\\n      openBlockNumber\\n      openBlockTime\\n      closeBlockNumber\\n      closeBlockTime\\n      durationInSecond\\n      isLong\\n      isWin\\n      isLiquidate\\n      status\\n      txHashes\\n      pair\\n      createdAt\\n      realisedPnlInToken\\n      realisedPnl\\n      realisedRoi\\n      updatedAt\\n      createdAt\\n      __typename\\n    }\\n    meta {\\n      total\\n      limit\\n      offset\\n      totalPages\\n      __typename\\n    }\\n    __typename\\n  }\\n}"}'

Response

The response includes a data property containing the requested GraphQL data.
data
array
Array of trader positions
meta
object
Metadata about the response

Response Example

{
    "data": {
        "livePosition": {
            "data": [
                {
                    "id": "68b015d060ef2b09156fce3f",
                    "synthetixPositionId": null,
                    "account": "0x35C85d656F3465176dD6906f2F6800C121Ee5BD8",
                    "smartAccount": null,
                    "protocol": "GMX_V2",
                    "indexToken": "0x09400D9DB990D5ed3f35D7be61DfAEB900Af03C9",
                    "collateralToken": "49.02",
                    "key": "0x79f8ea29781e33491e36df651b09ee3362f1ef994b56308c50475c3ac4e8839e",
                    "reverseIndex": null,
                    "logId": 48,
                    "collateralInToken": null,
                    "collateral": 49.015098,
                    "lastCollateral": null,
                    "size": 2449.6126,
                    "lastSizeNumber": null,
                    "lastSize": null,
                    "lastSizeInToken": null,
                    "sizeInToken": null,
                    "averagePrice": 214.238493,
                    "fee": 0.9799019999999999,
                    "feeInToken": null,
                    "lastFunding": null,
                    "funding": null,
                    "fundingInToken": null,
                    "pnl": 0.8176142659303159,
                    "roi": 0.01668086567796551,
                    "leverage": 49.976694935915454,
                    "orderCount": 1,
                    "orderIncreaseCount": 1,
                    "orderDecreaseCount": 0,
                    "openBlockNumber": 373124784,
                    "openBlockTime": "2025-08-28T08:39:42.000Z",
                    "closeBlockNumber": null,
                    "closeBlockTime": null,
                    "durationInSecond": null,
                    "isLong": true,
                    "isWin": null,
                    "isLiquidate": false,
                    "status": "OPEN",
                    "txHashes": [
                        "0x703a46efad7ec118d05d3942380f52bfc1ac47210fbdc9c46907815bb9a4a5dd"
                    ],
                    "pair": "SOL-USDT",
                    "createdAt": "2025-08-28T08:39:44.809Z",
                    "realisedPnlInToken": null,
                    "realisedPnl": 1.2749760715885772,
                    "realisedRoi": 0.026011904976474334,
                    "updatedAt": "2025-08-28T08:41:15.463Z",
                    "__typename": "TopPosition"
                }
            ],
            "meta": {
                "total": 2441,
                "limit": 20,
                "offset": 0,
                "totalPages": 123,
                "__typename": "PagingOutput"
            },
            "__typename": "TopPositionSearchResponse"
        }
    }
}