Convert USDZ to GLB
Short answer
The Sirv API converts USDZ, OBJ, FBX, STL and Blender files into GLB, which Sirv Media Viewer can show or turn into a 360 spin. Send a request to /v2/files/3d/model2GLB with the file path; the GLB is saved next to the original. Enterprise accounts can convert 100 files an hour, Business 100+ 30, Business 10.
After reading this you will know
- How to convert 3D files to GLB with the API
- Where the GLB file is saved
- How many conversions you can run an hour, and how accurate they are
The Sirv API can convert USDZ, OBJ, FBX, STL and Blender files into GLB files.
Those GLB files can then be served as they are in Sirv Media Viewer or converted to 360 spinning images or static images.
How to convert USDZ to GLB
Section titled “How to convert USDZ to GLB”1. Connect to the Sirv API and get a bearer token using the standard method.
2. Use the bearer token to submit an API request to the endpoint https://api.sirv.com/v2/files/3d/model2GLB.
In your request, enter the path to your USDZ file using the filename field. An API search can find the paths of all your USDZ files.
The following Curl example will convert a USDZ file at path /example-folder/example-file.usdz:
curl --request POST \ --url https://api.sirv.com/v2/files/3d/model2GLB \ --header 'Authorization: Bearer JIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRJZCI6IkoyU2xSWE04NE1VMlBCV1cwdW5UYkl' \ --header 'Content-Type: application/json' \ --data '{ "filename": "/example-folder/example-file.usdz"}'The GLB file will be created at the same path but with a .glb extension, like this:
/example-folder/example-file.glb3. A successful request will return a unique job ID, using JSON formatting:
{ "id": "DFLhz0pkNkv7vxTh7RcBqoQiBWWCAoSA"}An unsuccessful request will return an error, such as a 429 error that you’ve reached your account limit:
{ "statusCode": 429, "error": "Too Many Requests", "message": "rest:post:files:3d:model2GLB rate limit exceeded: too many requests (0). Please stop sending requests until 2024-11-11T22:58:13.000Z (UTC), then try again. Additional failed requests will increase the wait time. Please visit /rest-api/sirv-rest-api/#429-rate-limit-too-many-requests"Contact the Sirv team if you need help with an error.
4. The GLB file is now being prepared. It typically takes 5-30 seconds to convert the USDZ file but if there is a queue of others waiting to be converted, it will take longer.
You can check if your job has completed by submitting a GET request to endpoint v2/files/3d/model2GLB with the job ID in the URL. This example uses Curl:
curl --request GET \ --url 'https://api.sirv.com/v2/files/3d/model2GLB?id=DFLhz0pkNkv7vxTh7RcBqoQiBWWCAoSA' \ --header 'Authorization: Bearer JIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRJZCI6IkoyU2xSWE04NE1VMlBCV1cwdW5UYkl'The response will show the percentage completed from 0-100. If it is 0, then it is either waiting or being prepared. 100 indicates that it has completed. Example response:
{ "progress": 100}Hourly API limit
Section titled “Hourly API limit”Your account can submit a certain number of GLB creation requests per hour, depending on your Sirv plan:
- Enterprise: 100 requests / hour
- Business 100+: 30 requests / hour
- Business: 10 requests / hour
- Trial: 5 requests / hour
- Free: 0
Conversion accuracy
Section titled “Conversion accuracy”You should view your new GLB file after conversion, to confirm that it looks accurate. You can then add meta to it, such as a title or description, via the API.
Normally, the GLB will look identical to the original USDZ (or other) file but if the original file had an unexpected configuration, it might not look exactly correct.
In this case, you can try resaving your original file or you could modify the GLB.
The Sirv team can help you investigate a file that didn’t convert. Please send our team the URL of the converted file.
