Giter VIP home page Giter VIP logo

gobcy's Introduction

gobcy

A Go wrapper for the BlockCypher API. Targeting support for Bitcoin (main and testnet3) and BlockCypher's internal testnet, but others (Litecoin, Dogecoin) should work too.

Configuration

Import the package like so:

import "github.com/blockcypher/gobcy"

Then initiate an API struct with your credentials:

//explicitly
bc := gobcy.API
bc.Token = "your-api-token-here"
bc.Coin = "btc" //options: "btc","bcy","ltc","doge"
bc.Chain = "main" //depending on coin: "main","test3","test"

//using a struct literal
bc := gobcy.API{"your-api-token-here","btc","main"}

//query away
fmt.Println(bc.GetChain())
fmt.Println(bc.GetBlock(300000,"",nil))

Usage

Check the "types.go" file for information on the return types. Almost all API calls are supported, with a few dropped to reduce complexity. If an API call supports URL parameters, it will likely appear as a params map[string]string variable in the API method. You can check the docs for supported URL flags.

Speaking of API docs, you can check out BlockCypher's documentation here. We've also heavily commented the code following Golang convention, so you might also find the GoDoc quite useful. The gobcy_test.go file also shows most of the API calls in action.

A Warning for 32-Bit Systems

We assume you use are using a 64-bit architecture for deployment, which automatically makes int types 64-bit, the default behavior since Go 1.1. Without 64-bit ints, some values might overflow on certain calls, depending on the blockchain you are querying. If you are using a 32-bit system, you can change all int types to int64 to explicitly work around this issue.

Testing

The aforementioned gobcy_test.go file contains a number of tests to ensure the wrapper is functioning properly. If you run it yourself, you'll have to insert a valid API token; you may also want to generate a new token, as the test POSTs and DELETEs WebHooks and Payment Forwarding requests.

gobcy's People

Contributors

acityinohio avatar

Watchers

James Cloos avatar

Forkers

terminusdeus

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.