🔗 API Reference

Complete API documentation for VibeStarter platform integration

🔐 Authentication

VibeStarter uses session-based authentication with email/password login. All API endpoints require valid authentication except public data endpoints.

🎯 Endpoints

POST /api/auth/signin - User login
POST /api/auth/signup - User registration
POST /api/auth/signout - User logout
GET /api/auth/session - Current session

📝 Request Format

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

🚀 Core Endpoints

🏢 Startups

GET /api/startups - List all startups
POST /api/startups - Create startup listing
PUT /api/startups - Update startup
📋 Example Response
{
  "startups": [
    {
      "id": 1,
      "name": "TaskFlow Pro",
      "tagline": "Next-gen productivity suite",
      "description": "Revolutionary task management...",
      "category": "Productivity",
      "status": "active",
      "current_users": 15420,
      "monthly_downloads": 3200,
      "total_downloads": 28540,
      "creator_id": 42,
      "created_at": "2024-01-15T10:30:00Z"
    }
  ]
}

📈 Prediction Markets

GET /api/markets - List active markets
GET /api/markets/advanced - Advanced market data
POST /api/predictions - Place prediction
📋 Market Response
{
  "market": {
    "id": 15,
    "startup_id": 1,
    "title": "TaskFlow Pro to reach 100K downloads",
    "description": "Will TaskFlow Pro reach 100,000 total downloads by March 2024?",
    "market_type": "downloads",
    "target_value": 100000,
    "end_date": "2024-03-31T23:59:59Z",
    "resolved": false,
    "total_yes_amount": "450.25",
    "total_no_amount": "234.80",
    "yes_price": 0.65,
    "no_price": 0.35
  }
}

💎 Crypto Operations

GET /api/crypto/wallet - Wallet info
POST /api/crypto/deposit - Deposit SOL
POST /api/crypto/withdrawal - Withdraw SOL
POST /api/crypto/predictions - Crypto predictions
💰 Deposit Request
{
  "amount": "0.5",
  "wallet_address": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
  "transaction_hash": "2ZE7Rt5x..."
}

👤 User Management

GET /api/user/profile - User profile
GET /api/user/balance - User balance
POST /api/user/onboarding - Complete onboarding

🔄 AMM Pricing

GET /api/amm/pricing - Calculate trade pricing
💹 Pricing Request
{
  "market_id": 15,
  "position": "yes",
  "amount": "10.0"
}

// Response:
{
  "shares": "15.384615",
  "price_impact": "0.0234",
  "current_price": "0.65",
  "new_price": "0.6734",
  "fees": "0.10"
}

❌ Error Handling

VibeStarter API uses conventional HTTP status codes and returns structured error responses.

📊 Status Codes

200 - Success
201 - Created
400 - Bad Request
401 - Unauthorized
403 - Forbidden
404 - Not Found
500 - Server Error

📝 Error Format

{
  "error": {
    "code": "INSUFFICIENT_BALANCE",
    "message": "Insufficient SOL balance",
    "details": {
      "required": "0.5",
      "available": "0.25"
    }
  }
}

⏱️ Rate Limiting

📊 Limits

  • Public endpoints: 100 requests/minute
  • Authenticated endpoints: 1000 requests/minute
  • Trading endpoints: 10 requests/minute
  • Crypto operations: 5 requests/minute

📨 Headers

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1640995200

🛠️ Integration Examples

🟨 JavaScript/Node.js

// Fetch active prediction markets
const response = await fetch('https://yourdomain.com/api/markets');
const { markets } = await response.json();

// Place a prediction
const prediction = await fetch('https://yourdomain.com/api/predictions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Cookie': 'session=your_session_token'
  },
  body: JSON.stringify({
    market_id: 15,
    position: 'yes',
    amount: '10.0'
  })
});

🐍 Python

import requests

# Get user balance
response = requests.get(
    'https://yourdomain.com/api/user/balance',
    cookies={'session': 'your_session_token'}
)
balance_data = response.json()

# Create startup listing
startup_data = {
    'name': 'My SaaS App',
    'tagline': 'Revolutionary productivity tool',
    'category': 'Productivity'
}
response = requests.post(
    'https://yourdomain.com/api/startups',
    json=startup_data,
    cookies={'session': 'your_session_token'}
)

📱 React Hook Example

import { useState, useEffect } from 'react';

const useMarkets = () => {
  const [markets, setMarkets] = useState([]);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    fetch('/api/markets')
      .then(res => res.json())
      .then(data => {
        setMarkets(data.markets);
        setLoading(false);
      });
  }, []);

  return { markets, loading };
};