Quick Start Guide
This guide will help you make your first API call using the Silent Witness SDKs in just a few minutes.
Prerequisites
Before you begin, you'll need:
- API Key: Contact support to obtain your API key
- Development Environment: Go 1.21+ or Node.js 18+ depending on your chosen SDK
- Go
- TypeScript
1. Install the Go SDK
go get github.com/silentwitness/go-sdk
2. Create your first client
package main
import (
"context"
"fmt"
"log"
"github.com/silentwitness/go-sdk"
)
func main() {
// Initialize the API client
client := silentwitness.NewClient(silentwitness.Config{
APIKey: "your-api-key",
})
// Create a new case
ctx := context.Background()
caseResp, err := client.Cases.Create(ctx, &silentwitness.CreateCaseRequest{
Name: silentwitness.String("Smith v. Johnson"),
ClientName: silentwitness.String("Jane Smith"),
})
if err != nil {
log.Fatalf("Failed to create case: %v", err)
}
fmt.Printf("Case created successfully\n")
fmt.Printf("Case ID: %s\n", caseResp.CaseId)
fmt.Printf("Status: %s\n", caseResp.Status)
}
3. Run your application
go run main.go
1. Install the TypeScript SDK
npm install @silentwitness/typescript-sdk
2. Create your first client
import { SilentWitnessClient } from "@silentwitness/typescript-sdk";
// Initialize the API client
const client = new SilentWitnessClient({
apiKey: "your-api-key",
});
// Create a new case
async function createCase() {
try {
const response = await client.cases.createCase({
name: "Smith v. Johnson",
clientName: "Jane Smith"
});
console.log("Case created successfully");
console.log("Case ID:", response.case?.id);
console.log("Status:", response.case?.status);
} catch (error) {
console.error("Failed to create case:", error);
}
}
createCase();
3. Run your application
npx tsx index.ts
Expected Response
When you run either example, you should see output similar to:
Case created successfully
Case ID: case_1234567890abcdef
Status: active
Complete Analysis in One Call
For most use cases, use StartAnalysis() which handles the entire process automatically:
- Go
- TypeScript
import (
"context"
"fmt"
"log"
"os"
"time"
silentwitness "github.com/silentwitness/go-sdk"
)
func main() {
silentwitness.Key = "your-api-key"
ctx := context.Background()
// Load vehicle images
img1, _ := os.ReadFile("plaintiff-front.jpg")
img2, _ := os.ReadFile("plaintiff-rear.jpg")
// Start analysis
poller, err := silentwitness.StartAnalysis(ctx, &silentwitness.AnalyzeCaseRequest{
AnalysisType: silentwitness.AnalysisTypeTechnicalReport,
CaseName: silentwitness.String("Smith v. Jones"),
Plaintiff: &silentwitness.VehicleAnalysisData{
Images: [][]byte{img1, img2},
VehicleMake: silentwitness.String("Toyota"),
VehicleModel: silentwitness.String("Camry"),
VehicleYear: silentwitness.String("2020"),
},
})
if err != nil {
log.Fatal(err)
}
// Monitor progress
for !poller.Done() {
fmt.Printf("Status: %s\n", poller.Status())
time.Sleep(5 * time.Second)
}
// Get result
result, err := poller.Result()
if err != nil {
log.Fatal(err)
}
fmt.Printf("Case ID: %s\n", result.CaseID)
fmt.Printf("Report URL: %s\n", result.ReportURL)
}
import { SilentWitnessClient, startAnalysis } from "@silentwitness/typescript-sdk";
import fs from "fs";
const client = new SilentWitnessClient({ apiKey: "your-api-key" });
// Load vehicle images
const img1 = fs.readFileSync("plaintiff-front.jpg");
const img2 = fs.readFileSync("plaintiff-rear.jpg");
// Start analysis
const poller = startAnalysis(client, {
analysisType: "technical_report",
caseName: "Smith v. Jones",
plaintiff: {
images: [new Uint8Array(img1), new Uint8Array(img2)],
vehicleMake: "Toyota",
vehicleModel: "Camry",
vehicleYear: "2020",
},
});
// Monitor progress
while (!poller.isDone()) {
console.log(`Status: ${poller.getStatus()}`);
await new Promise(r => setTimeout(r, 5000));
}
// Get result
const result = await poller.wait();
console.log(`Case ID: ${result.caseId}`);
console.log(`Report URL: ${result.reportUrl}`);
See the Complete Case Analysis Guide for more examples.
Next Steps
Now that you've made your first API call, here's what you can explore next:
- Complete Case Analysis - Full analysis with progress tracking
- Authentication Guide - Learn about securing your API requests
- API Reference - Explore all available endpoints and their parameters
- Error Handling - Learn how to handle errors gracefully in your applications
Common Issues
Connection Errors
If you're getting connection errors, check:
- Network Access: Ensure your environment can reach
core.silentwitness.ai - Firewall Rules: Check if your network allows HTTPS connections
- DNS Resolution: Verify that the API domain resolves correctly
Authentication Errors
If you're getting authentication errors:
- API Key Format: Ensure your API key starts with
sk- - API Key Validity: Check that your API key hasn't been revoked
- Client Configuration: Verify the API key is correctly set in your client
Rate Limiting
If you're hitting rate limits:
- Implement Backoff: Add exponential backoff when receiving rate limit errors
- Monitor Usage: Track your API usage to stay within limits
- Request Increase: Contact support if you need higher rate limits
Getting Help
- Documentation - Browse the complete documentation
- Examples - See more code examples
- Support - Contact our support team