Git Product home page Git Product logo

coincapv2's Introduction

coincapV2 api golang

coincapV2

GoDoc Go Report Card

client library for interacting with the coincap.io V2 api

Installation

go get -u github.com/solipsis/coincapV2/...

Usage

import "github.com/solipsis/coincapV2/pkg/coincap"

GoDoc: https://godoc.org/github.com/solipsis/coincapV2/pkg/coincap

Official API Docs

https://docs.coincap.io/

Examples

Get Market Data

client := coincap.NewClient(nil)

params := &MarketsRequest{
	ExchangeID:  "binance",
	BaseSymbol:  "ETH",
	QuoteSymbol: "BTC",
	Limit:       100,
	Offset:      0,
}
markets, timestamp, err := client.Markets(params)

Get Data for an Asset

client := coincap.NewClient(nil)

params := &AssetsRequest{
	Search: "BTC",
	Limit:  4,
	Offset: 1,
}
assets, timestamp, err := client.Assets(params)

Get Historical Data for an Asset

client := coincap.NewClient(nil)

// setup the time range
end := time.Now()
start := now.Add(-time.Hour * 2)

params := &coincap.AssetHistoryRequest{
	Interval: coincap.FifteenMinutes,
	Start:    &coincap.Timestamp{Time: start},
	End:      &coincap.Timestamp{Time: end},
}
history, timestamp, err := client.AssetHistoryByID("bitcoin", params)
if err != nil {
	log.Fatal(err)
}

Get Rates of Various Currencies to USD

client := coincap.NewClient(nil)

rates, timestamp, err := client.Rates()
if err != nil {
	t.Fatal(err)
}

/*
Example response
{
  "data": [
    {
      "id": "barbadian-dollar",
      "symbol": "BBD",
      "currencySymbol": "$",
      "type": "fiat",
      "rateUsd": "0.5000000000000000"
    },
    {
      "id": "malawian-kwacha",
      "symbol": "MWK",
      "currencySymbol": "MK",
      "type": "fiat",
      "rateUsd": "0.0013750106599420"
    },
    {
      "id": "south-african-rand",
      "symbol": "ZAR",
      "currencySymbol": "R",
      "type": "fiat",
      "rateUsd": "0.0657544075508153"
    }],
}

Get USD Rates by Asset ID

client := coincap.NewClient(nil)

rate, timestamp, err := client.RateByID("bitcoin")

Get Information on Exchanges

client := coincap.NewClient(nil)

exchanges, timestamp, err := client.Exchanges()
if err != nil {
	t.Fatal(err)
}

Get Exchange Information by ID

client := coincap.NewClient(nil)

exchange, timestamp, err := client.ExchangeByID("gdax")
if err != nil {
	t.Fatal(err)
}

Get Candle Data

client := coincap.NewClient(nil)

params := &CandlesRequest{
	ExchangeID: "poloniex",
	BaseID:     "ethereum",
	QuoteID:    "bitcoin",
	Limit:      100,
	Offset:     1,
	Interval:   coincap.FiveMinutes,
}
candles, timestamp, err := client.Candles(params)
if err != nil {
	t.Fatal(err)
}

TODO

  • Implement websocket endpoints

Contributing

Contributions and pull requests welcome

coincapv2's People

Contributors

haukened avatar solipsis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

superly7

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.