GithubHelp home page GithubHelp logo

kimbin / cryptex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from trsathya/cryptex

0.0 2.0 0.0 216 KB

Gemini, GDAX, Bitfinex, Poloniex, Binance, Kraken, Cryptopia, Koinex, BitGrail and CoinMarketCap cryptocurrency exchange API clients in Swift / iOS SDK. Check prices and account balances using Sample iOS app.

License: MIT License

Ruby 1.35% Objective-C 0.22% Swift 98.38% C 0.06%

cryptex's Introduction

Cryptex - iOS SDK for crypto currencies in Swift 4

Swift 4.0 CocoaPods GitHub release Cocoapods Downloads Apps Github Commits Since last release badge-mit badge-platforms badge-pms

Cryptex, a single Swift 4 library and an iOS app to watch prices and check realtime account balances across multiple cryptocurrency exchanges. Trading features are coming soon.

Sample App UI

Requirements

  • iOS 9.0+ | macOS 10.10+ | tvOS 9.0+ | watchOS 2.0+
  • Xcode 8.3+

Integration

CocoaPods (iOS 9+, OS X 10.9+)

To install all exchanges

pod 'Cryptex', '~> 0.0.5'

To install only one exchange

pod 'Cryptex/Gemini', '~> 0.0.5'

To install two or more exchanges

pod 'Cryptex', '~> 0.0.4', :subspecs => ['Gemini', 'GDAX', "Poloniex"]

Carthage (iOS 8+, OS X 10.9+)

github "trsathya/Cryptex" ~> 0.0.5

Swift Package Manager

dependencies: [
    .Package(url: "https://github.com/trsathya/Cryptex.git", from: "0.0.5"),
]

Usage

Initialization

import Cryptex
Fetch coinmarketcap.com global data
let coinMarketCapService = CoinMarketCap.Service(key: nil, secret: nil, session: URLSession.shared, userPreference: .USD_BTC, currencyOverrides: nil)
coinMarketCapService.getGlobal { (_) in
    if let data = coinMarketCapService.store.globalMarketDataResponse.globalData {
        print(data)
    }
}
Console logs
GET https://api.coinmarketcap.com/v1/global
200 https://api.coinmarketcap.com/v1/global/
Response Data: {
    "total_market_cap_usd": 585234214361.0, 
    "total_24h_volume_usd": 22202189284.0, 
    "bitcoin_percentage_of_market_cap": 34.15, 
    "active_currencies": 896, 
    "active_assets": 567, 
    "active_markets": 8187, 
    "last_updated": 1517118863
}
Optional(Cryptex.CoinMarketCap.GlobalMarketData(marketCap: 585234214361, volume24Hrs: 22202189284, bitcoinDominance: 34.15, activeCurrencies: 896, activeAssets: 567, activeMarkets: 8187, lastUpdated: 1517118863))

Or

Fetch Gemini public ticker data
let geminiService = Gemini.Service(key: nil, secret: nil, session: URLSession.shared, userPreference: .USD_BTC, currencyOverrides: nil)
geminiService.getTickers { (_) in
    print(geminiService.store.tickerByName)
}
Console logs
GET https://api.gemini.com/v1/symbols
200 https://api.gemini.com/v1/symbols
GET https://api.gemini.com/v1/pubticker/BTCUSD
GET https://api.gemini.com/v1/pubticker/ETHBTC
GET https://api.gemini.com/v1/pubticker/ETHUSD
200 https://api.gemini.com/v1/pubticker/ETHBTC
200 https://api.gemini.com/v1/pubticker/ETHUSD
200 https://api.gemini.com/v1/pubticker/BTCUSD
[
BTCUSD : 11721 USD, 
ETHBTC : 0.0977 BTC, 
ETHUSD : 1148.99 USD]

Or

Fetch Gemini private account balance data
let geminiService = Gemini.Service(key: <Your gemini account api key>, secret: <Your gemini account api secret>, session: URLSession.shared, userPreference: .USD_BTC, currencyOverrides: nil)
geminiService.getBalances { (_) in
    for balance in self.gemini.store.balances {
        print("\(balance) \(self.gemini.store.balanceInPreferredCurrency(balance: balance).usdFormatted ?? "")")
    }
}
Console logs
GET https://api.gemini.com/v1/symbols
200 https://api.gemini.com/v1/symbols
GET https://api.gemini.com/v1/pubticker/BTCUSD
GET https://api.gemini.com/v1/pubticker/ETHBTC
GET https://api.gemini.com/v1/pubticker/ETHUSD
200 https://api.gemini.com/v1/pubticker/BTCUSD
200 https://api.gemini.com/v1/pubticker/ETHUSD
200 https://api.gemini.com/v1/pubticker/ETHBTC
POST https://api.gemini.com/v1/balances
200 https://api.gemini.com/v1/balances

BTC: 0.29182653 $3,420.49
USD: 26.96 $26.96
ETH: 0.00000017 $0.00

Note: While creating Binance service, pass a currency override array to resolve a currency code difference. This is because Binance chose to use the code BCC for BitcoinCash instead of BCH.

let currencyOverrides = ["BCC": Currency(name: "Bitcoin Cash", code: "BCC")]
let binanceService = Binance.Service(key: key, secret: secret, session: session, userPreference: .USDT_BTC, currencyOverrides: currencyOverrides)

cryptex's People

Contributors

trsathya avatar

Watchers

James Cloos avatar kimbin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.