Skip to main content
Use github.com/0xinsider/0xinsider-go to call the API from a Go program. Each operation has a typed ...WithResponse method. The source repository contains the generated types and request helpers.

Install

You need Go 1.26.5 or newer. The client uses github.com/oapi-codegen/runtime.

Make a request without a key

Start with example data from the sandbox. You do not need an account or a credential.
WithBaseURL("https://0xinsider.com/sandbox") sends requests to the sandbox. Supported operations return their documented examples. See the sandbox page for exceptions and the sandbox_status query parameter for error examples.

Switch to live data

Import os and replace the sandbox client with:
Set OXINSIDER_API_KEY in your environment first. The client does not read that variable itself; the example passes its value to WithBearerToken. WithBearerToken accepts an API key (oxi_sk_live_...) or an OAuth access token (oxi_at_...). The default API origin is https://api.0xinsider.com. Live data requires an active Pro or Max subscription; the public routes work without a token.

Read the response

The HTTP status selects the response field: JSON200 contains a decoded 200 body, JSON201 contains a decoded 201 body, and other fields work the same way. Those fields are nil for a different status. Always check before you use one.
Body contains the raw response bytes, and StatusCode() returns the HTTP status. Read the API’s error.code and error.reason when the response is an error; Errors explains the possible values. Optional fields are pointers. A nil Grade means that no grade was returned. It does not mean the wallet has an F grade or a zero value.

Keep money values exact

Trader and position responses can include an exact block with decimal values stored as strings. Use these values for arithmetic when they are available. Parse them directly into math/big.Rat or another decimal type, without converting through float64.
Each exact value also records its Unit, Scale, and Basis. The block or one of its fields can be absent when the source value is unavailable. Report that absence instead of substituting zero.

Set a deadline

Ordinary requests have a 30-second default deadline. Export downloads have a 5-minute default deadline. The default transport also limits connection, TLS handshake, and response-header waits.
A context with a deadline keeps the deadline you supplied. Use a shorter one for a request that must finish sooner. WithRequestTimeout(0) removes the client’s total request deadline but keeps the transport’s connection limits. A deadline added by the client returns *oxinsider.RequestTimeoutError. It includes Deadline, Method, and URL, unwraps to context.DeadlineExceeded, and implements Timeout() bool. A deadline you supplied returns the context’s own error. The event stream has no total request deadline. Read it with OpenStream, which uses separate start and idle timeouts. Do not use the generated GetStreamWithResponse: it would try to read the entire stream before returning. For a finite stream task, pass a context deadline to OpenStream and call reader.Close() when finished.

Protect the credential

Credentialed requests require HTTPS. HTTP is allowed only for a loopback development host. An insecure destination or a redirect that downgrades the request returns *oxinsider.InsecureTransportError before the credential is sent. The error identifies the destination without including the token.

Check which API version you have

The package records the OpenAPI document used to generate it:
Compare OpenAPISHA256 with the SHA-256 of the published OpenAPI document. A difference means the documents differ; check the changelog for the changes and upgrade when you need them.

Limits

  • The client does not retry failed requests. Handle 429, 503, and other failures in your application.
  • It does not place Polymarket orders or hold a wallet key.
  • Webhook and export operations can change resources on your 0xinsider account.
  • Round values only when displaying them. Missing values remain missing.
Read Authentication to create a live key, or Quickstart for common API calls.