Kraken Websockets API 1.1.0

Overview

WebSockets API offers real-time market data updates. WebSockets is a bidirectional protocol offering fastest real-time data, helping you build real-time applications. The public message types presented below do not require authentication. Private-data messages messages can be subscribed on a separate authenticated endpoint.

General Considerations

Connection details

  • Connection details for production environment:

    URL Scheme Description
    ws.kraken.com wss

    Once the socket is open you can subscribe to a public channel by sending a subscribe request message.

  • Connection details for authenticated production access:

    URL Scheme Description
    ws-auth.kraken.com wss

    Once the socket is open you can subscribe to private-data channels by sending an authenticated subscribe request message.

  • Connection details for beta environment:

    URL Scheme Description
    beta-ws.kraken.com wss

    Once the socket is open you can subscribe to a public channel by sending a subscribe request message.
    Websockets Beta Documentation

  • Connection details for authenticated beta access:

    URL Scheme Description
    beta-ws-auth.kraken.com wss

    Once the socket is open you can subscribe to private-data channels by sending an authenticated subscribe request message.
    Websockets Beta Documentation

    Authentication

    The API client must request an authentication "token" via the following REST API endpoint "GetWebSocketsToken" to connect to WebSockets Private endpoints. The token should be used within 15 minutes of creation. The token does not expire once a connection to a WebSockets API private message (openOrders or ownTrades) is maintained.

    Endpoint URL: https://api.kraken.com/0/private/GetWebSocketsToken

    The resulting token must be provided in the "token" field of any new private WebSocket feed subscription:

    {
      "event": "subscribe",
      "subscription":
      {
        "name": "ownTrades",
        "token": "WW91ciBhdXRoZW50aWNhdGlvbiB0b2tlbiBnb2VzIGhlcmUu"
      }
    }

    Book Checksum

    Each book update message will have a checksum value appended. The checksum is a CRC32 value based on the top 10 bids and 10 asks, and you can use it to verify that your data is correct and up to date by calculating the checksum independently and comparing it against the value provided.

    Checksums will not be sent in book snapshot messages, but rather only in book update messages. In the following sample book update messages, note the checksum field appears in the last bid or ask map structure in the message.

    Sample with asks only:

    [
        0,
        {
            "a": [
                ["0.05120", "0.00000500", "1582905486.493008"],
                ["0.05275", "0.00000500", "1582905486.493034"]
            ],
            "c": "974947235" <-- CRC32 checksum is here.
        },
        "book-1000",
        "XBT/USD"
    ]

    Sample with bids only:

    [
        0,
        {
            "b": [
                ["0.04765", "0.00000500", "1582905486.493008"],
                ["0.04940", "0.00000500", "1582905486.493034"]
            ],
            "c": "974947235" <-- CRC32 checksum is here.
        },
        "book-1000",
        "XBT/USD"
    ]

    Sample with both bids and asks:

    [
        0,
        {
            "a": [
                ["0.05120", "0.00000500", "1582905486.493008"],
                ["0.05275", "0.00000500", "1582905486.493034"]
            ]
        },
        {
            "b": [
                ["0.04765", "0.00000500", "1582905486.493008"],
                ["0.04940", "0.00000500", "1582905486.493034"]
            ],
            "c": "974947235" <-- CRC32 checksum is here.
        },
        "book-1000",
        "XBT/USD"
    ]

    Book Checksum Calculation

    The checksum is computed by concatenating the top 10 bids and asks in the current book in a particular format and then taking the CRC32 checksum of that string. The price and volume values should be treated as a string and formatted and concatenated as follows.

    Note: Processing order is important. First, the top ten ask price levels should be processed, sorted by price from low to high. Then, the top ten bid price levels should be processed, sorted by price from high to low.

    Consider you are subscribed at depth = 100 on the "book" channel and you receive the following book update message:

    [ "0.05000", "0.00000304", "1582905487.439814" ]

    This update should be processed as follows:

    1. Apply the update to your local copy of the book.
    2. For each of the top ten ask price levels, sorted by price from low to high:
      1. Remove the decimal character, '.', from the price, i.e. "0.05000" -> "005000".
      2. Remove all leading zero characters from the price. i.e. "005000" -> "5000".
      3. Add the formatted price string to the concatenation.
      4. Repeat steps a-c above but for the volume.

      For example, the price level corresponding to the sample update above would be formatted as "5000304". Note the timestamp values are not used in this calculation.

    3. Repeat the above steps for the top ten bids, sorted by price from high to low.
    4. Feed the concatenated string as input to a CRC32 checksum function, storing the result.
    5. Cast the result (comprising 32 bits) as an unsigned 32-bit integer. This value can now be compared to the checksum received to ensure your local book is accurate.

    For example, given the following book state:

    {
    "as": [
        [ "0.05005", "0.00000500", "1582905487.684110" ],
        [ "0.05010", "0.00000500", "1582905486.187983" ],
        [ "0.05015", "0.00000500", "1582905484.480241" ],
        [ "0.05020", "0.00000500", "1582905486.645658" ],
        [ "0.05025", "0.00000500", "1582905486.859009" ],
        [ "0.05030", "0.00000500", "1582905488.601486" ],
        [ "0.05035", "0.00000500", "1582905488.357312" ],
        [ "0.05040", "0.00000500", "1582905488.785484" ],
        [ "0.05045", "0.00000500", "1582905485.302661" ],
        [ "0.05050", "0.00000500", "1582905486.157467" ] ],
    "bs": [
        [ "0.05000", "0.00000500", "1582905487.439814" ],
        [ "0.04995", "0.00000500", "1582905485.119396" ],
        [ "0.04990", "0.00000500", "1582905486.432052" ],
        [ "0.04980", "0.00000500", "1582905480.609351" ],
        [ "0.04975", "0.00000500", "1582905476.793880" ],
        [ "0.04970", "0.00000500", "1582905486.767461" ],
        [ "0.04965", "0.00000500", "1582905481.767528" ],
        [ "0.04960", "0.00000500", "1582905487.378907" ],
        [ "0.04955", "0.00000500", "1582905483.626664" ],
        [ "0.04950", "0.00000500", "1582905488.509872" ] ]
    }

    The checksum input should be as follows (newlines appear here for convenience only and should not be included):

    "50055005010500501550050205005025500
    50305005035500504050050455005050500
    50005004995500499050049805004975500
    49705004965500496050049555004950500"

    The final unsigned CRC32 checksum value will then be "974947235".

    Error Types

    The following error messages are thrown as part of subscriptionStatus message.

    The following error messages may be thrown for public data requests:

    • Already subscribed
    • Currency pair not in ISO 4217-A3 format
    • Malformed request
    • Pair field must be an array
    • Pair field unsupported for this subscription type
    • Pair(s) not found
    • Subscription book depth must be an integer
    • Subscription depth not supported
    • Subscription field must be an object
    • Subscription name invalid
    • Subscription object unsupported field
    • Subscription ohlc interval must be an integer
    • Subscription ohlc interval not supported
    • Subscription ohlc requires interval

    The following error messages may be thrown for private data requests:

    • EAccount:Invalid permissions
    • EAuth:Account temporary disabled
    • EAuth:Account unconfirmed
    • EAuth:Rate limit exceeded
    • EAuth:Too many requests
    • EGeneral:Invalid arguments
    • EOrder:Cannot open opposing position
    • EOrder:Cannot open position
    • EOrder:Insufficient funds (insufficient user funds)
    • EOrder:Insufficient margin (exchange does not have sufficient funds to allow margin trading)
    • EOrder:Invalid price
    • EOrder:Margin allowance exceeded
    • EOrder:Margin level too low
    • EOrder:Order minimum not met (volume too low)
    • EOrder:Orders limit exceeded
    • EOrder:Positions limit exceeded
    • EOrder:Rate limit exceeded
    • EOrder:Scheduled orders limit exceeded
    • EOrder:Unknown position
    • EService:Unavailable
    • ETrade:Invalid request

    General error messages will have the following structure. However, error responses related to particular requests such as subscriptionStatus, addOrder, cancelOrder may be returned in the appropriate response message type:


    Name Type Description
    event string error
    errorMessage string Error detail message.
    reqid integer Optional - client originated ID reflected in response message

    Examples of payload

    {
      "errorMessage": "Malformed request",
      "event": "error"
    }
    {
      "errorMessage":"Exceeded msg rate",
      "event": "error",
      "reqid": 42
    }

    Example API Clients

    Below are sample API client code libraries that can be used when writing your own API client. Please keep in mind that Payward nor the third party authors are responsible for losses due to bugs or improper use of the APIs. Payward has performed an initial review of the safety of the third party code before listing them but cannot vouch for any changes added since then. If you have concerns, please contact support .

    Messages

    ping

    Request. Client can ping server to determine whether connection is alive, server responds with pong. This is an application level ping as opposed to default ping in websockets standard which is server initiated

    Payload

    Name Type Description
    event string
    reqid integer Optional - client originated ID reflected in response message

    Example of payload

    {
      "event": "ping",
      "reqid": 42
    }

    pong

    Response. Server pong response to a ping to determine whether connection is alive. This is an application level pong as opposed to default pong in websockets standard which is sent by client in response to a ping

    Payload

    Name Type Description
    event string
    reqid integer Optional - matching client originated request ID

    Example of payload

    {
      "event": "pong",
      "reqid": 42
    }

    heartbeat

    Publication: Server heartbeat sent if no subscription traffic within 1 second (approximately)

    Payload

    Name Type Description
    event string

    Example of payload

    {
      "event": "heartbeat"
    }

    systemStatus

    Publication: Status sent on connection or system status changes.

    Payload

    Name Type Description
    connectionID integer Connection ID
    event string systemStatus
    status string online|maintenance|(custom status tbd)
    version string

    Example of payload

    {
      "connectionID": 8628615390848610000,
      "event": "systemStatus",
      "status": "online",
      "version": "1.0.0"
    }

    subscribe

    Request. Subscribe to a topic on a single or multiple currency pairs.

    Payload

    Name Type Description
    event string subscribe
    reqid integer Optional - client originated ID reflected in response message
    pair array Optional - Array of currency pairs. Format of each pair is "A/B", where A and B are ISO 4217-A3 for standardized assets and popular unique symbol if not standardized.
    subscription object
    depth integer Optional - depth associated with book subscription in float of levels each side, default 10. Valid Options are: 10, 25, 100, 500, 1000
    interval integer Optional - Time interval associated with ohlc subscription in minutes. Default 1. Valid Interval values: 1|5|15|30|60|240|1440|10080|21600
    token string Optional - base64-encoded authentication token for private-data endpoints
    name string ticker|ohlc|trade|book|spread|ownTrades|openOrders|*, * for all available channels depending on the connected environment (ohlc interval value is 1 if all public channels subscribed)

    Example of payload

    {
      "event": "subscribe",
      "pair": [
        "XBT/USD",
        "XBT/EUR"
      ],
      "subscription": {
        "name": "ticker"
      }
    }
    {
      "event": "subscribe",
      "pair": [
        "XBT/EUR"
      ],
      "subscription": {
        "interval": 5,
        "name": "ohlc"
      }
    }
    {
      "event": "subscribe",
      "subscription": {
        "name": "ownTrades",
        "token": "WW91ciBhdXRoZW50aWNhdGlvbiB0b2tlbiBnb2VzIGhlcmUu"
      }
    }

    unsubscribe

    Request. Unsubscribe, can specify a channelID or multiple currency pairs.

    Payload

    Name Type Description
    Message Payload oneOf
    Anonymous object
    event string unsubscribe
    reqid integer Optional - client originated ID reflected in response message
    pair array Optional - Array of currency pairs. Format of each pair is "A/B", where A and B are ISO 4217-A3 for standardized assets and popular unique symbol if not standardized.
    subscription object
    depth integer Optional - depth associated with book subscription in float of levels each side, default 10. Valid Options are: 10, 25, 100, 500, 1000
    interval integer Optional - Time interval associated with ohlc subscription in minutes. Default 1. Valid Interval values: 1|5|15|30|60|240|1440|10080|21600
    token string Optional - base64-encoded authentication token for private-data endpoints
    name string ticker|ohlc|trade|book|spread|ownTrades|openOrders|*, * for all available channels depending on the connected environment (ohlc interval value is 1 if all public channels subscribed)
    Anonymous object
    event string unsubscribe
    reqid integer Optional - client originated ID reflected in response message
    channelID integer ChannelID associated with pair subscription

    Example of payload

    {
      "event": "unsubscribe",
      "pair": [
        "XBT/EUR",
        "XBT/USD"
      ],
      "subscription": {
        "name": "ticker"
      }
    }
    {
      "channelID": 10001,
      "event": "unsubscribe"
    }
    {
      "event": "unsubscribe",
      "subscription": {
        "name": "ownTrades",
        "token": "WW91ciBhdXRoZW50aWNhdGlvbiB0b2tlbiBnb2VzIGhlcmUu"
      }
    }

    subscriptionStatus

    Response. Subscription status response to subscribe, unsubscribe or exchange initiated unsubscribe.

    Payload

    Name Type Description
    channelID integer ChannelID on successful subscription, applicable to public messages only
    channelName string Channel Name on successful subscription. For payloads 'ohlc' and 'book', respective interval or depth will be added as suffix.
    event string
    reqid integer Optional - matching client originated request ID
    pair string Currency pair, applicable to public messages only
    status string Status of subscription
    subscription object
    depth integer Optional - depth associated with book subscription in float of levels each side, default 10. Valid Options are: 10, 25, 100, 500, 1000
    interval integer Optional - Time interval associated with ohlc subscription in minutes. Default 1. Valid Interval values: 1|5|15|30|60|240|1440|10080|21600
    token string Optional - base64-encoded authentication token for private-data endpoints
    name string ticker|ohlc|trade|book|spread|ownTrades|openOrders|*, * for all available channels depending on the connected environment (ohlc interval value is 1 if all public channels subscribed)
    OneOf oneOf
    errorMessage string Error message
    channelID integer ChannelID on successful subscription operation, applicable to public messages only

    Example of payload

    {
      "channelID": 10001,
      "channelName": "ticker",
      "event": "subscriptionStatus",
      "pair": "XBT/EUR",
      "status": "subscribed",
      "subscription": {
        "name": "ticker"
      }
    }
    {
      "channelID": 10001,
      "channelName": "ohlc-5",
      "event": "subscriptionStatus",
      "pair": "XBT/EUR",
      "reqid": 42,
      "status": "unsubscribed",
      "subscription": {
        "interval": 5,
        "name": "ohlc"
      }
    }
    {
      "channelName": "ownTrades",
      "event": "subscriptionStatus",
      "status": "subscribed",
      "subscription": {
        "name": "ownTrades"
      }
    }
    {
      "errorMessage": "Subscription depth not supported",
      "event": "subscriptionStatus",
      "pair": "XBT/USD",
      "status": "error",
      "subscription": {
        "depth": 42,
        "name": "book"
      }
    }

    ticker

    Publication: Ticker information on currency pair.

    Payload

    Name Type Description
    channelID integer ChannelID of pair-ticker subscription
    (Anonymous) object
    a array Ask
    price float Best ask price
    wholeLotVolume integer Whole lot volume
    lotVolume float Lot volume
    b array Bid
    price float Best bid price
    wholeLotVolume integer Whole lot volume
    lotVolume float Lot volume
    c array Close
    price float Price
    lotVolume float Lot volume
    v array Volume
    today float Value today
    last24Hours float Value over last 24 hours
    p array Volume weighted average price
    today float Value today
    last24Hours float Value over last 24 hours
    t array Number of trades
    today integer Value today
    last24Hours integer Value over last 24 hours
    l array Low price
    today float Value today
    last24Hours float Value over last 24 hours
    h array High price
    today float Value today
    last24Hours float Value over last 24 hours
    o array Open Price
    today float Value today
    last24Hours float Value over last 24 hours
    channelName string Channel Name of subscription
    pair string Asset pair

    Example of payload

    [
      0,
      {
        "a": [
          "5525.40000",
          1,
          "1.000"
        ],
        "b": [
          "5525.10000",
          1,
          "1.000"
        ],
        "c": [
          "5525.10000",
          "0.00398963"
        ],
        "h": [
          "5783.00000",
          "5783.00000"
        ],
        "l": [
          "5505.00000",
          "5505.00000"
        ],
        "o": [
          "5760.70000",
          "5763.40000"
        ],
        "p": [
          "5631.44067",
          "5653.78939"
        ],
        "t": [
          11493,
          16267
        ],
        "v": [
          "2634.11501494",
          "3591.17907851"
        ]
      },
      "ticker",
      "XBT/USD"
    ]

    ohlc

    Publication: Open High Low Close (Candle) feed for a currency pair and interval period.

    Description: When subscribed for OHLC, a snapshot of the last valid candle (irrespective of the endtime) will be sent, followed by updates to the running candle. For example, if a subscription is made to 1 min candle and there have been no trades for 5 mins, a snapshot of the last 1 min candle from 5 mins ago will be published. The endtime can be used to determine that it is an old candle.

    Payload

    Name Type Description
    channelID integer ChannelID of pair-ohlc subscription
    Array array
    time float Begin time of interval, in seconds since epoch
    etime float End time of interval, in seconds since epoch
    open float Open price of interval
    high float High price within interval
    low float Low price within interval
    close float Close price of interval
    vwap float Volume weighted average price within interval
    volume integer Accumulated volume within interval
    count integer Number of trades within interval
    channelName string Channel Name of subscription
    pair string Asset pair

    Example of payload

    [
      42,
      [
        "1542057314.748456",
        "1542057360.435743",
        "3586.70000",
        "3586.70000",
        "3586.60000",
        "3586.60000",
        "3586.68894",
        "0.03373000",
        2
      ],
      "ohlc-5",
      "XBT/USD"
    ]

    trade

    Publication: Trade feed for a currency pair.

    Payload

    Name Type Description
    channelID integer ChannelID of pair-trade subscription
    Array array
    Array array
    price float Price
    volume float Volume
    time float Time, seconds since epoch
    side string Triggering order side, buy/sell
    orderType string Triggering order type market/limit
    misc string Miscellaneous
    channelName string Channel Name of subscription
    pair string Asset pair

    Example of payload

    [
      0,
      [
        [
          "5541.20000",
          "0.15850568",
          "1534614057.321597",
          "s",
          "l",
          ""
        ],
        [
          "6060.00000",
          "0.02455000",
          "1534614057.324998",
          "b",
          "l",
          ""
        ]
      ],
      "trade",
      "XBT/USD"
    ]

    spread

    Publication: Spread feed for a currency pair.

    Payload

    Name Type Description
    channelID integer ChannelID of pair-spreads subscription
    Array array
    bid float Bid price
    ask float Ask price
    timestamp float Time, seconds since epoch
    bidVolume float Bid Volume
    askVolume float Ask Volume
    channelName string Channel Name of subscription
    pair string Asset pair

    Example of payload

    [
      0,
      [
        "5698.40000",
        "5700.00000",
        "1542057299.545897",
        "1.01234567",
        "0.98765432"
      ],
      "spread",
      "XBT/USD"
    ]

    book

    Publication: Order book levels. On subscription, a snapshot will be published at the specified depth, following the snapshot, level updates will be published

    Snapshot payload

    Name Type Description
    channelID integer ChannelID of pair-order book levels subscription
    (Anonymous) object
    as array Array of price levels, ascending from best ask
    Array array Anonymous array of level values
    price float Price level
    volume float Price level volume, for updates volume = 0 for level removal/deletion
    timestamp float Price level last updated, seconds since epoch
    bs array Array of price levels, descending from best bid
    Array array Anonymous array of level values
    price float Price level
    volume float Price level volume, for updates volume = 0 for level removal/deletion
    timestamp float Price level last updated, seconds since epoch
    channelName string Channel Name of subscription
    pair string Asset pair

    Example of snapshot payload

    [
      0,
      {
        "as": [
          [
            "5541.30000",
            "2.50700000",
            "1534614248.123678"
          ],
          [
            "5541.80000",
            "0.33000000",
            "1534614098.345543"
          ],
          [
            "5542.70000",
            "0.64700000",
            "1534614244.654432"
          ]
        ],
        "bs": [
          [
            "5541.20000",
            "1.52900000",
            "1534614248.765567"
          ],
          [
            "5539.90000",
            "0.30000000",
            "1534614241.769870"
          ],
          [
            "5539.50000",
            "5.00000000",
            "1534613831.243486"
          ]
        ]
      },
      "book-100",
      "XBT/USD"
    ]

    Update payload

    Name Type Description
    channelID integer ChannelID of pair-order book levels subscription
    AnyOf anyOf
    (Anonymous) object Container for ask updates
    a array Ask array of level updates
    (Array) array Anonymous array of level values
    price float Price level
    volume float Price level volume, for updates volume = 0 for level removal/deletion
    timestamp float Price level last updated, seconds since epoch
    updateType string Optional - "r" in case update is a republished update
    c string Optional - Book checksum as a quoted unsigned 32-bit integer, present only within the last update container in the message. See calculation details.
    (Anonymous) object Container for bid updates
    b array Bid array of level updates
    (Array) array Anonymous array of level values
    price float Price level
    volume float Price level volume, for updates volume = 0 for level removal/deletion
    timestamp float Price level last updated, seconds since epoch
    updateType string Optional - "r" in case update is a republished update
    c string Optional - Book checksum as a quoted unsigned 32-bit integer, present only within the last update container in the message. See calculation details.
    channelName string Channel Name of subscription
    pair string Asset pair

    Example of update payload

    [
      1234,
      {
        "a": [
          [
            "5541.30000",
            "2.50700000",
            "1534614248.456738"
          ],
          [
            "5542.50000",
            "0.40100000",
            "1534614248.456738"
          ]
        ],
        "c": "974942666"
      },
      "book-10",
      "XBT/USD"
    ]
    [
      1234,
      {
        "b": [
          [
            "5541.30000",
            "0.00000000",
            "1534614335.345903"
          ]
        ],
        "c": "974942666"
      },
      "book-10",
      "XBT/USD"
    ]
    [
      1234,
      {
        "a": [
          [
            "5541.30000",
            "2.50700000",
            "1534614248.456738"
          ],
          [
            "5542.50000",
            "0.40100000",
            "1534614248.456738"
          ]
        ]
      },
      {
        "b": [
          [
            "5541.30000",
            "0.00000000",
            "1534614335.345903"
          ]
        ],
        "c": "974942666"
      },
      "book-10",
      "XBT/USD"
    ]

    Example of republish payload

    [
      1234,
      {
        "a": [
          [
            "5541.30000",
            "2.50700000",
            "1534614248.456738",
            "r"
          ],
          [
            "5542.50000",
            "0.40100000",
            "1534614248.456738",
            "r"
          ]
        ],
        "c": "974942666"
      },
      "book-25",
      "XBT/USD"
    ]

    ownTrades

    Publication: Own trades. On subscription last 50 trades for the user will be sent, followed by new trades.

    Payload

    Name Type Description
    (Dictionary) object
    tradeid object Trade object
    ordertxid string order responsible for execution of trade
    postxid string Position trade id
    pair string Asset pair
    time float unix timestamp of trade
    type string type of order (buy/sell)
    ordertype string order type
    price float average price order was executed at (quote currency)
    cost float total cost of order (quote currency)
    fee float total fee (quote currency)
    vol float volume (base currency)
    margin float initial margin (quote currency)
    channelName string Channel Name of subscription

    Example of payload

    [
      [
        {
          "TDLH43-DVQXD-2KHVYY": {
            "cost": "1000000.00000",
            "fee": "1600.00000",
            "margin": "0.00000",
            "ordertxid": "TDLH43-DVQXD-2KHVYY",
            "ordertype": "limit",
            "pair": "XBT/EUR",
            "postxid": "OGTT3Y-C6I3P-XRI6HX",
            "price": "100000.00000",
            "time": "1560516023.070651",
            "type": "sell",
            "vol": "1000000000.00000000"
          }
        },
        {
          "TDLH43-DVQXD-2KHVYY": {
            "cost": "1000000.00000",
            "fee": "600.00000",
            "margin": "0.00000",
            "ordertxid": "TDLH43-DVQXD-2KHVYY",
            "ordertype": "limit",
            "pair": "XBT/EUR",
            "postxid": "OGTT3Y-C6I3P-XRI6HX",
            "price": "100000.00000",
            "time": "1560516023.070658",
            "type": "buy",
            "vol": "1000000000.00000000"
          }
        },
        {
          "TDLH43-DVQXD-2KHVYY": {
            "cost": "1000000.00000",
            "fee": "1600.00000",
            "margin": "0.00000",
            "ordertxid": "TDLH43-DVQXD-2KHVYY",
            "ordertype": "limit",
            "pair": "XBT/EUR",
            "postxid": "OGTT3Y-C6I3P-XRI6HX",
            "price": "100000.00000",
            "time": "1560520332.914657",
            "type": "sell",
            "vol": "1000000000.00000000"
          }
        },
        {
          "TDLH43-DVQXD-2KHVYY": {
            "cost": "1000000.00000",
            "fee": "600.00000",
            "margin": "0.00000",
            "ordertxid": "TDLH43-DVQXD-2KHVYY",
            "ordertype": "limit",
            "pair": "XBT/EUR",
            "postxid": "OGTT3Y-C6I3P-XRI6HX",
            "price": "100000.00000",
            "time": "1560520332.914664",
            "type": "buy",
            "vol": "1000000000.00000000"
          }
        }
      ],
      "ownTrades"
    ]

    openOrders

    Publication: Open orders. Feed to show all the open orders belonging to the user authenticated API key. Initial snapshot will provide list of all open orders and then any updates to the open orders list will be sent. For status change updates, such as 'closed', the fields orderid and status will be present in the payload.

    Payload

    Name Type Description
    (Dictionary) object
    orderid object Order object
    refid string Referral order transaction id that created this order
    userref integer user reference ID
    status string status of order:
    opentm float unix timestamp of when order was placed
    starttm float unix timestamp of order start time (if set)
    expiretm float unix timestamp of order end time (if set)
    descr object order description info
    pair string asset pair
    position string Optional - position ID (if applicable)
    type string type of order (buy/sell)
    ordertype string order type
    price float primary price
    price2 float secondary price
    leverage float amount of leverage
    order string order description
    close string conditional close order description (if conditional close set)
    vol float volume of order (base currency unless viqc set in oflags)
    vol_exec float total volume executed so far (base currency unless viqc set in oflags)
    cost float total cost (quote currency unless unless viqc set in oflags)
    fee float total fee (quote currency)
    avg_price float average price (cumulative; quote currency unless viqc set in oflags)
    stopprice float stop price (quote currency, for trailing stops)
    limitprice float triggered limit price (quote currency, when limit based order type triggered)
    misc string comma delimited list of miscellaneous info: stopped=triggered by stop price, touched=triggered by touch price, liquidation=liquidation, partial=partial fill
    oflags string Optional - comma delimited list of order flags. viqc = volume in quote currency (not currently available), fcib = prefer fee in base currency, fciq = prefer fee in quote currency, nompp = no market price protection, post = post only order (available when ordertype = limit)
    channelName string Channel Name of subscription

    Example of payload

    [
      [
        {
          "OGTT3Y-C6I3P-XRI6HX": {
            "cost": "0.00000",
            "descr": {
              "close": "",
              "leverage": "0:1",
              "order": "sell 10.00345345 XBT/EUR @ limit 34.50000 with 0:1 leverage",
              "ordertype": "limit",
              "pair": "XBT/EUR",
              "price": "34.50000",
              "price2": "0.00000",
              "type": "sell"
            },
            "expiretm": "0.000000",
            "fee": "0.00000",
            "limitprice": "34.50000",
            "misc": "",
            "oflags": "fcib",
            "opentm": "0.000000",
            "price": "34.50000",
            "refid": "OKIVMP-5GVZN-Z2D2UA",
            "starttm": "0.000000",
            "status": "open",
            "stopprice": "0.000000",
            "userref": 0,
            "vol": "10.00345345",
            "vol_exec": "0.00000000"
          }
        },
        {
          "OGTT3Y-C6I3P-XRI6HX": {
            "cost": "0.00000",
            "descr": {
              "close": "",
              "leverage": "0:1",
              "order": "sell 0.00000010 XBT/EUR @ limit 5334.60000 with 0:1 leverage",
              "ordertype": "limit",
              "pair": "XBT/EUR",
              "price": "5334.60000",
              "price2": "0.00000",
              "type": "sell"
            },
            "expiretm": "0.000000",
            "fee": "0.00000",
            "limitprice": "5334.60000",
            "misc": "",
            "oflags": "fcib",
            "opentm": "0.000000",
            "price": "5334.60000",
            "refid": "OKIVMP-5GVZN-Z2D2UA",
            "starttm": "0.000000",
            "status": "open",
            "stopprice": "0.000000",
            "userref": 0,
            "vol": "0.00000010",
            "vol_exec": "0.00000000"
          }
        },
        {
          "OGTT3Y-C6I3P-XRI6HX": {
            "cost": "0.00000",
            "descr": {
              "close": "",
              "leverage": "0:1",
              "order": "sell 0.00001000 XBT/EUR @ limit 90.40000 with 0:1 leverage",
              "ordertype": "limit",
              "pair": "XBT/EUR",
              "price": "90.40000",
              "price2": "0.00000",
              "type": "sell"
            },
            "expiretm": "0.000000",
            "fee": "0.00000",
            "limitprice": "90.40000",
            "misc": "",
            "oflags": "fcib",
            "opentm": "0.000000",
            "price": "90.40000",
            "refid": "OKIVMP-5GVZN-Z2D2UA",
            "starttm": "0.000000",
            "status": "open",
            "stopprice": "0.000000",
            "userref": 0,
            "vol": "0.00001000",
            "vol_exec": "0.00000000"
          }
        },
        {
          "OGTT3Y-C6I3P-XRI6HX": {
            "cost": "0.00000",
            "descr": {
              "close": "",
              "leverage": "0:1",
              "order": "sell 0.00001000 XBT/EUR @ limit 9.00000 with 0:1 leverage",
              "ordertype": "limit",
              "pair": "XBT/EUR",
              "price": "9.00000",
              "price2": "0.00000",
              "type": "sell"
            },
            "expiretm": "0.000000",
            "fee": "0.00000",
            "limitprice": "9.00000",
            "misc": "",
            "oflags": "fcib",
            "opentm": "0.000000",
            "price": "9.00000",
            "refid": "OKIVMP-5GVZN-Z2D2UA",
            "starttm": "0.000000",
            "status": "open",
            "stopprice": "0.000000",
            "userref": 0,
            "vol": "0.00001000",
            "vol_exec": "0.00000000"
          }
        }
      ],
      "openOrders"
    ]

    Example of status-change payload

    [
      [
        {
          "OGTT3Y-C6I3P-XRI6HX": {
            "status": "closed"
          }
        },
        {
          "OGTT3Y-C6I3P-XRI6HX": {
            "status": "closed"
          }
        }
      ],
      "openOrders"
    ]

    addOrder

    Request. Add new order.

    Payload

    Name Type Description
    event string addOrder
    token string Session token string
    reqid integer Optional - client originated requestID sent as acknowledgment in the message response
    ordertype string Order type - market|limit|stop-loss|take-profit|stop-loss-limit|take-profit-limit|settle-position
    type string Side, buy or sell
    pair string Currency pair
    price float Optional dependent on order type - order price
    price2 float Optional dependent on order type - order secondary price
    volume float Order volume in lots
    leverage float amount of leverage desired (optional; default = none)
    oflags string Optional - comma delimited list of order flags. viqc = volume in quote currency (not currently available), fcib = prefer fee in base currency, fciq = prefer fee in quote currency, nompp = no market price protection, post = post only order (available when ordertype = limit)
    starttm string Optional - scheduled start time. 0 = now (default) +<n> = schedule start time <n> seconds from now <n> = unix timestamp of start time
    expiretm string Optional - expiration time. 0 = no expiration (default) +<n> = expire <n> seconds from now <n> = unix timestamp of expiration time
    userref string Optional - user reference ID (should be an integer in quotes)
    validate string Optional - validate inputs only; do not submit order (not currently available)
    close[ordertype] string Optional - close order type.
    close[price] float Optional - close order price.
    close[price2] float Optional - close order secondary price.
    trading_agreement string Optional - should be set to "agree" by German residents in order to signify acceptance of the terms of the Kraken Trading Agreement .

    Example of payload

    {
      "event": "addOrder",
      "ordertype": "limit",
      "pair": "XBT/USD",
      "price": "9000",
      "token": "0000000000000000000000000000000000000000",
      "type": "buy",
      "volume": "10"
    }

    Example of payload when conditional close order is sent

    {
      "close[ordertype]": "limit",
      "close[price]": "9100",
      "event": "addOrder",
      "ordertype": "limit",
      "pair": "XBT/USD",
      "price": "9000",
      "token": "0000000000000000000000000000000000000000",
      "type": "buy",
      "volume": "10"
    }

    Response payload

    Name Type Description
    event string addOrderStatus
    reqid integer Optional - client originated requestID sent as acknowledgment in the message response
    status string Status. "ok" or "error"
    txid string order ID (if successful)
    descr string order description info (if successful)
    errorMessage string error message (if unsuccessful)

    Example of payload

    {
      "descr": "buy 0.01770000 XBTUSD @ limit 4000",
      "event": "addOrderStatus",
      "status": "ok",
      "txid": "ONPNXH-KMKMU-F4MR5V"
    }
    {
      "errorMessage": "EOrder:Order minimum not met",
      "event": "addOrderStatus",
      "status": "error"
    }

    cancelOrder

    Request. Cancel order or list of orders.

    For every cancelOrder message, an update message 'closeOrderStatus' is sent. For multiple orderid in cancelOrder, multiple update messages for 'closeOrderStatus' will be sent.

    For example, if a cancelOrder request is sent for cancelling three orders [A, B, C], then if two update messages for 'closeOrderStatus' are received along with an error such as 'EOrder: Unknown order', then it would imply that the third order is not cancelled. The error message could be different based on the condition which was not met by the 'cancelOrder' request.

    Payload

    Name Type Description
    event string cancelOrder
    token string Session token string
    reqid integer Optional - client originated requestID sent as acknowledgment in the message response
    txid array Array of order IDs to be canceled. These can be user reference IDs.

    Example of payload

    {
      "event": "cancelOrder",
      "token": "0000000000000000000000000000000000000000",
      "txid": [
        "OGTT3Y-C6I3P-XRI6HX",
        "OGTT3Y-C6I3P-X2I6HX"
      ]
    }

    Response payload

    Name Type Description
    event string cancelOrderStatus
    reqid integer Optional - client originated requestID sent as acknowledgment in the message response
    status string Status. "ok" or "error"
    errorMessage string error message (if unsuccessful)

    Example of payload

    {
      "event": "cancelOrderStatus",
      "status": "ok"
    }
    {
      "errorMessage": "EOrder:Unknown order",
      "event": "cancelOrderStatus",
      "status": "error"
    }