The official Go SDK for the ThreadSync API. Sync data between any source and destination with a few lines of code.
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-goRequires Go 1.21 or later.
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)
}Set your API token via environment variable (recommended):
export THREADSYNC_API_TOKEN=ts_live_xxxxxxxxxxxxOr pass it directly to New():
client:=threadsync.New("ts_live_xxxxxxxxxxxx")client:= threadsync.New(tokenstring) *ClientCreates a new ThreadSync client. If token is an empty string, the value of the THREADSYNC_API_TOKEN environment variable is used.
conn, err:=client.Connections.Create(providerstring, optionsmap[string]interface{}) (*Connection, error)| Parameter | Type | Description |
|---|---|---|
provider | string | Provider name (e.g. "salesforce", "postgres", "hubspot") |
options | map[string]interface{} | Additional provider-specific options (e.g. "name") |
Returns a *Connection:
typeConnectionstruct {
IDstring// Unique connection IDProviderstring// Provider nameNamestring// Display nameStatusstring// "active", "pending", "error"
}conn, err:=client.Connections.Get(idstring) (*Connection, error)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
}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)
}| Constant | Value |
|---|---|
DefaultBaseURL | https://api.threadsync.io/v1 |
Version | 0.1.0 |
MIT — see LICENSE.