API Architecture Overview: StarkEx & ZK-Rollup
Incubated by Amber Group, EdgeX Exchange uses a Layer-2 scaling solution built on StarkWare (StarkEx). Orders are matched in an off-chain engine at up to 200,000 transactions per second with 10 ms latency. Cryptographic proofs (ZK-proofs) are then published to Ethereum, delivering L1-grade security with near-zero gas fees.
API Security: Protecting the L1 and L2 Layers
To build trading bots on EdgeX you will need standard API keys and an L2 Stark Key. Treat them as carefully as private keys. A compromised L2 key lets an attacker control your orders.
Key security practices:
- Two-factor model: Requests use a pair of Account ID / Secret (for HTTP authentication) + L2 Stark Private Key (for cryptographically signing the orders themselves).
- IP whitelist: Always bind your API keys to the static IP address of your trading server.
- Secure storage: Keep `L2_PRIVATE_KEY` and `API_SECRET` exclusively in protected environment variables (`.env`) or secret managers.
API Use Cases: AI Trading and HFT Strategies
Thanks to ultra-low fees (base ~0.012% maker / 0.038% taker) and USDT collateral, the EdgeX API is ideal for sophisticated algorithmic strategies:
- Market Making (HFT): Maintaining liquidity in the order book using WebSockets (the EdgeX engine processes orders faster than most DeFi protocols).
- Funding Rate Arbitrage: Delta-neutral strategies between EdgeX and centralized exchanges (Binance, Bybit).
- Liquidation hunting: Analyzing the feeds of the
Storkoracle used on EdgeX to calculate Index and Mark Price, for automatic entries during cascading liquidations.
Key Generation: L1 Wallet, L2 Stark Key and API Key
On EdgeX, developer onboarding consists of 3 steps:
- Connecting an L1 Wallet: Connect your wallet (e.g., MetaMask) in the EdgeX Exchange interface. Select the network (Ethereum or Arbitrum).
- L2 Stark Key generation: The platform will request a signature to derive a
Stark Key. This L2 key is used by the ZK-Rollup mathematical engine to verify that the order was placed by you. - Creating an API Key: Go to the API settings. The system will generate an Account ID (API Key) and a Secret Key, required for signing HTTP headers.
Important: When placing an order via the private API, the order body is signed with your L2 Stark Key (Stark Signature), while the HTTP request itself is protected by headers based on your Secret Key.
API Architecture and Endpoints
The EdgeX API offers two main interaction interfaces:
- REST API (pull model): Placing and canceling orders, balance queries and trade history.
- WebSocket API (push model): Instant order book updates (15 or 200 levels of depth), real-time trade streams and private account events.
Environments reference
- Mainnet REST (EdgeX):
https://pro.edgex.exchange - Mainnet WebSocket:
wss://quote.edgex.exchange - Authentication: Private (Third-party) API calls require building signatures based on your key; the specifications are described in detail in the EdgeX documentation (GitBook).
Error Handling (Error Codes)
When writing trading algorithms, it is important to handle server responses correctly. Main errors of the StarkEx / EdgeX engine:
| Code (HTTP) | Message (Cause) | Solution |
|---|---|---|
| 401 | Unauthorized / Invalid API-key or Signature. | Check that the HMAC signature for the HTTP headers is formed correctly. Make sure your IP address has been added to the whitelist. |
| 400 | Invalid Stark Signature. | The order was rejected by the ZK-Rollup engine. Check that the order hash is built correctly and signed with your L2 Stark Private Key. |
| 400 | Insufficient Margin. | Not enough collateral (USDT) to open a position. Reduce the quantity or check the margin requirements for the specific market. |
Guides and Tutorials
To get started quickly with the EdgeX infrastructure, check out our materials:
- Python Trading Bot for EdgeX — Working with StarkEx signing libraries and building limit orders.
- Streaming WebSocket Data (Node.js) — Receiving the order book and aggregated trades without delays.
- Integration Examples and Building API Clients — Code snippets for the REST API.
First Steps: Connecting and Examples
Availability Check (Public API)
To test connectivity, request the list of available trading pairs (this endpoint requires no authentication):
curl -X GET "https://pro.edgex.exchange/api/v1/symbols"
Node.js: Fetching the Order Book
An example using axios to fetch the order book for the BTC-USDT pair (collateral on EdgeX is USDT):
const axios = require('axios');
async function getOrderbook() {
try {
const response = await axios.get('https://pro.edgex.exchange/api/v1/depth', {
params: {
symbol: 'BTC-USDT',
limit: 5
}
});
console.log("Топ 5 заявок Ask:", response.data.data.asks);
} catch (error) {
console.error("Ошибка API:", error.response ? error.response.data : error.message);
}
}
getOrderbook();
Third-Party Integrations: FMZ Quant
Algorithmic Trading via FMZ
The FMZ Quant platform ships built-in, fully functional support for EdgeX DEX. You don't need to write L2 signature logic from scratch. In the FMZ dashboard, add a new exchange, select EdgeX, and enter your AccountID (Access Key) and SecretKey.
This lets you instantly launch complex strategies (e.g., "Grid Trading" or multi-level Bollinger Bands arbitrage) using the platform's ready-made interfaces, broadcasting orders straight into the EdgeX ZK engine.
Frequently Asked Questions (FAQ) about the EdgeX API
What is the base URL of the EdgeX REST API?
The main URL for REST requests to EdgeX Mainnet: https://pro.edgex.exchange. For WebSocket streams (public and private): wss://quote.edgex.exchange.
Why isn't a regular API key enough to place orders?
EdgeX is built on ZK-Rollup architecture (StarkEx). Regular keys (AccountID/Secret) only authenticate your HTTP session. The trading intent itself (size, price, pair) must be cryptographically signed with your private L2 key (Stark Private Key) for the blockchain to consider the operation valid.
How do I keep my API keys and L2 keys secure?
Always use an IP whitelist in the EdgeX panel. Never store your keys (Stark Private Key, API Secret) in public repositories (GitHub); pass them through protected environment variables (.env).