An API wrapper for bitFlyer.

Overview

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.

You might also like...
Unified API Library for: Cloud Storage, Social Log-In, Social Interaction, Payment, Email, SMS, POIs, Video & Messaging.
Unified API Library for: Cloud Storage, Social Log-In, Social Interaction, Payment, Email, SMS, POIs, Video & Messaging.

Unified API Library for: Cloud Storage, Social Log-In, Social Interaction, Payment, Email, SMS, POIs, Video & Messaging. Included services are Dropbox, Google Drive, OneDrive, OneDrive for Business, Box, Egnyte, PayPal, Stripe, Google Places, Foursquare, Yelp, YouTube, Vimeo, Twitch, Facebook Messenger, Telegram, Line, Viber, Facebook, GitHub, Google+, LinkedIn, Slack, Twitter, Windows Live, Yahoo, Mailjet, Sendgrid, Twilio, Nexmo, Twizo.

A swift SDK for Medium's OAuth2 API

Medium SDK - Swift A library to allow access to Medium API for any Swift iOS application. Features Medium.com authorization & token handling Login sta

An Elegant Spotify Web API Library Written in Swift for iOS and macOS
An Elegant Spotify Web API Library Written in Swift for iOS and macOS

Written in Swift 4.2 Spartan is a lightweight, elegant, and easy to use Spotify Web API wrapper library for iOS and macOS written in Swift 3. Under th

Easy and powerful way to interact with VK API for iOS and macOS
Easy and powerful way to interact with VK API for iOS and macOS

Easy and powerful way to interact with VK API for iOS and macOS. Key features 😊 It's not ios-vk-sdk 😊 🍏 One library for iOS and mac OS 🍏 🤘 Fully

Instagram API client written in Swift
Instagram API client written in Swift

SwiftInstagram is a wrapper for the Instagram API written in Swift. It allows you to authenticate users and request data from Instagram effortlessly.

A Slack API Client for the Perfect Server-Side Swift Framework

PerfectSlackAPIClient is an API Client to access the Slack API from your Perfect Server Side Swift application. It is build on top of PerfectAPIClient

A Swift library for the Forecast.io Dark Sky API
A Swift library for the Forecast.io Dark Sky API

Requirements To use ForecastIO, all you need is an API key for the Dark Sky API. ForecastIO supports iOS (≥9.0), macOS (≥10.10), watchOS (≥2.0), and t

A clima based app with use of API
A clima based app with use of API

Clima Our Goal It’s time to take our app development skills to the next level. We’re going to introduce you to the wonderful world of Application Prog

Questrade API written in Swift.

QuestradeAPI Getting Started The QuestAPI is made up of two main concepts: ResponseProviders API ResponseProviders The job of the provider is to retur

Comments
  • Delete real-time API using PubNub

    Delete real-time API using PubNub

    Bitflyer says

    We have been supporting multiple methods of real-time data transmission API to our customers at bitFlyer. However, we will be dropping support for real-time data transmission via PubNub.

    Expire on: Saturday, December 1, 2018 at 00:00 (JST)

    opened by rinov 0
  • Support swift package manager v4

    Support swift package manager v4

    First, I need to say this changes are still not perfect because daltoniam/zlib-spm and daltoniam/Starscream didn't support Swift PM v4 yet. So I fork these and add changes to support it. You can check my changes via following pages.

    • zlib-spm: https://github.com/daltoniam/zlib-spm/compare/master...c-bata:support-spm4?expand=1
    • common-crypto-spm: https://github.com/daltoniam/common-crypto-spm/compare/master...c-bata:support-spm4?expand=1
    • Starscream: https://github.com/daltoniam/Starscream/compare/master...c-bata:support-spm4?expand=1

    There is a problem when sending a Pull Request to Starscream because C header files are moved inside include directory to support Swift PM v4 cause of constraints to support C language targets (See https://github.com/apple/swift-package-manager/blob/master/Documentation/Usage.md#c-language-targets for more details). So maybe Starscream builds in XCode will be failed cause of changing directory of header files.

    enhancement 
    opened by c-bata 2
Releases(0.1.3)
  • 0.1.3(Mar 18, 2018)

    • Fix amount of order size issue due to bitflyer's order amount available degits.
    • Remove pln and keepRate from Swift Equatable. These are dynamic changed by order fetching and causes confusion.
    • Update PubNub framework to latest version.
    Source code(tar.gz)
    Source code(zip)
  • 0.1.2(Feb 4, 2018)

Owner
Ryo Ishikawa
Ryo Ishikawa
Unofficial Dribbble iOS wrapper allows you to integrate Dribble API into iOS application (Designer, Shot, Comment, User Story, Like, Follow)

DribbbleSDK DribbbleSDK is easy-to-use iOS wrapper for Dribbble SDK. We're working hard to complete the full coverage of available methods and make th

Agilie Team 74 Dec 2, 2020
A Swift wrapper for Foursquare API. iOS and OSX.

Das Quadrat Das Quadrat is Foursquare API wrapper written in Swift. Features Supports iOS and OSX. Covers all API endpoints. Authorization process imp

Constantine Fry 171 Jun 18, 2022
Swift Wrapper For Bittrex API

BittrexApiKit Swift client for Bittrex api. It support all APIs with most recent changes. more info here let api = Bittrex(apikey: "api key", secretke

Saeid 8 Apr 5, 2021
Pokeapi wrapper, written in Swift

PokemonKit What is this? PokemonKit is a swift wrapper for Pokeapi. PokemonKit use Alamofire and PromiseKit for async web requests handling. Usage imp

Continuous Learning 105 Nov 16, 2022
SwiftCloudDrive - An easy to use Swift wrapper around iCloud Drive.

SwiftCloudDrive Author: Drew McCormack (@drewmccormack) An easy to use Swift wrapper around iCloud Drive. SwiftCloudDrive handles complexities like fi

Drew McCormack 11 Dec 21, 2022
A stable, mature and comprehensive Objective-C library for Twitter REST API 1.1

STTwitter A stable, mature and comprehensive Objective-C library for Twitter REST API 1.1 Like a FOSS version of Twitter Fabric TwitterKit, without th

Nicolas Seriot 1k Nov 30, 2022
Twitter API for Cocoa developers

FHSTwitterEngine Twitter API for Cocoa developers Created by Nathaniel Symer FHSTwitterEngine can: Authenticate using OAuth and/or xAuth. Make a reque

Nathaniel Symer 213 Jul 8, 2022
Giphy API client for iOS in Objective-C

Giphy-iOS Giphy-iOS is a Giphy API client for iOS in Objective-C. Usage To run the example project, clone the repo, and run pod install from the Examp

alex choi 52 Jul 11, 2019
ObjectiveFlickr, a Flickr API framework for Objective-C

ObjectiveFlickr ObjectiveFlickr is a Flickr API framework designed for Mac and iPhone apps. OAuth Support ObjectiveFlickr now supports Flickr's new OA

Lukhnos Liu 714 Jan 9, 2023
Unofficial GitHub API client in Swift

Github.swift ❤️ Support my apps ❤️ Push Hero - pure Swift native macOS application to test push notifications PastePal - Pasteboard, note and shortcut

Khoa 184 Nov 25, 2022