Frontend Integration Guide

This section documents how frontend applications integrate with the PRISM MEV Platform.

  • OpenAPI spec endpoints: /api-docs/openapi.json, /api-docs/openapi.yaml
  • Interactive docs: /swagger-ui (Swagger UI)
  • Spec version: /api-docs/spec-version

Quick Start

  1. Generate OpenAPI spec + clients:
    make clients-generate
    
  2. Sync to your frontend repository:
    FRONTEND_PATH=../your-frontend make clients-sync
    
  3. In your frontend, import the generated TypeScript Axios client from src/api.

Live Docs Server

Run the docs server locally:

cargo run --bin docs_server --features off-chain -- 8081

Open http://localhost:8081/swagger-ui

Authentication

  • Use x-api-key header for endpoints requiring authentication.
  • Example:
    const client = axios.create({
      baseURL: process.env.NEXT_PUBLIC_API_BASE_URL,
      headers: { 'x-api-key': process.env.NEXT_PUBLIC_API_KEY! }
    })
    

Error Model

All API errors include a machine-readable code and human-friendly message suitable for UI display.

WebSocket Updates

The docs server reserves a channel for future live spec updates. Frontends may subscribe once available for hot reloading API schemas in dev mode.