Go SDK
Use solver.Client to solve supported flows through the local HTTP API. The server sends target requests and holds the API key.
Simple mode
Start the local API and install the Go SDK. Set TARGET_URL to a supported target page and PROXY_URL to your proxy.
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/nullgate-club/nullgate-sdk-go/v2/solver"
)
func main() {
client, err := solver.New(solver.Options{})
if err != nil { log.Fatal(err) }
response, err := client.Solve(context.Background(), solver.Request{
Type: solver.Akamai, URL: os.Getenv("TARGET_URL"),
UserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",
Proxy: os.Getenv("PROXY_URL"), Session: "visit-1",
})
if err != nil { log.Fatal(err) }
fmt.Println(response.Cookies, response.Result.Accepted)
}Cookies retains cookie attributes. Result contains typed product fields. Use the same user agent and proxy for subsequent site requests. The named session pins those settings and transport. Pass refreshed Cookies to replace the origin's snapshot after external changes.
Other types are solver.ThreatMetrix, solver.PingOne and solver.AmazonACIC. PingOne returns data rather than a login or cookie. ACIC completes PoW, WAF, voucher and continuation through PASS. If the script cannot be discovered, supply its real URL in ScriptURL. Pass an already received page in HTML to avoid fetching it again. Unsupported cases return an error. One solve can incur multiple generation charges at the existing prices. The local server adds no separate charge.
Advanced: direct API and prepared requests
The following direct API uses a key in the Go process. It prepares requests for your own target client instead of running the local simple-mode flow.
Install and check your account
Go 1.24.1 or newer. Get an API key from @nullgate_app.
GOPROXY=direct go get github.com/nullgate-club/nullgate-sdk-go/v2@main
export NULLGATE_API_KEY=ng_your_keypackage main
import (
"context"
"fmt"
"log"
"time"
"github.com/nullgate-club/nullgate-sdk-go/v2"
"github.com/nullgate-club/nullgate-sdk-go/v2/api"
)
func main() {
client, err := nullgate.New("", api.Options{})
if err != nil {
log.Fatal(err)
}
defer client.Close()
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
account, err := client.Accounts.Get(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Balance: %s %s\n", account.Balance, account.Currency)
}An empty key reads NULLGATE_API_KEY. Get usage buckets with client.Accounts.Usage(ctx, accounts.UsageOptions{}). Amounts and prices are decimal strings, not float64. Account reads are free. See Keys and balance and Prices.
Choose an operation
| Product | Guide and runnable example |
|---|---|
| Akamai | Akamai · Sensor and pixel example |
| Amazon FWCIM | Amazon FWCIM · Form example |
| Amazon ACIC | ACIC · PoW/WAF example |
| ThreatMetrix | ThreatMetrix · Callback example |
| Images | Classifier · Image example |
For labels, call client.Classifier.Classify with classifier.ClassifyOptions. For queries, call client.Classifier.Match with classifier.MatchOptions. Match scores are independent.
Keep the visit together
- Create a browser identity with
browser.New(browser.Options{UserAgent: ua}). Reuse it for the visit. - Call
visit.Page(url, html, browser.PageOptions{})for each navigation, using its final URL and current HTML. - Create a product session with
client.Akamai.Session(visit)and reuse it for that visit. Browser and product sessions are separate. A product session rejects a page from another visit. - Discover URLs with
akamai.SensorURL(page),akamai.PixelURL(page), orakamai.SbsdURL(page). An empty result means none was found. Ambiguous discovery returns an error. - Pass cookies from the target client's jar. Call
session.Sensor(ctx, page, akamai.SensorOptions{...}),session.Pixel(ctx, page, akamai.PixelOptions{...}), orsession.Sbsd(ctx, page, akamai.SbsdOptions{...}). - Call
result.Wait(ctx), then send the request through your target client.
Use page.Inputs to summarize ordinary field values from a map. Use browser.PrepareInputs([]browser.Input{...}) for explicit summaries, including passwords. Never put raw password values in page HTML or actions.
For FWCIM, create and reuse client.Amazon.Session(visit) and call session.Fwcim(ctx, page, amazon.FwcimOptions{...}). Use amazon.PrepareInputs(page, []browser.Input{...}) while raw values are available. It returns amazon.Input values: browser summaries plus FWCIM-only metadata. It computes the source-compatible checksum and supplies email text for the canvas probe. Passwords keep only summaries. If you supply precomputed observations, nonempty submitted nonpassword fields need a checksum, and the email field also needs its text.
For ACIC, use acic.Discover, acic.ParseResult, and acic.DiscoverWaf from amazon/acic. Use their setup methods and send the resulting requests with your target client. Call client.Amazon.ACIC.Pow or client.Amazon.ACIC.Waf to generate solutions.
For ThreatMetrix, create and reuse client.ThreatMetrix.Session(visit), then call session.Start(ctx, page, threatmetrix.Options{...}) with a target fetch callback. Keep the startup context alive for the profile lifetime. WaitCollected waits for collection, Pagehide signals departure, and Close stops the profile.
Omitted and empty are different. A nil Inputs or Actions slice keeps automatic collection. A non-nil empty slice explicitly disables that collection.
Keep passing the downloaded script to session.Sensor. The SDK retains its digest after the server confirms retention. Later requests omit the script, and script_required triggers one retry with the original text.
The SDK gzips JSON bodies of at least 1,024 bytes. Classifier images remain raw multipart bytes. api.Options.HTTPClient configures API traffic only. The SDK copies it and disables its cookies and redirects. Keep target cookies and proxy settings in your own client. Go's net/http does not preserve wire header order or reproduce Chrome's TLS fingerprint.
Handle errors and cancellation
Every network operation accepts context.Context. Cancel it to stop a request or active profile. Close stops the client and its profiles.
Use errors.As for *api.Error fields: Code, Message, Status, RequestID. Error text includes Message, not Cause or credentials. errors.Is matches api.ErrClosed and underlying context cancellation or deadline errors.
Only explicit maintenance rejection and script recovery trigger bounded retries. ACIC generation never retries automatically. Report confirms HTTP delivery of a request ID, not target acceptance or a refund.
See Errors, Sessions, and the SDK README.
Migrate from v1
The old SDK remains in the repository's v1 branch. API v1 hosts are off. Import /v2 and migrate from Open and Solve to the browser and product sessions above. The root package has no session, options, error, or model aliases.
If you used the initial flat v2 API, replace nullgate.NewClient with nullgate.New, and use api.Options and api.Error. Replace client.Session and page-level product methods with the browser visit and product sessions shown above. No compatibility aliases remain.