https://github.com/trsathya/cryptex
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.
https://github.com/trsathya/cryptex
altcoin binance bitcoin bitgrail coinexchange coinmarketcap coinmarketcap-api crypto cryptocurrencies cryptocurrency ethereum gdax gemini ios koinex litecoin macos poloniex sdk swift
Last synced: 2 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/trsathya/cryptex
- Owner: trsathya
- License: mit
- Created: 2017-12-30T13:46:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-07-16T22:11:33.000Z (almost 5 years ago)
- Last Synced: 2026-02-14T16:40:14.025Z (3 months ago)
- Topics: altcoin, binance, bitcoin, bitgrail, coinexchange, coinmarketcap, coinmarketcap-api, crypto, cryptocurrencies, cryptocurrency, ethereum, gdax, gemini, ios, koinex, litecoin, macos, poloniex, sdk, swift
- Language: Swift
- Homepage:
- Size: 240 KB
- Stars: 65
- Watchers: 13
- Forks: 23
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cryptex - iOS SDK for crypto currencies in Swift 4
  [](https://github.com/trsathya/Cryptex/releases)  ![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.

## 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
```ruby
pod 'Cryptex', '~> 0.0.6'
```
To install only one exchange
```ruby
pod 'Cryptex/Gemini', '~> 0.0.6'
```
To install two or more exchanges
```ruby
pod 'Cryptex', '~> 0.0.6', :subspecs => ['Gemini', 'GDAX', "Poloniex"]
```
#### Carthage (iOS 8+, OS X 10.9+)
```
github "trsathya/Cryptex" ~> 0.0.6
```
#### Swift Package Manager
```swift
dependencies: [
.Package(url: "https://github.com/trsathya/Cryptex", from: "0.0.6"),
]
```
## Usage
#### Initialization
```swift
import Cryptex
```
##### Fetch coinmarketcap.com global data
```swift
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
```swift
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
```swift
let geminiService = Gemini.Service(key: , 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.
```swift
let currencyOverrides = ["BCC": Currency(name: "Bitcoin Cash", code: "BCC")]
let binanceService = Binance.Service(key: key, secret: secret, session: session, userPreference: .USDT_BTC, currencyOverrides: currencyOverrides)
```
[badge-pms]: https://img.shields.io/badge/supports-CocoaPods%20%7C%20Carthage%20%7C%20SwiftPM-green.svg
[badge-platforms]: https://img.shields.io/badge/platforms-macOS%20%7C%20iOS%20%7C%20watchOS%20%7C%20tvOS%20%7C%20Linux-lightgrey.svg
[badge-mit]: https://img.shields.io/badge/license-MIT-blue.svg