GithubHelp home page GithubHelp logo

gorjan-mishevski / puzzle Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 94 KB

Golang light CryptoCompare library, api wrapper

License: MIT License

Go 100.00%
golang golang-library cryptocurrency cryptocompare-api cryptocompare

puzzle's Introduction

Puzzle_Crypto_Logo

               

PUZZLE

Golang CryptoCompare library

If you are searching for a nice wrapper library that used CryptoCompare API this is the one. ☝️

This library has a lot of struct's (or type asserted response instead of interface{}) that extend the response, thus ensuring nice clean access to the data and providing easy way to add more functionalities with methods on the structs.

Currently I deliberatly don't add any interfaces and methods becouse I want you to use whatever methods fits best.

Installation

go get github.com/gorjan-mishevski/puzzle

Usage

Example 1

Let's start simple. Get the current value from a given currency.
EX: I want to know what is the rate from US to ETH, BTC.

1 USD dollar 💵 -> ETH 💎
response := puzzle.BaseAgainsMultiPrice("USD", []string{"ETH", "BTC"})

1st Argument is the currency you take as base.
2nd Argument is a slice of currencies you want the rate.

Response:

response <*puzzle.Currency>
        base: "USD"
        rates: <map[string]float64>
                ["ETH"]: 0.001556
                ["BTC"]: 0.000002355

Example 2

Let's see how to get from multiple currencies to multiples rates.
response := puzzle.MultiPrice([]string{"USD", "EUR"}, []string{"ETH", "BTC"})

1st Argument wants a slice of currencies to be taken as base.
2nd Argument is a slice of currencies you want the rate.

Response:

response <map[string]map[string]float64>
        "USD": <map[string]float64>
                "ETH": 0.0000034
                "BTC": 0.0000000344
        "EUR": <map[string]float64>
                "ETH": 0.0000034
                "BTC": 0.0000000344

Example 3

We can check the rates for a given day.
response := puzzle.PriceHistoryByDay("USD", []string{"ETH", "BTC"}, 1452680400)

1st Argument is the base we want to converto from.
2nd Argument the currency we want to get it's rate.
3rd Argument is the timestamp. Note, it will get the price at the end of the day GMT based on the requested timestamp.

Response:

response <*puzzle.Currency>
        base: "USD"
        rates: <map[string]float64>
                ["ETH"]: 0.001556
                ["BTC"]: 0.000002355

Example 4

Now let's get more complicated. Let's say we want a complete trading information with dynamic to -> from currencies.
response := puzzle.MultiPriceTradingInfo([]string{"USD", "EUR"}, []string{"ETH", "BTC"})

Response:

response <puzzle.MultiPriceMarket>
        "RAW": <map[string]puzzle.MultiPriceFrom>
                "USD": <puzzle.MultiPriceFrom>
                        From: "USD"
                        To: <map[string]puzzle.MultiPriceTo>
                                "ETH": <puzzle.MultiPriceTo>
                                        Name: "ETH"
                                        Field: <map[string]interface{}>
                                                ... Here we have random field data.
                                                For now they are as interface but they can be
                                                mapped.
                                "BTC": <puzzle.MultiPriceTo>
                                        ...
                "EUR": <puzzle.MultiPriceFrom>
                        ...
                        
        "DYNAMIC": ...

puzzle's People

Contributors

gorjan-mishevski avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  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.