Latest 1.1.0
License MIT
Platforms ios 10.3
Dependencies CryptoSwift

Kraken Swift


Please thoroughly vet everything in the code for yourself before using this lib to buy, sell, or move any of your assets.

PLEASE submit an issue or pull request if you notice any bugs, security holes, or potential improvements. Any help is appreciated!


This library is a wrapper for the Kraken Digital Asset Trading Platform API. Official documentation from Kraken can be found here.

The current version can be used to query public/private data and make trades. Private data queries and trading functionality require use of your Kraken account API keys.

Kraken Swift was initially built by Antonio Casero
Heavy modifications have been added by Jonas-Taha El Sesiy



Just add this dependency to your Podfile:

pod Kraken

The transitive dependency to CryptoSwift is added automatically.


Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Kraken into your Xcode project using Carthage, specify it in your Cartfile:

github "antoniocasero/Kraken" ~> 1.0

Run carthage update to build the framework and drag the built Kraken.framework into your Xcode project.


If you prefer not to use any of the aforementioned dependency managers, you can integrate Kraken into your project manually.

Embedded Framework

  • Open up Terminal, cd into your top-level project directory, and run the following command "if" your project is not initialized as a git repository:

    $ git init
  • Add Kraken as a git submodule by running the following command:

    $ git submodule add
  • Open the new Kraken folder, and drag the Kraken.xcodeproj into the Project Navigator of your application’s Xcode project.

    It should appear nested underneath your application’s blue project icon. Whether it is above or below all the other Xcode groups does not matter.

  • Select the Kraken.xcodeproj in the Project Navigator and verify the deployment target matches that of your application target.
  • Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar.
  • In the tab bar at the top of that window, open the "General" panel.
  • Click on the + button under the "Embedded Binaries" section.
  • Select the top Kraken.framework
  • And that’s it!

    The Kraken.framework is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.


Create a Kraken client using your credentials

let credentials = Kraken.Credentials(key: "0Q/eOVRtyfg+WbIuLjKJ.....",
                                     secret: "EVFTYSinNiC89V.....")

let kraken = Kraken(credentials: credentials)

kraken.serverTime(completion: { let _ = ${ print($0) } } // 1393056191

Public Data Methods

Server Time

This functionality is provided by Kraken to to aid in approximating the skew time between the server and client.

 kraken.serverTime { result in
    switch result {
         case .success(let serverTime):
                serverTime["unixtime"] // 1393056191
                serverTime["rfc1123"] // "Sat, 22 Feb 2014 08:28:04 GMT"
         case .failure(let error): print(error)

Asset Info

Returns the assets that can be traded on the exchange. This method can be passed info, aclass (asset class), and asset options. An example below is given for each:

kraken.assets(completion: { let _ = ${ print($0) } })

Asset Pairs

kraken.assetsPairs(completion: { let _ = ${ print($0) } })

Ticker Information

  kraken.ticker(pairs: ["BCHEUR", "BCHUSD"], completion: { let _ = ${ print($0) }  })

Order Book

Get market depth information for given asset pairs

depth_data = kraken.order_book('LTCXRP', completion: { ... })


Get recent trades

trades = kraken.trades('LTCXRP', completion: { ... })


Get spread data for a given asset pair

spread = kraken.spread('LTCXRP', completion: { ... })

Private Data Methods


Get account balance for each asset
Note: Rates used for the floating valuation is the midpoint of the best bid and ask prices

kraken.balance(completion: { ... })

Trade Balance

Get account trade balance

kraken.tradeBalance(completion: { ... })

Open Orders

kraken.openOrders(completion: { ... })

Closed Orders

kraken.closedOrders(completion: { ... })

Query Orders

See all orders

kraken.queryOrders(completion: { ... })

Trades History

Get array of all trades

kraken.tradeHistory(completion: { ... })

Query Trades

Input: Array of transaction (tx) ids

kraken.queryTrades(txids:arrayIds completion: { ... })

Open Positions

Input: Array of transaction (tx) ids

kraken.openPositions(txids:arrayIds completion: { ... })

Ledgers Info

kraken.ledgersInfo(completion: { ... })

Ledgers Info

Input: Array of ledger ids

kraken.queryTrades(ids: ledgerIds completion: { ... })

Trade Volume

let assetPairs = ["XLTCXXDG", "ZEURXXDG"]
kraken.queryTrades(ids: assetPairs completion: { ... })

Adding and Cancelling Orders

Add Order

There are 4 required parameters for buying an order. The example below illustrates the most basic order. Please see the Kraken documentation for the parameters required for more advanced order types.

// buying 0.01 XBT (bitcoin) for XRP (ripple) at market price
let opts = [
  "pair": "XBTXRP",
  "type": "buy",
  "ordertype": "market",
  "volume": "0.01"

kraken.addOrder(options:opts completion: { ... })

Cancel Order

kraken.cancelOrder(ids:["UKIYSP-9VN27-AJWWYC"] completion: { ... })

Latest podspec

    "name": "KrakenCrypto",
    "version": "1.1.0",
    "summary": "Lightweight wrapper for trading cryptocurrencies using Kraken.",
    "homepage": "",
    "license": {
        "type": "MIT"
    "authors": "Jonas-Taha El Sesiy",
    "social_media_url": "",
    "platforms": {
        "ios": "10.3"
    "source": {
        "git": "",
        "tag": "1.1.0"
    "swift_version": "4.1",
    "source_files": "Sources/*.swift",
    "dependencies": {
        "CryptoSwift": [
            "~> 0.10.0"

Pin It on Pinterest

Share This