Rate Limiting
Overview
To ensure fair usage and maintain service quality, Silent Witness implements rate limiting across all SDK methods. Our SDKs automatically handle rate limiting for you.
API Limits
Request Rate Limits
Default Limits: 1000 requests per hour per API key
File Upload Limits
- Maximum file size: 50MB per file
- Supported formats: JPEG, PNG, WebP, PDF, DOC, DOCX, CSV
- Files exceeding 50MB will be rejected immediately with an error
For more details on file uploads, see the File Upload documentation.
How SDKs Handle Rate Limiting
Our SDKs automatically monitor rate limit information and handle throttling transparently:
- Automatic Detection: SDKs monitor rate limit metadata in responses
- Intelligent Retry: Exponential backoff when rate limits are hit
- Transparent Handling: Your code doesn't need to handle rate limiting manually
Rate Limit Information
While SDKs handle rate limiting automatically, you can still access rate limit information:
limit - integer
The maximum number of requests allowed in the current window
remaining - integer
The number of requests remaining in the current window
resetTime - timestamp
When the rate limit window resets
Rate Limit Windows
Rate limits are calculated using a sliding window:
- Window Duration: 1 hour (3600 seconds)
- Window Type: Sliding window (not fixed hourly reset)
SDK Rate Limit Handling
Automatic Retry Logic
When rate limits are exceeded, SDKs automatically handle the retry process:
- Go
- TypeScript
// SDK automatically retries with exponential backoff
response, err := client.Hello.SayHello(ctx, params)
if err != nil {
// Only fails if all retries are exhausted
log.Printf("Request failed after retries: %v", err)
}
// Success - SDK handled any rate limiting transparently
try {
// SDK automatically retries with exponential backoff
const response = await client.sayHello({ name: "World" });
// Success - SDK handled any rate limiting transparently
} catch (error) {
// Only throws if all retries are exhausted
console.error("Request failed after retries:", error);
}
Best Practices
- Trust the SDK: Let the SDK handle rate limiting automatically
- Handle Final Errors: Only handle errors after all SDK retries are exhausted
- Cache Responses: Cache responses in your application to reduce API calls
- Batch Operations: Group multiple operations when SDK methods support it
SDK Usage Examples
Since SDKs handle rate limiting automatically, your code can focus on business logic:
- Go
- TypeScript
func processMultipleRequests(client *silentwitness.Client) {
ctx := context.Background()
for i := 0; i < 100; i++ {
// SDK automatically handles rate limiting
response, err := client.Hello.SayHello(ctx,
&silentwitness.HelloParams{
Name: silentwitness.String(fmt.Sprintf("Request %d", i)),
})
if err != nil {
log.Printf("Request %d failed: %v", i, err)
continue
}
log.Printf("Request %d succeeded: %s", i, response.Message)
}
}
async function processMultipleRequests(client: SilentWitnessClient) {
for (let i = 0; i < 100; i++) {
try {
// SDK automatically handles rate limiting
const response = await client.sayHello({
name: `Request ${i}`
});
console.log(`Request ${i} succeeded:`, response.message);
} catch (error) {
console.error(`Request ${i} failed:`, error);
}
}
}
Custom Rate Limits
Need higher rate limits? Contact our support team at support@silentwitness.ai
Custom rate limits are available for enterprise customers. Please include your expected usage patterns and business requirements when requesting.
Rate Limit Monitoring
Monitor your API usage with these strategies:
- Track Usage: Log rate limit headers from each response
- Set Alerts: Alert when remaining requests drop below threshold
- Analyze Patterns: Identify peak usage times and optimize accordingly
- Plan Capacity: Request limit increases before hitting constraints
Testing Rate Limits
You can test rate limiting behavior using SDK methods. Make rapid requests to trigger rate limiting and observe how the SDK handles retries automatically:
- Go
- TypeScript
// Test rate limiting with rapid requests
for i := 0; i < 1500; i++ { // Exceed the 1000/hour limit
_, err := client.Hello.SayHello(ctx, params)
// SDK will automatically handle rate limiting
// Some requests may take longer due to backoff
}
// Test rate limiting with rapid requests
const promises = [];
for (let i = 0; i < 1500; i++) { // Exceed the 1000/hour limit
promises.push(client.sayHello({ name: `Test ${i}` }));
}
// SDK will automatically handle rate limiting for each request
await Promise.allSettled(promises);