Polling
Updates through data polling
Learn how to keep your application in sync with RotateProduct’s API by polling for generation status updates and downloading your finished 3D rotating product videos.
Overview
When you request a new video generation, the process is asynchronous:
- The generation starts in a
rotating
(processing) state. - You need to check (poll) the status until it is
completed
. - Once completed, you can download the video.
Step 1: Submit a Generation Request
Use the bulk generation endpoint to start a new generation.
You’ll receive a unique id
for each generation in the response.
Step 2: Poll for Status Updates
Use the Get Generation Status endpoint to check the progress:
Endpoint:GET /api/v1/generations/:id/status
Authorization: Bearer YOUR_API_KEY
Example using curl
:
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://rotateproduct.com/api/v1/generations/123/status
Example response:
{
"id": 123,
"external_id": "your-external-id",
"status": "rotating",
"created_at": "2024-05-08T12:34:56.789Z",
"updated_at": "2024-05-08T12:35:56.789Z"
}
- If
status
isrotating
, the video is still being processed. - If
status
iscompleted
, the video is ready for download. - If
status
isfailed
, there was an error (see FAQ below).
Recommended polling interval:
Poll every 5–10 seconds until the status
is completed
or failed
.
Step 3: Download the Video
Once the status
is completed
, use the Get Generation by ID endpoint to download the video.
- The video will be returned as an
mp4
file. - Videos are available for 1 hour after completion—download promptly!
Example: Polling in JavaScript
async function pollGenerationStatus(id, apiKey) {
const statusUrl = `https://rotateproduct.com/api/v1/generations/${id}/status`
while (true) {
const res = await fetch(statusUrl, {
headers: { Authorization: `Bearer ${apiKey}` },
})
const data = await res.json()
if (data.status === 'completed') {
return true
}
if (data.status === 'failed') {
throw new Error('Generation failed')
}
await new Promise((resolve) => setTimeout(resolve, 5000)) // Wait 5 seconds
}
}
// Usage
const id = 123 // Your generation ID
const apiKey = 'YOUR_API_KEY'
pollGenerationStatus(id, apiKey)
.then(() => {
// Download the video
window.location = `https://rotateproduct.com/api/v1/generations/${id}`
})
.catch(console.error)
FAQ
Q: What if the status is failed?
A: The generation could not be completed. Possible reasons include sensitive content, service downtime. You may retry or contact support.
Q: How long is the video available?
A: Videos are available for 1 hour after completion. Download them promptly.
Q: Can I use webhooks instead of polling?
A: Currently, polling is the recommended method. Webhook support may be added in the future.
For more help, contact info@rotateproduct.com.