config — Network configuration

Networks

class o2_sdk.config.Network[source]

Enum of available O2 Exchange networks.

TESTNET = "testnet"

The O2 testnet (for testing and development). Includes a faucet for obtaining test tokens.

DEVNET = "devnet"

The O2 devnet (for internal/early development). Includes a faucet.

MAINNET = "mainnet"

The O2 mainnet (production). No faucet available.

Usage:

from o2_sdk import O2Client, Network

# Testnet (default)
client = O2Client(network=Network.TESTNET)

# Mainnet
client = O2Client(network=Network.MAINNET)

Network configuration

class o2_sdk.config.NetworkConfig[source]

Configuration for connecting to an O2 Exchange network.

This is a frozen (immutable) dataclass. Pass a custom instance to O2Client for private deployments or custom endpoints.

api_base: str

Base URL for REST API calls (e.g., "https://api.testnet.o2.app").

ws_url: str

WebSocket URL for real-time streams (e.g., "wss://api.testnet.o2.app/v1/ws").

fuel_rpc: str

Fuel Network RPC endpoint.

faucet_url: str | None

Faucet URL for test token minting. None for mainnet.

from o2_sdk import O2Client, NetworkConfig

custom = NetworkConfig(
    api_base="https://my-private-api.example.com",
    ws_url="wss://my-private-api.example.com/v1/ws",
    fuel_rpc="https://my-fuel-node.example.com/v1/graphql",
    faucet_url=None,
)
client = O2Client(custom_config=custom)

Built-in endpoints

Network

REST API

WebSocket

Faucet

Testnet

https://api.testnet.o2.app

wss://api.testnet.o2.app/v1/ws

Yes

Devnet

https://api.devnet.o2.app

wss://api.devnet.o2.app/v1/ws

Yes

Mainnet

https://api.o2.app

wss://api.o2.app/v1/ws

No

Helper function

o2_sdk.config.get_config(network)[source]

Return the built-in NetworkConfig for the given network.

Parameters:

network (Network) – The target network.

Returns:

The network configuration.

Return type:

NetworkConfig