OSHA Compliance API

Integration Docs

Get started with the OSHA Compliance API in minutes.

Quick Start

Get your API key from your dashboard, then make your first call:

curl -X POST https://osha-mcp.vercel.app/api/lookup \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "lookup_standard",
    "query": "fall protection"
  }'

Node.js

const response = await fetch('https://osha-mcp.vercel.app/api/lookup', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    tool: 'lookup_standard',
    query: 'fall protection for roofing work'
  })
});

const data = await response.json();
console.log(data.result);
// [
//   {
//     "standard_number": "1926.501",
//     "title": "Duty to have fall protection.",
//     "plain_summary": "This OSHA standard requires employers...",
//     "key_requirements": ["Provide fall protection for employees..."],
//     "ppe_requirements": ["Hard hat when exposed to falling objects"],
//     "ecfr_url": "https://www.ecfr.gov/current/title-29/section-1926.501"
//   }
// ]

Python

import requests

response = requests.post(
    'https://osha-mcp.vercel.app/api/lookup',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json={
        'tool': 'get_ppe_requirements',
        'task': 'overhead welding'
    }
)

data = response.json()
for standard in data['result']:
    print(f"{standard['standard_number']}: {standard['title']}")

Go

package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    body, _ := json.Marshal(map[string]string{
        "tool":  "get_penalty_info",
        "violation_type": "serious",
    })
    
    req, _ := http.NewRequest("POST", 
        "https://osha-mcp.vercel.app/api/lookup",
        bytes.NewBuffer(body))
    req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
    req.Header.Set("Content-Type", "application/json")
    
    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()
}

React

const [standards, setStandards] = useState([]);

async function lookupOSHA(query: string) {
  const res = await fetch('/api/lookup', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.OSHA_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ tool: 'lookup_standard', query })
  });
  
  const { result } = await res.json();
  setStandards(result);
}

// Usage
<button onClick={() => lookupOSHA('respiratory protection')}>
  Check OSHA Standards
</button>

Error Handling

// Error responses
{
  "error": "Missing required field: query"
}

// HTTP Status Codes
200 - Success
400 - Bad request (missing params)
401 - Invalid or missing API key
402 - Payment required (pay-per-call)
429 - Rate limit exceeded
500 - Server error

// Handle errors
if (!response.ok) {
  if (response.status === 429) {
    // Implement exponential backoff
    await delay(1000 * Math.pow(2, retryCount));
    return fetchWithRetry(payload, retryCount + 1);
  }
  throw new Error(`API error: ${response.status}`);
}

Rate Limits

PlanRequests/minMonthly cap
Free10100
Growth6010,000
Business300100,000
View Full API Reference