Skip to content

DataCrunch-io/datacrunch-sdk-go

Repository files navigation

DataCrunch SDK for Go

Go Version Go Reference

The official Go SDK for the DataCrunch API. Get up and running with DataCrunch compute instances, storage, and networking in minutes.

Installation

go get github.com/datacrunch-io/datacrunch-sdk-go

Quick Start

1. Set your credentials

export DATACRUNCH_BASE_URL="https://api.datacrunch.io/v1" # Optional for production client
export DATACRUNCH_CLIENT_ID="your-client-id"
export DATACRUNCH_CLIENT_SECRET="your-client-secret"

💡 Get your credentials from: https://datacrunch.io/account/api

2. Basic usage

See examples/basic/ for complete working examples.

Authentication

The SDK uses an AWS-style credential chain with flexible configuration:

  1. Environment variables (highest priority)

    • DATACRUNCH_CLIENT_ID + DATACRUNCH_CLIENT_SECRET
    • DATACRUNCH_BASE_URL (optional for production client)
      • production(default): https://api.datacrunch.io/v1
      • staging: https://api-staging.datacrunch.io/v1
      • testing: https://api-testing.datacrunch.io/v1
  2. Shared credentials file

    • Location: ~/.datacrunch/credentials
    • Multiple profiles (default, staging, production, etc.)
    • INI format with profile sections
    [default]
    client_id = your-default-client-id
    client_secret = your-default-client-secret
    base_url = https://api.datacrunch.io/v1
    
    [staging]
    client_id = your-staging-client-id
    client_secret = your-staging-client-secret
    base_url = https://api-staging.datacrunch.io/v1
  3. Static credentials

    • Programmatically configured
    • Useful for testing and development
  4. Custom credential providers

    • Environment-only, credentials-file-only, or custom chains
    • Full control over credential resolution order

Available Services

Service Description
Instance Manage compute instances
InstanceTypes Query available hardware
Volumes Persistent storage
SSHKeys SSH key management
StartScripts Startup automation
Locations Datacenter regions

Examples

Comprehensive examples are available in the examples/ directory:

  • basic/ - Session-based service usage
  • advanced/ - Custom credential providers and configuration

Run examples

# Set credentials
export DATACRUNCH_BASE_URL="https://api.datacrunch.io/v1" # Optional for production client
export DATACRUNCH_CLIENT_ID="your-client-id"
export DATACRUNCH_CLIENT_SECRET="your-client-secret"

# Run examples
cd examples/basic && go run main.go

# Set up your credential files
cd examples/advanced && go run main.go

Usage Patterns

The SDK uses a session-based approach:

  • Create a session that manages credentials and configuration
  • Instantiate only the services you need
  • Memory efficient with fine-grained control
  • Supports all credential provider types

Configuration Options

  • Debug logging: Enable with session.WithDebug(true)
  • Custom base URLs: For different environments
  • Flexible credential providers: Environment, shared files, static, or custom chains
  • Profile support: Multiple credential profiles in shared files

See examples/ for detailed implementation patterns.

Getting Help

License

MIT License - see LICENSE file for details.


🚀 Ready to get started? Set your environment variables and create your first instance in under 5 minutes!

About

DataCrunch SDK golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •