This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is the binance-go SDK - a comprehensive Go client for Binance cryptocurrency exchange APIs. The codebase is auto-generated from OpenAPI and AsyncAPI specifications using the OpenXAPI project.
The codebase is organized into two main modules:
- Module:
github.com/openxapi/binance-go/rest - Generator: OpenAPI Generator
- Products:
spot/,umfutures/,cmfutures/,options/,pmargin/
- Module:
github.com/openxapi/binance-go/ws - Generator: OpenXAPI AsyncAPI generator
- Products:
spot/,umfutures/,cmfutures/(APIs) +spot-streams/,umfutures-streams/,cmfutures-streams/(Streams)
# Build REST APIs
cd rest/spot && go build ./...
cd rest/umfutures && go build ./...
cd rest/cmfutures && go build ./...
# Build WebSocket APIs
cd ws/spot && go build ./...
cd ws/spot-streams && go build ./...
cd ws/umfutures && go build ./...Auto-Generated Unit Tests (all skipped by default):
cd rest/spot && go test ./...
cd ws/spot && go test ./...Integration Tests (comprehensive, requires API keys):
# Set up environment variables
export BINANCE_API_KEY="your_api_key"
export BINANCE_SECRET_KEY="your_secret_key"
# Test REST APIs
cd ../integration-tests/src/binance/go/rest/spot
go test -v
# Test WebSocket APIs
cd ../integration-tests/src/binance/go/ws/spot
go test -vGenerated clients follow standard OpenAPI patterns:
- Configuration:
configuration.go- Client setup - Client:
client.go- HTTP client wrapper - APIs:
api_*.go- Endpoint implementations - Models:
model_*.go- Request/response structs - Auth:
signing.go- Authentication utilities
Usage Pattern:
config := spot.NewConfiguration()
client := spot.NewAPIClient(config)
// Authentication
auth := spot.NewAuth(apiKey)
auth.SetSecretKey(secretKey)
ctx, err := auth.ContextWithValue(ctx)
// API calls
result, httpRes, err := client.SpotTradingAPI.GetAccountV3(ctx).Execute()Event-driven architecture with handlers:
- Client:
client.go- WebSocket client - Models:
models/- Event structures - Auth:
signing.go- Authentication
Usage Pattern:
client := spotws.NewClient()
// Authentication
auth := &spotws.Auth{APIKey: apiKey}
auth.SetSecretKey(secretKey)
client.SetAuth(auth)
// Register handlers
client.HandleExecutionReport(func(event *models.ExecutionReport) error {
return nil
})
// Connect
err := client.Connect(ctx)Supports three authentication methods:
- HMAC-SHA256: API key + secret (most common)
- RSA: Private key file
- Ed25519: Ed25519 private key
Authentication is context-based for REST APIs and client-based for WebSocket APIs.
github.com/stretchr/testify v1.10.0
gopkg.in/validator.v2 v2.0.1
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.3
- Update specifications in OpenXAPI
- Regenerate code using OpenXAPI tools
- Replace generated files in this repository
- Use integration tests at
../integration-tests/src/binance/go/ - Set up Binance API credentials
- Run comprehensive test suites for each product
- Add AsyncAPI/OpenAPI specs to OpenXAPI project
- Configure code generation templates
- Generate new product modules
- Update documentation
- No custom build system (uses standard Go tooling)
- Generated unit tests are skipped placeholders
- Cannot modify generated files directly
- Must work through OpenXAPI project for changes
Focus on integration tests rather than unit tests:
- Unit tests are auto-generated placeholders (all skipped)
- Integration tests provide comprehensive real-world testing
- Located in separate integration-tests directory
- Require actual Binance API credentials for testing