All Projects → rinov → SwiftFlyer

rinov / SwiftFlyer

Licence: MIT license
An API wrapper for bitFlyer.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to SwiftFlyer

bitflyer
⚡ bitFlyer API wrapper for Ruby
Stars: ✭ 25 (-35.9%)
Mutual labels:  api-wrapper, bitflyer
bitmex-backtest-python
bitmex-backtest is a python library for backtest with bitmex fx trade rest api on Python 3.7 and above.
Stars: ✭ 13 (-66.67%)
Mutual labels:  btc, fx
jokeapi
Official golang wrapper for Sv443's jokeapi.
Stars: ✭ 19 (-51.28%)
Mutual labels:  api-wrapper
DPP
C++ Discord API Bot Library - D++ is Lightweight and scalable for small and huge bots!
Stars: ✭ 560 (+1335.9%)
Mutual labels:  api-wrapper
scala-weather
High-performance Scala library for looking up the weather
Stars: ✭ 45 (+15.38%)
Mutual labels:  api-wrapper
go-ovh
Simple go wrapper for the OVH API
Stars: ✭ 107 (+174.36%)
Mutual labels:  api-wrapper
rust-ipfs-api
Rust language IPFS API implementation
Stars: ✭ 20 (-48.72%)
Mutual labels:  api-wrapper
tatsumaki.js
A api wrapper for the Tatsumaki Discord Bot API
Stars: ✭ 9 (-76.92%)
Mutual labels:  api-wrapper
node-fred
A Fred2 API wrapper
Stars: ✭ 16 (-58.97%)
Mutual labels:  api-wrapper
roux
Simple and (a)synchronous Reddit API wrapper for Rust.
Stars: ✭ 41 (+5.13%)
Mutual labels:  api-wrapper
the-traveler
The Traveler is a small npm package which wraps around the Destiny 2 API.
Stars: ✭ 52 (+33.33%)
Mutual labels:  api-wrapper
bch-devsuite
A quick and easy setup for Bitcoin Cash Node, SLP infrastructure and SmartBCH
Stars: ✭ 12 (-69.23%)
Mutual labels:  bitcoin-api
gtmetrix-net
GTmetrix .Net client
Stars: ✭ 16 (-58.97%)
Mutual labels:  api-wrapper
wp-pgp-encrypted-emails
🔐 📧 Encrypts WordPress emails using OpenPGP or S/MIME with a familiar API.
Stars: ✭ 35 (-10.26%)
Mutual labels:  api-wrapper
pybuildkite
A Python library for the Buildkite API
Stars: ✭ 29 (-25.64%)
Mutual labels:  api-wrapper
Customizable-Crypto-Currency-Dashboard-with-Chart
📺 A Dashboard with the price movements of the selected Cryptocurrencies 💹
Stars: ✭ 79 (+102.56%)
Mutual labels:  btc
acord
An API wrapper for discord, built using aiohttp and pydantic.
Stars: ✭ 25 (-35.9%)
Mutual labels:  api-wrapper
crypto-watcher
Real-time cryptocurrencies prices.
Stars: ✭ 25 (-35.9%)
Mutual labels:  btc
asyncpixel
An Asyncronous Python wrapper for the Hypixel API.
Stars: ✭ 22 (-43.59%)
Mutual labels:  api-wrapper
rdfp
This R package connects the DoubleClick for Publishers API from R
Stars: ✭ 16 (-58.97%)
Mutual labels:  api-wrapper

SwiftFlyer

An API wrapper for bitFlyer that supports all providing API.

Swift Platform Cocoapods Carthage License

API Document

https://lightning.bitflyer.jp/docs

Usage

Public API

Fetch a market list.

import SwiftFlyer

let request = GetMarketListRequest()

ApiSession.shared.send(request) { result in
    switch result {
    case .success(let markets):
      print(markets)
    case .failed(let e):
      // Error handling
      break
    }
}

Response:

