mining

package module
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 2 Imported by: 0

README

Binance Go Mining SDK

Build Status Open Issues Known Vulnerabilities

This is a client library for the Binance Mining API, enabling developers to interact programmatically with Binance's Mining trading platform. The library provides tools to mine through the REST API:

Table of Contents

Supported Features

  • REST API Endpoints:
    • /sapi/v1/mining/*
  • Inclusion of test cases and examples for quick onboarding.

Installation

To use this library, ensure you have Go installed (version 1.25 or higher is recommended). You can install the library using the following command:

go get github.com/binance/binance-connector-go/clients/mining

Documentation

For detailed information, refer to the Binance API Documentation.

REST APIs

All REST API endpoints are available through the restapi module. Note that some endpoints require authentication using your Binance API credentials.

package main

import (
	"context"
	"encoding/json"
	"log"

	client "github.com/binance/binance-connector-go/clients/mining"
	"github.com/binance/binance-connector-go/common/v2/common"
)

func main() {
	AcquiringAlgorithm()
}

func AcquiringAlgorithm() {
	configuration := common.NewConfigurationRestAPI(
		common.WithBasePath(common.MiningRestApiProdUrl),
		common.WithApiKey("Your API Key"),
	)
	apiClient := client.NewBinanceMiningClient(
		client.WithRestAPI(configuration),
	)
	resp, err := apiClient.RestApi.MiningAPI.AcquiringAlgorithm(context.Background()).Execute()
	if err != nil {
		log.Println(err)
		return
	}

	rateLimitsValue, _ := json.MarshalIndent(resp.RateLimits, "", "  ")
	log.Printf("Rate limits: %s\n", string(rateLimitsValue))

	dataValue, _ := json.MarshalIndent(resp.Data, "", "  ")
	log.Printf("Response: %s\n", string(dataValue))
}

More examples can be found in the examples/restapi folder.

Configuration Options

The REST API supports the following advanced configuration options:

  • Timeout: Timeout for requests in milliseconds (default: 1000 ms).
  • Proxy: Proxy configuration:
    • Host: Proxy server hostname.
    • Port: Proxy server port.
    • Protocol: Proxy protocol (http or https).
    • Auth: Proxy authentication credentials:
      • Username: Proxy username.
      • Password: Proxy password.
  • KeepAlive: Enable HTTP keep-alive (default: true).
  • Compression: Enable response compression (default: true).
  • Retries: Number of retry attempts for failed requests (default: 3).
  • Backoff: Delay in milliseconds between retries (default: 1000 ms).
  • HTTPSAgent: Custom HTTPS agent for advanced TLS configuration.
  • PrivateKey: RSA or ED25519 private key for authentication.
  • PrivateKeyPassphrase: Passphrase for the private key, if encrypted.
Timeout

You can configure a timeout for requests in milliseconds. If the request exceeds the specified timeout, it will be aborted. See the Timeout example for detailed usage.

Proxy

The REST API supports HTTP/HTTPS proxy configurations. See the Proxy example for detailed usage.

Keep-Alive

Enable HTTP keep-alive for persistent connections. See the Keep-Alive example for detailed usage.

Compression

Enable or disable response compression. See the Compression example for detailed usage.

Retries

Configure the number of retry attempts and delay in milliseconds between retries for failed requests. See the Retries example for detailed usage.

HTTPS Agent

Customize the HTTPS agent for advanced TLS configurations. See the HTTPS Agent example for detailed usage.

Key Pair Based Authentication

The REST API supports key pair-based authentication for secure communication. You can use RSA or ED25519 keys for signing requests. See the Key Pair Based Authentication example for detailed usage.

Certificate Pinning

To enhance security, you can use certificate pinning with the HTTPSAgent option in the configuration. This ensures the client only communicates with servers using specific certificates. See the Certificate Pinning example for detailed usage.

Error Handling

The REST API provides detailed error types to help you handle issues effectively:

  • ConnectorClientError: General client error.
  • RequiredError: Thrown when a required parameter is missing.
  • UnauthorizedError: Indicates missing or invalid authentication credentials.
  • ForbiddenError: Access to the requested resource is forbidden.
  • TooManyRequestsError: Rate limit exceeded.
  • RateLimitBanError: IP address banned for exceeding rate limits.
  • ServerError: Internal server error.
  • NetworkError: Issues with network connectivity.
  • NotFoundError: Resource not found.
  • BadRequestError: Invalid request.

See the Error Handling example for detailed usage.

Testing

To run the test cases, use the following command:

go test ./tests/...

The tests cover:

  • REST API endpoints
  • Error handling and edge cases

Migration Guide

For information on migrating from previous versions of the Binance Go Mining SDK, please refer to the Migration Guide.

Contributing

Contributions are welcome!

Since this repository contains auto-generated code, we encourage you to start by opening a GitHub issue to discuss your ideas or suggest improvements. This helps ensure that changes align with the project's goals and auto-generation processes.

To contribute:

  1. Open a GitHub issue describing your suggestion or the bug you've identified.
  2. If it's determined that changes are necessary, the maintainers will merge the changes into the main branch.

Please ensure that all tests pass if you're making a direct contribution. Submit a pull request only after discussing and confirming the change.

Thank you for your contributions!

Disclaimer

This SDK is provided by Binance on an "as is" and "as available" basis for use at your own risk. Binance makes no representations or warranties of any kind, whether express or implied, as to the operation of the SDK, its accuracy, reliability, completeness, or fitness for any particular purpose.

To the fullest extent permitted by law, Binance shall not be liable for any losses, damages, or expenses of any kind arising from or in connection with your use of, or inability to use, this SDK, including but not limited to any financial losses resulting from errors, bugs, interruptions, or inaccuracies in the SDK.

Your use of this SDK to access the Binance Platform is subject to the Binance API Key Terms and the Binance Terms of Use, which shall prevail in the event of any conflict with this disclaimer. You are solely responsible for any orders or transactions executed through the Binance Platform using this SDK.

This SDK is not intended to constitute investment advice or a recommendation to buy, sell, or hold any digital asset. You should independently evaluate and verify all information before acting.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinanceMiningClient

type BinanceMiningClient struct {
	RestApi *BinanceMiningRestApi.RestAPIClient
}

func NewBinanceMiningClient

func NewBinanceMiningClient(opts ...Option) *BinanceMiningClient

type Option

type Option func(*BinanceMiningClient)

func WithRestAPI

func WithRestAPI(cfg *common.ConfigurationRestAPI) Option

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL