The tiktokshop package is a typed Go client for the TikTok Shop Partner API. It signs requests, handles OAuth, works with many shops at once, and verifies and types webhooks. It is published as a Go module on pkg.go.dev, and its source is in go/.
Install
Section titled “Install”go get github.com/isaackogan/TikTok-Shop-Api-SDKs/goRequires Go 1.22 or newer. The package name is tiktokshop. It has no dependencies beyond the standard library and the generated code’s validator.
First call
Section titled “First call”With an access token from the OAuth helper, create a client and call an operation. Each operation is a request builder: set the parameters, then call Execute.
import ( "context" "fmt"
tiktokshop "github.com/isaackogan/TikTok-Shop-Api-SDKs/go")
func listOrders(ctx context.Context) error { client := tiktokshop.New(tiktokshop.Options{ AppKey: "APP_KEY", AppSecret: "APP_SECRET", AccessToken: "ACCESS_TOKEN", ShopCipher: "SHOP_CIPHER", })
orders, _, err := client.Orders.GetOrderList(ctx).PageSize(20).Execute() if err != nil { return err } data := orders.GetData() fmt.Println(data.GetTotalCount(), "orders; request", orders.GetRequestId()) return nil}Every call is signed, timestamped and sent with your access token. The shop_cipher query parameter is added for you on the endpoints that need it.
In this section
Section titled “In this section”- Authorization:
NewAuth, authorization URLs, token exchange and refresh. - Calling the API: the client, API areas, many shops and options.
- Webhooks:
Webhooks.VerifyAndParseand typed events. - Errors:
*tiktokshop.Errorand its codes.