Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

3 Commits

Repository files navigation

ThreadSync Go SDK

Go ReferenceGo VersionLicense: MIT

The official Go SDK for the ThreadSync API. Sync data between any source and destination with a few lines of code.

Installation

Preview: SDKs are in preview and installed from GitHub. Registry packages (npm, PyPI, etc.) will be available at GA.

go get github.com/threadsync-infrastructure/threadsync-go

Requires Go 1.21 or later.

Quick Start

package main
import (
"fmt""log"
threadsync "github.com/threadsync/threadsync-go"
)
funcmain() {
// Token is read from THREADSYNC_API_TOKEN env var if empty string is passedclient:=threadsync.New("your-api-token")
// Create a connectionconn, err:=client.Connections.Create("salesforce", map[string]interface{}{
"name": "Production Salesforce",
})
iferr!=nil {
log.Fatal(err)
}
fmt.Printf("Connection created: %s (status: %s)\n", conn.ID, conn.Status)
// Create a syncresult, err:=client.Sync.Create(&threadsync.SyncConfig{
Source: threadsync.Endpoint{
Connection: conn.ID,
Object: "Contact",
},
Destination: threadsync.Endpoint{
Connection: "dest-conn-id",
Table: "contacts",
},
Schedule: "0 * * * *", // hourly
})
iferr!=nil {
log.Fatal(err)
}
fmt.Printf("Sync %s started — status: %s\n", result.ID, result.Status)
}

Authentication

Set your API token via environment variable (recommended):

export THREADSYNC_API_TOKEN=ts_live_xxxxxxxxxxxx

Or pass it directly to New():

client:=threadsync.New("ts_live_xxxxxxxxxxxx")

API Reference

Client

client:= threadsync.New(tokenstring) *Client

Creates a new ThreadSync client. If token is an empty string, the value of the THREADSYNC_API_TOKEN environment variable is used.


Connections

Create a connection

conn, err:=client.Connections.Create(providerstring, optionsmap[string]interface{}) (*Connection, error)
ParameterTypeDescription
providerstringProvider name (e.g. "salesforce", "postgres", "hubspot")
optionsmap[string]interface{}Additional provider-specific options (e.g. "name")

Returns a *Connection:

typeConnectionstruct {
IDstring// Unique connection IDProviderstring// Provider nameNamestring// Display nameStatusstring// "active", "pending", "error"
}

Get a connection

conn, err:=client.Connections.Get(idstring) (*Connection, error)

Sync

Create a sync

result, err:=client.Sync.Create(config*SyncConfig) (*SyncResult, error)
typeSyncConfigstruct {
SourceEndpoint// Source connection and object/tableDestinationEndpoint// Destination connection and object/tableSchedulestring// Cron expression (e.g. "0 * * * *")
}
typeEndpointstruct {
Connectionstring// Connection IDObjectstring// Source object name (e.g. "Contact")Tablestring// Destination table name
}

Get a sync

result, err:=client.Sync.Get(idstring) (*SyncResult, error)

Returns a *SyncResult:

typeSyncResultstruct {
IDstring// Sync job IDStatusstring// "pending", "running", "completed", "failed"RecordsSyncedint// Number of records synced (when completed)
}

Constants

ConstantValue
DefaultBaseURLhttps://api.threadsync.io/v1
Version0.1.0

License

MIT — see LICENSE.

About

Official Go SDK for ThreadSync's LLM Gateway. Multi-provider governed AI access with policy controls, audit trails, and cost tracking.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages