Skip to content

Latest commit

 

History

History
153 lines (113 loc) · 6.84 KB

README.md

File metadata and controls

153 lines (113 loc) · 6.84 KB

coincheck public & private API client

All Contributors

Go Reference Coverage MultiPlatformUnitTest reviewdog gitleaks

Important

This library is under development and is not yet ready for production use.

The coincheck package is a client for the API provided by Coincheck, Inc., which operates the cryptocurrency exchange (Coincheck). The coincheck package offers two types of APIs:

  • Public API: Can be executed without authentication
  • Private API: Requires authentication using the API Key and API Secret issued by the Coincheck service.

The coincheck package supports both Public and Private APIs.

Supported OS and go version

  • OS: Linux, macOS, Windows
  • Go: 1.20 or later

Example

An example of executing the Public API is shown below.

package main

import (
	"context"
	"fmt"

	"github.com/nao1215/coincheck"
)

func main() {
	client, err := coincheck.NewClient()
	if err != nil {
		panic(err)
	}

	// Get the latest ticker
	ticker, err := client.GetTicker(context.Background(), coincheck.GetTickerInput{
		Pair: coincheck.PairETCJPY,
	})
	if err != nil {
		panic(err)
	}

	fmt.Printf("Last: %d\n", ticker.Last)
	fmt.Printf("Bid: %d\n", ticker.Bid)
	fmt.Printf("Ask: %d\n", ticker.Ask)
	fmt.Printf("High: %d\n", ticker.High)
	fmt.Printf("Low: %d\n", ticker.Low)
	fmt.Printf("Volume: %s\n", ticker.Volume)
	fmt.Printf("Timestamp: %d\n", ticker.Timestamp)

    // Output:
    // Last: 4000.000000
    // Bid: 3980.020000
    // Ask: 4000.000000
    // High: 4220.000000
    // Low: 4000.000000
    // Volume: 339.150000
    // Timestamp: 1722661800.000000
}

If you want to execute the Private API, you need to create a client with the API Key and API Secret issued by the Coincheck service.

	client, err := coincheck.NewClient(WithCredentials("API_KEY", "API_SECRET"))

API List

Public API

API Method Name Description
GET /api/ticker GetTicker() Check latest ticker information.
GET /api/trades GetTrades() You can get current order transactions.
GET /api/order_books GetOrderBooks() Fetch order book information.
GET /api/exchange/orders/rate GetExchangeOrdersRate() To calculate the rate from the order of the exchange.
GET /api/rate/[pair] GetRate() Get the Standard Rate of Coin.
GET /api/exchange_status GetExchangeStatus() Retrieving the status of the exchange.

Private API

API Method Name Description
GET /api/bank_accounts GetBankAccounts() Display list of bank account you registered (withdrawal).
GET /api/accounts/balance GetAccountsBalance() Get the balance of your account.

License

MIT License

Contribution

First off, thanks for taking the time to contribute! See CONTRIBUTING.md for more information. Contributions are not only related to development. For example, GitHub Star motivates me to develop! Please feel free to contribute to this project.

Star History

Star History Chart

Contributors ✨

Thanks goes to these wonderful people (emoji key):

CHIKAMATSU Naohiro
CHIKAMATSU Naohiro

💻
Add your contributions

This project follows the all-contributors specification. Contributions of any kind welcome!

Reasons for Creating the coincheck package

I wanted to create a Bot that is reason why. Another reason is that I started creating it without much thought. Foolish. Now, I would rather have a bitFlyer Bot.

I received a bonus and bought cryptocurrency out of curiosity (I bought it secretly from my spouse and have already lost 10,000 yen). I became interested in the mechanism of cryptocurrency itself, as well as in how to trade cryptocurrency automatically using a Bot.

The cryptocurrency exchanges I use are Coincheck and bitFlyer, with the former being the one where I hold the most coins. Given this situation, it was natural for me to consider creating a Bot for Coincheck.

However, the official Coincheck API client (Golang) was quite simplistic. I had no choice but to create my own. At this point, I realized my mistake. There was a lot of information that could not be gleaned from the official documentation.