SDK Overview¶
The SPOT Contracts repository provides SDKs for Python and TypeScript, automatically generated from OpenAPI specifications.
Available SDKs¶
Python SDK¶
- Package:
spot-sdk - Language: Python 3.11+
- Framework: Pydantic v2
- Registry: GitLab PyPI
View Python SDK Documentation →
TypeScript SDK¶
- Package:
@spot/contracts - Language: TypeScript 5.3+
- Framework: Axios
- Registry: GitLab NPM
View TypeScript SDK Documentation →
Quick Installation¶
Quick Start¶
from spot_sdk.api_gateway import Email, EmailHeader
from spot_sdk.api_gateway import AnalysisResult
# Create email
email = Email(
id="test-123",
headers=EmailHeader(
subject="Test email",
sender="test@example.com",
recipients=["user@company.com"]
),
body_text="Email content"
)
# Use in your analyzer
result = AnalysisResult(
is_phishing=False,
threat_level="safe",
confidence=0.1,
explanation="No threats detected",
indicators=[],
metadata=AnalysisMetadata(...)
)
import { Email, EmailHeader, AnalysisResult } from '@spot/contracts';
// Create email
const email: Email = {
id: 'test-123',
headers: {
subject: 'Test email',
sender: 'test@example.com',
recipients: ['user@company.com']
},
body_text: 'Email content'
};
// Use in your application
const result: AnalysisResult = {
is_phishing: false,
threat_level: 'safe',
confidence: 0.1,
explanation: 'No threats detected',
indicators: [],
metadata: {...}
};
Common Models¶
Both SDKs provide the same core models:
Email Models¶
Email- Complete email structureEmailHeader- Email headers and metadataAttachment- File attachments
Analysis Models¶
AnalysisResult- Analysis outcomeAnalysisIndicator- Spear-phishing indicatorsAnalysisMetadata- Analysis metadataThreatLevel- Threat severity enumIndicatorType- Indicator type enum
Workflow Models¶
Workflow- Workflow definitionWorkflowStage- Workflow stage configurationAnalyzerConfig- Analyzer configuration
Orchestrator Models¶
OrchestrationResult- Overall analysis resultAnalyzerResult- Individual analyzer resultWorkflowStageResult- Stage execution result
SDK Generation¶
SDKs are automatically generated from OpenAPI specifications:
# Validate OpenAPI specs
make validate
# Generate both SDKs
make generate
# Generate specific SDK
make generate-python
make generate-typescript
Generation Flow¶
OpenAPI Specs (openapi/*.yaml)
↓
Validation
↓
Generation Tools
├── datamodel-code-generator (Python)
└── openapi-typescript-codegen (TypeScript)
↓
Generated SDKs (sdk/)
↓
Testing & Validation
↓
Publishing (GitLab Registries)
Version Management¶
Python and TypeScript SDKs have independent versions:
# Check versions
make check-versions
# Bump versions
make bump-python VERSION=1.2.0
make bump-typescript VERSION=2.1.0
Publishing¶
SDKs are published automatically via GitLab CI when tags are created:
# Publish Python SDK
git tag python-v1.2.0
git push origin python-v1.2.0
# Publish TypeScript SDK
git tag typescript-v2.1.0
git push origin typescript-v2.1.0
See Publishing Guide for detailed publishing instructions.
Use Cases¶
For Analyzer Developers¶
Use the SDK to implement SPOT analyzers:
from spot_sdk.api_gateway import Email
from spot_sdk.api_gateway import AnalysisResult
@app.post("/internal/analyze")
async def analyze(email: Email) -> AnalysisResult:
# Your analysis logic
return AnalysisResult(...)
For Application Developers¶
Use the SDK to integrate with SPOT Platform:
import { SpotApiClient } from './client';
import { Email } from '@spot/contracts';
const client = new SpotApiClient();
const result = await client.analyzeEmail(email);
For Testing¶
Use the SDK models in tests:
from spot_sdk.api_gateway import Email
def test_email_validation():
email = Email(id="test", headers=...)
assert email.id == "test"
Next Steps¶
- Python Developers: Read Python SDK Documentation
- TypeScript Developers: Read TypeScript SDK Documentation
- Analyzer Developers: Read Analyzer Development Guide
- Contributors: Read Development Guide
Support¶
- Issues: GitLab Issues
- Documentation: Main Documentation
- SPOT Platform: Platform Docs