Giter Site home page Giter Site logo

cryptowatcher's Introduction

Cryptowatcher

An API client for Cryptowatch written in swift.

Cryptowatcher uses the Codable protocol introduced in Swift 4 to decode JSON data from the Cryptowatch API. All network calls are made wtih URLSession and provide a promise-based interface through then.

Compatibility

This project requires Swift 4/Xcode 9.

Example

Each of the get functions for Cryptowatcher will return a Promise for a corresponding struct representing the response. In the example below, getMarketPrice returns Promise<GetMarketPrice>.

Cryptowatcher().getMarketPrice(exchange: "gdax", pair: "btcusd").then { response in
  let price = response.result.price
  let remainingAllowance = response.allowance.remaining
  // Use the values to do something fun
}.onError { error in
  // Handle the error
}

Carthage

This project currently uses Carthage to manage it's dependency on then.

Testing

Decoding is fully tested through fixtures generated using a simple script located at bin/load_fixtures.sh. These fixtures are committed but may be refreshed to test against newer data.

To generate new fixtures:

  1. Make the script executable (only once): chmod u+x ./bin/load_fixtures.sh
  2. Run the script ./bin/load_fixtures.sh

Documentation

Code is fully documented and provides helpful hints such as an example URL, notes about API constraints and expected data formats. Documentation for the Cryptowatch API can be found at https://cryptowat.ch/docs/api.

Future

This is a very early version providing basic fetch functionality. The following are considerations for future versions:

  • Pick a mocking approach and implement tests for all of the network calls.
  • Remove then in favor of a baked-in promise solution or adopt a less attractive interface.
  • Facilitate polling with respect paid to the CPU allowance.
  • Add CocoaPods support

cryptowatcher's People

Contributors

benbinary avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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.