API Reference

Integrate MSpread simulations into your own applications and workflows.

v0.5.0OAS 3.1

Authentication

MSpread supports two methods of authentication. Use Bearer tokens for client-side applications and API Keys for server-side scripts.

Method A: Bearer Token

Standard for frontend applications using JWT.

Authorization: Bearer <JWT_TOKEN>

Method B: API Key

Recommended for scripts and external tools. Generate this in your settings.

X-API-Key: <YOUR_API_KEY>

Auth Endpoints

POST/auth/register

Register a new user account.

Request Body

{
  "email": "user@example.com",
  "password": "string"
}
POST/auth/login

Login and retrieve a JWT access token.

Request Body

{
  "email": "user@example.com",
  "password": "string"
}

Example Usage (Python)

import requests
import json

API_KEY = "msp_example_key_12345"
BASE_URL = "https://api.mspread.com/api"

headers = {
    "X-API-Key": API_KEY,
    "Content-Type": "application/json"
}

# 1. Define Simulation
payload = {
    "network_config": {
        "network_type": "scale_free",
        "num_nodes": 50
    },
    "malware_config": {
        "malware_type": "worm",
        "infection_rate": 0.3
    },
    "initial_infected": ["device_0"],
    "max_steps": 50
}

# 2. Run Simulation
response = requests.post(f"{BASE_URL}/simulate", json=payload, headers=headers)

if response.status_code == 200:
    results = response.json()
    print(f"Simulation Complete! ID: {results['id']}")
else:
    print(f"Error: {response.text}")