[
  SwiftFlyer.Market(productCode: SwiftFlyer.ProductCode.btc_jpy, alias: nil),
  SwiftFlyer.Market(productCode: SwiftFlyer.ProductCode.fx_btc_jpy, alias: nil),
  SwiftFlyer.Market(productCode: SwiftFlyer.ProductCode.eth_btc, alias: nil),
  SwiftFlyer.Market(productCode: SwiftFlyer.ProductCode.bch_btc, alias: nil)
]

Private API

Generate API keys: https://lightning.bitflyer.jp/developer

Check your balance.

import SwiftFlyer
...

// For access private API.
BitFlyer.apiKey = // Your API Key
BitFlyer.apiSecretKey = // Your API Secret Key

let request = GetBalanceRequest()

ApiSession.shared.send(request) { result in
    switch result {
    case .success(let markets):
      print(markets)
    case .failed(let e):
      // Error handling
      break
    }
}

Response:

[
  SwiftFlyer.Balance(amount: 0.0, available: 0.0, currencyCode: SwiftFlyer.CurrencyCode.jpy),
  SwiftFlyer.Balance(amount: 0.0, available: 0.0, currencyCode: SwiftFlyer.CurrencyCode.btc),
  SwiftFlyer.Balance(amount: 0.0, available: 0.0, currencyCode: SwiftFlyer.CurrencyCode.bch),
  SwiftFlyer.Balance(amount: 0.0, available: 0., currencyCode: SwiftFlyer.CurrencyCode.eth),
  SwiftFlyer.Balance(amount: 0.0, available: 0.0, currencyCode: SwiftFlyer.CurrencyCode.etc),
  SwiftFlyer.Balance(amount: 0.0, available: 0.0, currencyCode: SwiftFlyer.CurrencyCode.ltc),
  SwiftFlyer.Balance(amount: 0.0, available: 0.0, currencyCode: SwiftFlyer.CurrencyCode.mona)
]

RealTime API (JSON RPC over WebSocket)

Use RealTImeAPI in your project.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    // If you want retrive realtime information, set channels and call `subscribe` of RealTimeAPI.
    typealias Channel = RealTimeAPI.SubscribeChannel

    // Set channels for subscribing realtime api from bitFlyer RealTimeAPI by using JSON RPC over WebSocket.
    let subscribeChannels: [String] = [
    Channel.SnapShot.boardSnap_fx_btc_jpy.targetChannel,
    Channel.Board.board_fx_btc_jpy.targetChannel,
    Channel.Ticker.ticker_fx_btc_jpy.targetChannel,
    Channel.Execution.execution_fx_btc_jpy.targetChannel
    ]

    // Start observing realtime API.
    RealTimeAPI.shared.subscribe(with: subscribeChannels)

    ...
}

After subscribe realtime API, you should implement RealTimeAPIDelegate into your class.

class ViewController: UIViewController {    

    private let realtime: RealTimeAPI = .shared

    override func viewDidLoad() {
        super.viewDidLoad()

        // Set realtime API delegate for get your setted object.
        realtime.delegate = self
    }
}

extension UIViewController: RealTimeAPIDelegate {
    public func didReceiveSnapShot(_ snapshot: Board) {
        print(snapshot)
    }
    
    public func didReceiveBoardDiff(_ board: Board) {
        print(board)
    }
    
    public func didReceiveTicker(_ ticker: Ticker) {
        print(ticker)
    }
    
    public func didReceiveExecution(_ executions: [Execution]) {
        print(executions)
    }
}

Requirements

XCode 9+

Swift 4+

Installation

$ pod repo update

And add this to your Podfile:

pod 'SwiftFlyer'

and

$ pod install

Carthage

Add this to your Cartfile:

github "rinov/SwiftFlyer"

and

$ carthage update

TODO

  • Add timeout to each requests and common settings.
  • Provide HMAC 256 algorithm instead of CryptoSwift.
  • Detect exceeding of API call.

Disclaimer

USE THE SOFTWARE AT YOUR OWN RISK.

THE AUTHORS NO RESPONSIBILITY FOR YOUR TRADING RESULTS.

Author

Ryo Ishikawa, [email protected]

License

SwiftFlyer is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].