Go SDK
Use the TwexAPI Go SDK for tweet search, follower exports, and public reads in Go services and workers.
Use the Go SDK when you want context-aware calls, typed request structs, retries, and pagination helpers for TwexAPI REST workflows in Go services and background workers.
twexapi-dev/x-api-scraper-goGo SDK for TwexAPI public social data and approved account workflows. Independent third-party service.00| Go task | SDK call | Save |
|---|---|---|
| Search tweets | Search.Advanced |
NextCursor |
| Read profile | Users.GetAbout |
ScreenName |
| List followers | Users.Followers.List |
cursor |
Install
go get github.com/twexapi-dev/x-api-scraper-go@v0.1.0
Source: twexapi-dev/x-api-scraper-go
Authenticate
export X_API_SCRAPER_KEY="YOUR_API_KEY"
package main
import (
"context"
"os"
xapiscraper "github.com/twexapi-dev/x-api-scraper-go"
"github.com/twexapi-dev/x-api-scraper-go/models/components"
)
func main() {
client := xapiscraper.New(
xapiscraper.WithSecurity(os.Getenv("X_API_SCRAPER_KEY")),
)
ctx := context.Background()
req := components.AdvancedSearchCursorQuery{
SearchTerms: []string{"from:elonmusk"},
SortBy: "Latest",
NextCursor: "",
}
res, err := client.Search.Advanced(ctx, req)
if err != nil {
panic(err)
}
_ = res
}
Basic example
Look up a profile and paginate followers:
about, err := client.Users.GetAbout(ctx, "elonmusk")
if err != nil {
panic(err)
}
followers, err := client.Users.Followers.List(ctx, components.FollowersFollowingV3Query{
Username: "elonmusk",
})
if err != nil {
panic(err)
}
Workflow: search tweets
cursor := ""
for {
res, err := client.Search.Advanced(ctx, components.AdvancedSearchCursorQuery{
SearchTerms: []string{"from:elonmusk AI"},
SortBy: "Latest",
NextCursor: cursor,
})
if err != nil {
panic(err)
}
for _, tweet := range res.Tweets {
// process tweet rows
_ = tweet
}
if !res.HasNextPage || res.NextCursor == nil || *res.NextCursor == "" {
break
}
cursor = *res.NextCursor
}
Error handling
The SDK returns typed errors for HTTP failures. Check err from each call and inspect status codes before retrying 4xx responses.
Configure retries with WithRetryConfig on the client or per-operation options.
References
- SDKs overview
- Authentication
- Terraform provider (wraps this Go SDK)
- Advanced Twitter Search
- Source Repository