Skip to main content
Use the official Python package to read 0xinsider data from a script or service. Install 0xinsider and import oxinsider. The source repository contains the client and examples.

Install

You need Python 3.9 or newer. The package uses httpx for HTTP requests and includes its type annotations.

Make a request without a key

Use the sandbox to get example data without an account or credential.
Client.sandbox() uses https://0xinsider.com/sandbox and sends no credential. See the sandbox page for supported operations. Add sandbox_status to request a documented error example:

Switch to live data

Set OXINSIDER_API_KEY in your environment. Client() reads it automatically.
You can also pass api_key= from a secret manager. Use an API key or an OAuth access token linked to an account with an active Pro or Max subscription; see Authentication. The same methods work in the sandbox and against live data. The remaining snippets assume client is the live client created above. Use a with block or call client.close() when your application finishes.

Keep money values exact

Trader and position responses can include an exact block containing decimal strings. Parse a value directly with Decimal when you need exact arithmetic. Converting through float first can lose precision.
Each value includes unit, scale, and basis. The block or one of its fields can be absent when the source is unavailable. An absent value is not zero.

Find a method

Method names use the OpenAPI operationId in snake case. For example, listLeaderboard becomes list_leaderboard, and getMarketFlow becomes get_market_flow. Most methods return the decoded JSON body, including the API envelope. Markdown methods return strings, and download methods return a streaming Download.
Compare OPENAPI_SHA256 with the SHA-256 of the published OpenAPI document. Check the changelog and upgrade when you need a newer operation or type.

Read optional fields

Your editor uses TypedDict types from oxinsider.types for request bodies and responses. The client returns ordinary decoded dictionaries; it does not validate or convert them into model objects at runtime.
An omitted key and a null value are different, and neither means zero. A filter can guarantee a value without changing the generated type; read optional fields with .get() even when the filter normally supplies them. New response keys remain in the dictionary even if your installed types do not know them. Upgrade the package, or use the low-level client.request(...) when you need an untyped call. Resolving annotations with typing.get_type_hints requires Python 3.10 or newer.

Read every page

paginate yields items and follows next_cursor while keeping your filters unchanged. Use the canonical large-trade operation for new code:
The client checks a page before yielding it. A malformed list, invalid data, missing continuation cursor, or repeated cursor raises PaginationError.
Read error.reason to identify the problem. pagination_checkpoint(error) returns the last paging position when one exists; it does not mean the list was completed. Pass a PaginationProgress() object as progress= to retain the position during a normal run. Resume with progress.cursor to fetch the last page again, or progress.next_cursor after processing the whole page. progress.stopped_by distinguishes the end of the list from a limit you supplied. See Pagination for filter changes and expired cursors.

Read headers and cache validators

Use client.with_response.<method>(...) when you need the body and headers together:
ApiResponse.data is the same body the plain method returns. The wrapper also exposes monthly_quota, batch_rate_limit, request_cost, retry_after, and header(name). Send .etag back as if_none_match= to revalidate a cached response. A 304 returns a not_modified result, so keep your cached body. An absent budget header is None; it does not mean the budget is exhausted.

Handle failures

An API error raises an exception with status, code, and retry_after. All client errors inherit OxinsiderError; errors carrying an API body also inherit OxinsiderApiError. Errors explains the API’s code and reason values.

Request behavior

Read an async stream for a finite task

AsyncClient.stream() reconnects and resumes from the last received event ID. For a task with a time limit, cancel the read through asyncio.wait_for; the client closes the connection on cancellation. This example requires Python 3.9 or newer:
Automatic resume tracks received events. If processing can fail, save your own completed-event checkpoint before reconnecting; see Stream.

Limits

  • The client does not place Polymarket orders or hold a wallet key.
  • Webhook and export methods can change resources on your 0xinsider account.
  • Missing values remain missing. Keep numeric precision until display and use exact decimal strings for arithmetic when available.
  • A package release implements its recorded API document. Upgrade to get newly generated methods and types.