Best Practices

Best practices for using the Swiftia API

This section outlines best practices for using the Swiftia API effectively and efficiently.

Handling Rate Limits

As described in the Rate Limiting section, the Swiftia API has rate limits. Implement proper retry logic with exponential backoff to handle 429 Too Many Requests errors gracefully.

Asynchronous Requests (Recommended)

For long-running tasks like video processing, use asynchronous requests to avoid blocking your application. Poll the job status endpoint periodically to check for completion. This improves the responsiveness of your application and prevents timeouts.

Efficient Data Retrieval

Only retrieve the data you need. For example, if you only need the job status, don't retrieve the entire job object. This reduces bandwidth usage and improves performance.

Error Handling

Always check the HTTP status code of responses and handle errors appropriately. Refer to the Error Handling section for details on the error response format and common error codes.

Secure API Key Management

Store your API keys securely, preferably in environment variables. Never expose your API keys in client-side code or public repositories. Rotate your API keys regularly to minimize the impact of potential compromises.

Webhooks (Recommended)

Use webhooks to receive real-time notifications about job completion. This eliminates the need for constant polling and improves efficiency. See the documentation for the webhook parameter in the job creation request.

Input Validation

Validate user inputs before sending them to the Swiftia API to prevent errors and ensure data integrity. For example, check the format of the youtubeVideoId before submitting a job of videoShorts function .

Keep Your SDK Up-to-Date

If you're using a Swiftia client SDK, keep it up-to-date to benefit from the latest features, performance improvements, and bug fixes.

By following these best practices, you can ensure a smooth and efficient integration with the Swiftia API.