Build

API, MCP & SDK

Every programmatic way into Somnia: the JSON-RPC API for the chain, the Explorer APIs, the Somnia CLI and MCP server, and the SDKs for markets and data.

Every programmatic way into Somnia.

Everything the explorer shows is reachable programmatically: the chain over JSON-RPC, the explorer's own APIs, the Somnia CLI and its MCP server, and typed SDKs for markets and data.

JSON-RPC API

Somnia exposes an RPC API compatible with the Ethereum JSON-RPC specification, so standard tooling (viem, ethers, Foundry, Hardhat) works unchanged.

  • Mainnet: https://api.infra.mainnet.somnia.network (chain ID 5031)
  • Testnet: https://api.infra.testnet.somnia.network (chain ID 50312)
  • WebSocket endpoints at the same hosts under /ws

See the JSON-RPC API reference for every method, and Somnia Dedicated RPC for private, low-latency nodes reserved for your traffic (coming soon).

Somnia MCP server

somnia mcp, part of the Somnia CLI, gives AI agents read tools for markets, order books, positions, oracle prices and the Explorer, and finds the CLI command for anything else. It never signs or sends a transaction. Add it to Claude Code with:

claude mcp add somnia -- npx -y @somnia-chain/cli mcp

See Somnia MCP server for Codex, Cursor and other clients. For the docs themselves, point your agent at llms.txt, and at the Explorer's llms.txt for its pages and APIs.

SDKs

  • Markets SDK — create and configure venues, and trade spot, perpetual and event markets. See the Markets SDK docs.
  • Venue Kit (coming soon) — a front-end template, venue commands and an agent skill. See Venue Kit.
  • Data Streams SDK — publish and read structured onchain data streams. See the SDK methods guide.
  • Somnia CLI — spot, binary and perp markets, SomniaLend, oracle prices and the Explorer from the command line, scriptable and CI-friendly. See Somnia CLI.

Edit this page

Send feedback

Agents: POST the same to /api/feedback.