Skip to main content

Go SDK

Official Go client for the Huntrecht Platform API v1.

Installation​

go get github.com/huntrecht/sdk-go

Quick Start​

package main

import (
"context"
"fmt"
"log"

"github.com/huntrecht/sdk-go"
)

func main() {
client := huntrecht.NewClient(
huntrecht.WithClientID("hnt_your_client_id"),
huntrecht.WithClientSecret("your_secret"),
)

ctx := context.Background()

// List orders
var orders huntrecht.OrderListResponse
if err := client.Orders.List(ctx, &orders, nil); err != nil {
log.Fatal(err)
}
for _, order := range orders.Data {
fmt.Printf("Order %s: %s - %.2f\n", order.ID, order.Commodity, order.Quantity)
}

// Get credit score
var score huntrecht.CreditScoreResponse
if err := client.Credit.Score(ctx, &score, "customer@example.com"); err != nil {
log.Fatal(err)
}
fmt.Printf("Credit score: %d (%s)\n", score.Data.CreditScore, score.Data.RiskLevel)
}

Authentication​

// Using environment variables
client := huntrecht.NewClient()

// Using explicit credentials
client := huntrecht.NewClient(
huntrecht.WithClientID("hnt_abc"),
huntrecht.WithClientSecret("secret"),
)

// With custom base URL
client := huntrecht.NewClient(
huntrecht.WithBaseURL("https://api.huntrecht.com"),
huntrecht.WithClientID("hnt_abc"),
huntrecht.WithClientSecret("secret"),
)

Resource Modules​

Orders​

var orders huntrecht.OrderListResponse
err := client.Orders.List(ctx, &orders, &huntrecht.OrderListOptions{
Page: 1,
PerPage: 20,
Status: "pending",
})

var order huntrecht.OrderResponse
err = client.Orders.Get(ctx, &order, "ord_abc123")

Payments​

var payments huntrecht.PaymentListResponse
err := client.Payments.List(ctx, &payments, &huntrecht.PaymentListOptions{
Status: "completed",
})

Subscriptions​

var subs huntrecht.SubscriptionListResponse
err := client.Subscriptions.List(ctx, &subs, &huntrecht.SubscriptionListOptions{
Status: "active",
})

Credit​

var score huntrecht.CreditScoreResponse
err := client.Credit.Score(ctx, &score, "customer@example.com")

var assessment huntrecht.CreditAssessmentResponse
err = client.Credit.Assess(ctx, &assessment, huntrecht.CreditAssessmentRequest{
CustomerEmail: "customer@example.com",
IncludeRecommendations: true,
})

KYC​

var kycs huntrecht.KycListResponse
err := client.KYC.List(ctx, &kycs, &huntrecht.KycListOptions{
Status: "pending",
})

Quotes​

var quotes huntrecht.QuoteListResponse
err := client.Quotes.List(ctx, &quotes, nil)

Users​

var user huntrecht.UserResponse
err := client.Users.Me(ctx, &user)

Storefront​

var collections huntrecht.CollectionsResponse
err := client.Storefront.Collections(ctx, &collections, &huntrecht.CollectionsOptions{
IncludeProducts: true,
})

Price Drops (Public)​

var drops huntrecht.PriceDropListResponse
err := client.PriceDrops.List(ctx, &drops, &huntrecht.PriceDropOptions{
Limit: 10,
})

Error Handling​

if err != nil {
if apiErr, ok := err.(*huntrecht.APIError); ok {
fmt.Printf("API error: %s (status=%d)\n", apiErr.Message, apiErr.StatusCode)
} else {
fmt.Printf("Error: %v\n", err)
}
}

Environment Variables​

VariableDescription
HUNTRECHT_BASE_URLAPI base URL (default: https://api.huntrecht.com)
HUNTRECHT_CLIENT_IDOAuth2 client ID
HUNTRECHT_CLIENT_SECRETOAuth2 client secret