Skip to main content

API Reference

Complete reference documentation for all sc.sb platform APIs, including REST APIs, GraphQL, and SDK libraries.

Overview

The sc.sb platform provides comprehensive APIs for programmatic access to all services and resources. This reference covers:

  • REST APIs - HTTP-based service interfaces
  • GraphQL APIs - Flexible data querying
  • Webhooks - Real-time event notifications
  • SDK Libraries - Language-specific development kits
  • Authentication - API security and access control

Authentication

API Keys

Getting Started:

  1. Generate API Key - Create authentication credentials
  2. Set Permissions - Configure access levels
  3. Test Authentication - Verify API access
  4. Secure Storage - Protect your API keys

API Key Format:

Authorization: Bearer sk_live_1234567890abcdef

OAuth 2.0

OAuth Flow:

  • Authorization Code - Server-side applications
  • Client Credentials - Service-to-service authentication
  • Refresh Tokens - Long-term access management
  • Scope Management - Granular permission control

REST APIs

Core Services API

Base URL: https://api.sc.sb/v1

Service Management:

GET /services
POST /services
GET /services/{id}
PUT /services/{id}
DELETE /services/{id}

Resource Management:

GET /resources
POST /resources
GET /resources/{id}
PUT /resources/{id}
DELETE /resources/{id}

Storage API

File Operations:

GET /storage/files
POST /storage/files
GET /storage/files/{id}
PUT /storage/files/{id}
DELETE /storage/files/{id}

Directory Operations:

GET /storage/directories
POST /storage/directories
GET /storage/directories/{id}
PUT /storage/directories/{id}
DELETE /storage/directories/{id}

Computing API

Virtual Machines:

GET /compute/instances
POST /compute/instances
GET /compute/instances/{id}
PUT /compute/instances/{id}
DELETE /compute/instances/{id}

Container Services:

GET /compute/containers
POST /compute/containers
GET /compute/containers/{id}
PUT /compute/containers/{id}
DELETE /compute/containers/{id}

GraphQL API

Schema Overview

Query Operations:

query {
services {
id
name
status
resources {
id
type
usage
}
}
}

Mutation Operations:

mutation {
createService(input: {
name: "My Service"
type: "web"
resources: {
cpu: 2
memory: 4096
}
}) {
id
name
status
}
}

Real-time Subscriptions

Service Status Updates:

subscription {
serviceStatusChanged {
id
status
timestamp
}
}

Webhooks

Event Types

Service Events:

  • service.created - New service created
  • service.updated - Service configuration changed
  • service.deleted - Service removed
  • service.status_changed - Service status updated

Resource Events:

  • resource.created - New resource provisioned
  • resource.updated - Resource configuration changed
  • resource.deleted - Resource decommissioned
  • resource.usage_alert - Resource usage threshold exceeded

Webhook Configuration

Setting Up Webhooks:

POST /webhooks
Content-Type: application/json

{
"url": "https://your-app.com/webhooks/scsb",
"events": ["service.created", "service.updated"],
"secret": "your-webhook-secret"
}

SDK Libraries

JavaScript/Node.js

Installation:

npm install @scsb/sdk

Usage:

const { ScsbClient } = require('@scsb/sdk');

const client = new ScsbClient({
apiKey: 'your-api-key'
});

// List services
const services = await client.services.list();

// Create a new service
const service = await client.services.create({
name: 'My Service',
type: 'web'
});

Python

Installation:

pip install scsb-sdk

Usage:

from scsb import ScsbClient

client = ScsbClient(api_key='your-api-key')

# List services
services = client.services.list()

# Create a new service
service = client.services.create(
name='My Service',
type='web'
)

Go

Installation:

go get github.com/scsb/go-sdk

Usage:

package main

import (
"github.com/scsb/go-sdk"
)

func main() {
client := scsb.NewClient("your-api-key")

// List services
services, err := client.Services.List()

// Create a new service
service, err := client.Services.Create(&scsb.ServiceRequest{
Name: "My Service",
Type: "web",
})
}

Error Handling

HTTP Status Codes

Success Codes:

  • 200 OK - Request successful
  • 201 Created - Resource created
  • 204 No Content - Request successful, no content

Client Error Codes:

  • 400 Bad Request - Invalid request
  • 401 Unauthorized - Authentication required
  • 403 Forbidden - Access denied
  • 404 Not Found - Resource not found
  • 429 Too Many Requests - Rate limit exceeded

Server Error Codes:

  • 500 Internal Server Error - Server error
  • 502 Bad Gateway - Gateway error
  • 503 Service Unavailable - Service temporarily unavailable

Error Response Format

{
"error": {
"code": "INVALID_REQUEST",
"message": "The request is invalid",
"details": {
"field": "name",
"reason": "required"
}
}
}

Rate Limiting

Limits

API Rate Limits:

  • Free Tier - 1,000 requests per hour
  • Pro Tier - 10,000 requests per hour
  • Enterprise - 100,000 requests per hour

Rate Limit Headers:

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

Best Practices

Rate Limit Management:

  • Exponential Backoff - Retry with increasing delays
  • Request Batching - Combine multiple requests
  • Caching - Cache responses when appropriate
  • Monitoring - Track rate limit usage

Testing

API Testing Tools

Postman Collection:

  • Import Collection - Download sc.sb API collection
  • Environment Setup - Configure API keys and base URLs
  • Test Automation - Automated API testing
  • Documentation - Interactive API documentation

cURL Examples:

# List services
curl -H "Authorization: Bearer your-api-key" \
https://api.sc.sb/v1/services

# Create service
curl -X POST \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{"name":"My Service","type":"web"}' \
https://api.sc.sb/v1/services

Best Practices

API Usage

Efficient API Calls:

  • Use Pagination - Handle large result sets
  • Filter Results - Reduce data transfer
  • Cache Responses - Minimize redundant requests
  • Batch Operations - Combine multiple operations
  • Error Handling - Implement robust error handling

Security

API Security:

  • Secure API Keys - Never expose in client-side code
  • Use HTTPS - Always use secure connections
  • Validate Input - Sanitize all user inputs
  • Monitor Usage - Track API usage patterns
  • Regular Rotation - Rotate API keys periodically

Support

API Support

Documentation:

  • Interactive API Explorer - Test APIs in browser
  • Code Examples - Sample implementations
  • SDK Documentation - Language-specific guides
  • Changelog - API version updates

Getting Help:

  • API Support - Technical API assistance
  • Community Forums - Developer community
  • GitHub Issues - Bug reports and feature requests
  • Direct Support - Enterprise API support

Next Steps


The sc.sb API provides powerful programmatic access to all platform services. Use this reference to integrate with our platform and build amazing applications.