Convert a 360 spin to video
Short answer
Convert a 360 spin to video with POST /v2/files/spin2video. You can specify the width/height of the video and the number of rotations. If it is a multi-row spin, you can also specify which row should be converted. Each call needs a bearer token and counts towards your hourly API limit.
After reading this you will know
- How to convert a 360 spin to video
- Which parameters it takes
- Sample code in 9 languages and a sample answer
This command needs a bearer token and counts towards your hourly limit.
Convert spin to video
Section titled “Convert spin to video”https://api.sirv.com/v2/files/spin2video
Use this API method to convert a 360 spin into an MP4 video.
You can specify the width/height of the video and the number of rotations.
If it is a multi-row spin, you can also specify which row should be converted.
Request body (JSON)
| Field | Type | Required | Example | Description |
|---|---|---|---|---|
filename | string | Yes | /REST API Examples/coin/coin.spin | Path of the .spin file to turn into a video. |
options | object | No | Size, number of loops, speed and row of the video. | |
options.width | number | No | 1920 | Up to 1920. |
options.height | number | No | 1080 | Up to 1080. |
options.loops | number | No | 3 | Up to 20. |
options.speed | number | No | 3600 | Up to 60000. |
options.row | string | No | single | For a spin with several rows: one row in the video, or all of them. One of: single, all. |
Example request
// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variableconst res = await fetch('https://api.sirv.com/v2/files/spin2video', { method: 'POST', headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}`, 'content-type': 'application/json' }, body: JSON.stringify({ "filename": "/REST API Examples/coin/coin.spin", "options": { "width": 1920, "height": 1080, "loops": 3, "speed": 3600 } }),});console.log(res.status, await res.text());import requests
res = requests.post( 'https://api.sirv.com/v2/files/spin2video', headers={'authorization': 'Bearer BEARER_TOKEN', 'content-type': 'application/json'}, json={ "filename": "/REST API Examples/coin/coin.spin", "options": { "width": 1920, "height": 1080, "loops": 3, "speed": 3600 } },)print(res.status_code, res.text)curl --request POST \ --url 'https://api.sirv.com/v2/files/spin2video' \ --header 'authorization: Bearer BEARER_TOKEN' \ --header 'content-type: application/json' \ --data '{"filename":"/REST API Examples/coin/coin.spin","options":{"width":1920,"height":1080,"loops":3,"speed":3600}}'import java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.sirv.com/v2/files/spin2video")) .header("authorization", "Bearer BEARER_TOKEN") .header("content-type", "application/json") .method("POST", HttpRequest.BodyPublishers.ofString(""" { "filename": "/REST API Examples/coin/coin.spin", "options": { "width": 1920, "height": 1080, "loops": 3, "speed": 3600 } } """)) .build();HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());System.out.println(response.statusCode() + " " + response.body());using System.Net.Http.Headers;
using var client = new HttpClient();var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.sirv.com/v2/files/spin2video");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "BEARER_TOKEN");request.Content = new StringContent("""{ "filename": "/REST API Examples/coin/coin.spin", "options": { "width": 1920, "height": 1080, "loops": 3, "speed": 3600 }}""", System.Text.Encoding.UTF8, "application/json");var response = await client.SendAsync(request);Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");<?php$ch = curl_init('https://api.sirv.com/v2/files/spin2video');curl_setopt_array($ch, [ CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HTTPHEADER => ['authorization: Bearer BEARER_TOKEN', 'content-type: application/json'], CURLOPT_POSTFIELDS => json_encode([ 'filename' => '/REST API Examples/coin/coin.spin', 'options' => [ 'width' => 1920, 'height' => 1080, 'loops' => 3, 'speed' => 3600 ] ]), CURLOPT_RETURNTRANSFER => true,]);echo curl_exec($ch);package main
import ( "fmt" "io" "net/http" "strings")
func main() { body := strings.NewReader(`{ "filename": "/REST API Examples/coin/coin.spin", "options": { "width": 1920, "height": 1080, "loops": 3, "speed": 3600 } }`) req, _ := http.NewRequest("POST", "https://api.sirv.com/v2/files/spin2video", body) req.Header.Set("authorization", "Bearer BEARER_TOKEN") req.Header.Set("content-type", "application/json") res, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer res.Body.Close() out, _ := io.ReadAll(res.Body) fmt.Println(res.Status, string(out))}require 'net/http'
uri = URI('https://api.sirv.com/v2/files/spin2video')req = Net::HTTP::Post.new(uri)req['authorization'] = 'Bearer BEARER_TOKEN'req['content-type'] = 'application/json'req.body = <<~'JSON' { "filename": "/REST API Examples/coin/coin.spin", "options": { "width": 1920, "height": 1080, "loops": 3, "speed": 3600 } }JSONres = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }puts res.code, res.bodyimport Foundation
var request = URLRequest(url: URL(string: "https://api.sirv.com/v2/files/spin2video")!)request.httpMethod = "POST"request.setValue("Bearer BEARER_TOKEN", forHTTPHeaderField: "authorization")request.setValue("application/json", forHTTPHeaderField: "content-type")request.httpBody = #"""{ "filename": "/REST API Examples/coin/coin.spin", "options": { "width": 1920, "height": 1080, "loops": 3, "speed": 3600 }}"""#.data(using: .utf8)let (data, response) = try await URLSession.shared.data(for: request)print((response as! HTTPURLResponse).statusCode, String(decoding: data, as: UTF8.self))Example response
{ "filename": "/REST API Examples/coin/coin_single_1920x1080.mp4"}