Getting started
The first time you use the Sirv REST API, create an API client, then connect to Sirv. Once connected, you can use over 30 API methods.
API client
To use the Sirv REST API, create an API client from the Settings page of your Sirv account:
Once created, you'll see your Client ID and Client Secret:
Connect to Sirv API
Each API call must be authenticated with a bearer token (JSON Web Token). You can get a token with a POST request. Use the token with the Sirv REST API methods listed below. When the token expires (see the expiresIn field, in seconds), you should request a new token.
Get API access token
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
payload = "{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}"
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/token", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url https://api.sirv.com/v2/token \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json' \
--data '{"clientId":"ZcnZNfzwRhQExoHFoGpxWJ4p2R","clientSecret":"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q=="}'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/token",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}");
req.end();
var data = "{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/token");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/token")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.body("{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
request.body = "{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let postData = NSData(data: "{"clientId":"ZcnZNfzwRhQExoHFoGpxWJ4p2R","clientSecret":"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q=="}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/token")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/token");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/token"
payload := strings.NewReader("{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Before using any API method, you must first obtain an API access token. Tokens expire after 20 minutes (1200 seconds). If your token expires, request a new one, then continue with your work.
Query string
None
Body payload
Example:
{
"clientId": "ZcnZNfzwRhQExoHFoGpxWJ4p2R",
"clientSecret": "TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q=="
}
JSON Schema:
{
"type": "object",
"properties": {
"clientId": {
"description": "API client ID",
"examples": [
"ZcnZNfzwRhQExoHFoGpxWJ4p2R"
],
"example": "ZcnZNfzwRhQExoHFoGpxWJ4p2R",
"type": "string"
},
"clientSecret": {
"description": "API client secret",
"examples": [
"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q=="
],
"example": "TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==",
"type": "string"
}
},
"additionalProperties": false,
"patterns": [],
"required": [
"clientId",
"clientSecret"
]
}
Response
Example response:
< HTTP/1.1 200
< date: Thu, 01 Dec 2022 19:11:48 GMT
< content-type: application/json; charset=utf-8
< content-length: 697
< connection: close
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRJZCI6IlpjblpOZnp3UmhRRXhvSEZvR3B4V0o0cDJSIiwiY2xpZW50TmFtZSI6Ik15IHdlYnNpdGUiLCJzY29wZSI6WyJhY2NvdW50OnJlYWQiLCJhY2NvdW50OndyaXRlIiwidXNlcjpyZWFkIiwidXNlcjp3cml0ZSIsImJpbGxpbmc6cmVhZCIsImJpbGxpbmc6d3JpdGUiLCJmaWxlczpyZWFkIiwiZmlsZXM6d3JpdGUiLCJ2aWRlb3MiLCJpbWFnZXMiXSwiaWF0IjoxNjY5OTIxOTA4LCJleHAiOjE2Njk5MjMxMDgsImF1ZCI6Ijk1cnR2cGxuY3p1Y25sZ2llNm1qdXUyaWI3Z29ncXoyIn0.uY_NWGcfDg5j80MU2L2RIPQobu-9kyBzhd6eg8E367I",
"expiresIn": 1200,
"scope": [
"account:read",
"account:write",
"user:read",
"user:write",
"billing:read",
"billing:write",
"files:read",
"files:write",
"videos",
"images"
]
}
Account API
Get account info
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/account", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url https://api.sirv.com/v2/account \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/account",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/account");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/account")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/account",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/account")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/account")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/account");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/account"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to get information about the account, including its CDN URL; account name; additional domains; remote fetching status; date created and more.
Query string
None
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:49 GMT
< content-type: application/json; charset=utf-8
< content-length: 661
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6897
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"dateCreated": "2014-10-14T14:15:18.580Z",
"alias": "demo",
"fileSizeLimit": 50000000,
"fetching": {
"enabled": false,
"type": "http",
"http": {
"auth": {
"enabled": false
},
"url": "https://somesite.com/folder/"
},
"maxFilesize": 2097152
},
"minify": {
"enabled": false
},
"cdnTempURL": "demo.sirv.com",
"cdnURL": "demo.sirv.com",
"aliases": {
"demo": {
"prefix": "/",
"cdn": true
},
"anotherdemo": {
"prefix": "/",
"cdn": true
},
"demo-cdntest": {
"prefix": "/"
},
"demo-jwt": {
"prefix": "/",
"cdn": true
}
}
}
Get API limits
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/account/limits", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url https://api.sirv.com/v2/account/limits \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/account/limits",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/account/limits");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/account/limits")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/account/limits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/account/limits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/account/limits")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/account/limits");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/account/limits"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this method to check the allowed number of API requests and the number of requests used in the past 60 minutes.
Query string
None
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:50 GMT
< content-type: application/json; charset=utf-8
< content-length: 2892
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6893
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< vary: accept-encoding
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"s3:global": {
"count": 0,
"limit": 7000,
"remaining": 7000,
"reset": 1595076350
},
"s3:PUT": {
"count": 0,
"limit": 2000,
"remaining": 2000,
"reset": 1595076350
},
"s3:GET": {
"count": 0,
"limit": 3000,
"remaining": 3000,
"reset": 1595076350
},
"s3:DELETE": {
"count": 0,
"limit": 3000,
"remaining": 3000,
"reset": 1595076350
},
"rest:global": {
"count": 107,
"limit": 7000,
"remaining": 6893,
"reset": 1595075478
},
"rest:post:files:search": {
"count": 3,
"limit": 1000,
"remaining": 997,
"reset": 1595075483
},
"rest:post:files:search:scroll": {
"count": 0,
"limit": 2000,
"remaining": 2000,
"reset": 1595076350
},
"rest:post:files:video2spin": {
"count": 3,
"limit": 200,
"remaining": 197,
"reset": 1595075483
},
"rest:post:files:spin2video": {
"count": 3,
"limit": 200,
"remaining": 197,
"reset": 1595075486
},
"rest:post:files:fetch": {
"count": 3,
"limit": 2000,
"remaining": 1997,
"reset": 1595075492
},
"rest:post:files:upload": {
"count": 3,
"limit": 2000,
"remaining": 1997,
"reset": 1595075494
},
"rest:post:files:delete": {
"count": 3,
"limit": 3000,
"remaining": 2997,
"reset": 1595075495
},
"rest:post:account": {
"count": 4,
"limit": 50,
"remaining": 46,
"reset": 1595075478
},
"rest:post:account:fetching": {
"count": 0,
"limit": 50,
"remaining": 50,
"reset": 1595076350
},
"rest:get:stats:http": {
"count": 3,
"limit": 100,
"remaining": 97,
"reset": 1595075480
},
"rest:get:stats:storage": {
"count": 3,
"limit": 100,
"remaining": 97,
"reset": 1595075481
},
"rest:post:account:new": {
"count": 0,
"limit": 5,
"remaining": 5,
"reset": 1595076350
},
"rest:post:user:accounts": {
"count": 0,
"limit": 20,
"remaining": 20,
"reset": 1595076350
},
"rest:get:rest:credentials": {
"count": 0,
"limit": 50,
"remaining": 50,
"reset": 1595076350
},
"rest:post:video:toSpin": {
"count": 0,
"limit": 400,
"remaining": 400,
"reset": 1595076350
},
"rest:post:upload:toSirv": {
"count": 0,
"limit": 2000,
"remaining": 2000,
"reset": 1595076350
},
"ftp:global": {
"count": 0,
"limit": 10000,
"remaining": 10000,
"reset": 1595076350
},
"ftp:STOR": {
"count": 0,
"limit": 2000,
"remaining": 2000,
"reset": 1595076350
},
"ftp:RETR": {
"count": 0,
"limit": 3000,
"remaining": 3000,
"reset": 1595076350
},
"ftp:DELE": {
"count": 0,
"limit": 3000,
"remaining": 3000,
"reset": 1595076350
},
"fetch:file": {
"count": 1,
"limit": 2000,
"remaining": 1999,
"reset": 1595075492
}
}
Get storage info
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/account/storage", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url https://api.sirv.com/v2/account/storage \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/account/storage",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/account/storage");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/account/storage")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/account/storage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/account/storage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/account/storage")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/account/storage");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/account/storage"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this to check the current storage usage of an account. It will also return the total allowed storage; any extra storage provided; the temporary 30-day burstable storage allowance; the total files stored. If the account has exceeded its storage allowance, it will state the when that happened. If the account is one of a multi-account group, it will show the total storage used by all accounts.
Query string
None
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:50 GMT
< content-type: application/json; charset=utf-8
< content-length: 139
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6895
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 51916252571,
"files": 73143,
"quotaExceededDate": null
}
Get users
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/account/users", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url https://api.sirv.com/v2/account/users \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/account/users",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/account/users");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/account/users")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/account/users",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/account/users")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/account/users")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/account/users");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/account/users"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to get a list of all users of an account. It will return a list of user IDs and their roles. If you need a users email address, the user ID can be used to obtain it.
Query string
None
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:50 GMT
< content-type: application/json; charset=utf-8
< content-length: 833
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6894
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
[
{
"role": "primaryOwner",
"userId": "************************"
},
{
"role": "owner",
"userId": "************************"
},
{
"role": "owner",
"userId": "************************"
},
{
"role": "contributor",
"userId": "************************"
},
{
"role": "admin",
"userId": "************************"
},
{
"role": "owner",
"userId": "************************"
},
{
"role": "user",
"userId": "************************"
},
{
"role": "user",
"userId": "************************"
},
{
"role": "user",
"userId": "************************"
},
{
"role": "contributor",
"userId": "************************"
},
{
"role": "viewer",
"userId": "************************"
}
]
Get billing info
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/billing/plan", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url https://api.sirv.com/v2/billing/plan \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/billing/plan",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/billing/plan");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/billing/plan")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/billing/plan",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/billing/plan")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/billing/plan")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/billing/plan");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/billing/plan"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to get all the billing plan information of an account, including price, storage and transfer allowances.
Query string
None
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:51 GMT
< content-type: application/json; charset=utf-8
< content-length: 294
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6891
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"dateActive": "2017-05-31T00:00:00.000Z",
"id": "Business_5_v2",
"period": "month",
"name": "Business 5",
"description": "The complete set of features, with large allowances and no branding",
"price": {
"month": 19,
"year": 209,
"quarter": 57
},
"storage": 1000000000,
"burstableStorage": 5000000000
}
Update account info
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
payload = "{\"fetching\":{\"enabled\":false}}"
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/account", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url https://api.sirv.com/v2/account \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json' \
--data '{"fetching":{"enabled":false}}'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/account",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\"fetching\":{\"enabled\":false}}");
req.end();
var data = "{\"fetching\":{\"enabled\":false}}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/account");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/account")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.body("{\"fetching\":{\"enabled\":false}}")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/account",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"fetching\":{\"enabled\":false}}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/account")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
request.body = "{\"fetching\":{\"enabled\":false}}"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let postData = NSData(data: "{"fetching":{"enabled":false}}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/account")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/account");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"fetching\":{\"enabled\":false}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/account"
payload := strings.NewReader("{\"fetching\":{\"enabled\":false}}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this method to change the account options. You can enable or disable JS/CSS file minification. You can also enable/disable automatic fetching via HTTP or S3 from a remote location.
Query string
None
Body payload
Example:
{
"fetching": {
"enabled": false
}
}
JSON Schema:
{
"type": "object",
"properties": {
"minify": {
"type": "object",
"properties": {
"enabled": {
"description": "Enable or disable automatic minification of JS/CSS files",
"type": "boolean"
}
},
"additionalProperties": false,
"patterns": [],
"required": [
"enabled"
]
},
"fetching": {
"type": "object",
"properties": {
"enabled": {
"examples": [
false
],
"example": false,
"type": "boolean"
},
"type": {
"oneOf": [
{
"enum": [
"http",
"s3"
],
"type": "string"
}
]
},
"http": {
"oneOf": [
{
"type": "object",
"properties": {
"auth": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"username": {
"oneOf": [
{
"type": "string"
}
]
},
"password": {
"oneOf": [
{
"type": "string"
}
]
}
},
"additionalProperties": false,
"patterns": [],
"required": [
"enabled"
]
},
"url": {
"type": "string",
"format": "uri"
}
},
"additionalProperties": false,
"patterns": [],
"required": [
"url"
]
}
]
},
"s3": {
"oneOf": [
{
"type": "object",
"properties": {
"endpoint": {
"type": "string"
},
"accessKeyId": {
"type": "string"
},
"secretAccessKey": {
"type": "string"
},
"bucket": {
"type": "string"
},
"prefix": {
"type": "string"
},
"forcePathStyle": {
"type": "boolean"
}
},
"additionalProperties": false,
"patterns": [],
"required": [
"accessKeyId",
"secretAccessKey",
"bucket"
]
}
]
}
},
"additionalProperties": false,
"patterns": [],
"required": [
"enabled"
]
},
"aliases": {
"type": "object",
"properties": {},
"additionalProperties": false,
"patterns": [
{
"rule": {
"type": "object",
"properties": {
"cdn": {
"type": "boolean"
},
"prefix": {
"type": "string"
},
"defaultProfile": {
"type": "string"
}
},
"additionalProperties": false,
"patterns": []
}
}
]
}
},
"additionalProperties": false,
"patterns": []
}
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:50 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 50
< x-ratelimit-remaining: 46
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:post:account
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000
/ no response body: HTTP status 200 means SUCCESS /
List or search account events
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
payload = "{\"module\":\"fetching\"}"
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/account/events/search", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url https://api.sirv.com/v2/account/events/search \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json' \
--data '{"module":"fetching"}'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/account/events/search",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\"module\":\"fetching\"}");
req.end();
var data = "{\"module\":\"fetching\"}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/account/events/search");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/account/events/search")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.body("{\"module\":\"fetching\"}")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/account/events/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"module\":\"fetching\"}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/account/events/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
request.body = "{\"module\":\"fetching\"}"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let postData = NSData(data: "{"module":"fetching"}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/account/events/search")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/account/events/search");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"module\":\"fetching\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/account/events/search"
payload := strings.NewReader("{\"module\":\"fetching\"}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
List all events triggered for account.
Query string
None
Body payload
Example:
{
"module": "fetching"
}
JSON Schema:
{
"type": "object",
"properties": {
"module": {
"examples": [
"fetching"
],
"example": "fetching",
"type": "string",
"maxLength": 64
},
"type": {
"type": "string",
"maxLength": 64
},
"filename": {
"type": "string",
"maxLength": 1000
},
"level": {
"enum": [
"error",
"warn",
"info"
],
"type": "string"
}
},
"additionalProperties": false,
"patterns": []
}
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:51 GMT
< content-type: application/json; charset=utf-8
< content-length: 4112
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6892
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< vary: accept-encoding
< server: Sirv.API
< strict-transport-security: max-age=31536000
[
{
"module": "fetching",
"type": "http",
"level": "error",
"filename": "/REST API Examples/missing.jpg",
"fetching": {
"url": "https://demo.sirv.com/missing.jpg",
"statusCode": 404,
"maxFilesize": 2097152,
"contentLength": "4140",
"error": "Request not successful: expected status code 200 but got 404"
},
"initiator": {
"type": "api",
"remoteAddr": "176.105.166.4",
"date": "2020-07-18T11:31:32.229Z"
},
"notify": true,
"_seen": false,
"_submitted": "2020-07-18T11:31:32.612Z",
"_accountId": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"_id": "8fbb11a7dd77f7f64337e581ccbce2d62fc7cda0"
}
]
Mark account event(s) as seen
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
payload = "[\"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba\",\"199cf48046964f8567fe49e22107c4c5d27271e7\"]"
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/account/events/seen", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url https://api.sirv.com/v2/account/events/seen \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json' \
--data '["f1f5d68ef232e5d27d10f28bcef836efbb7cdeba","199cf48046964f8567fe49e22107c4c5d27271e7"]'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/account/events/seen",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("[\"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba\",\"199cf48046964f8567fe49e22107c4c5d27271e7\"]");
req.end();
var data = "[\"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba\",\"199cf48046964f8567fe49e22107c4c5d27271e7\"]";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/account/events/seen");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/account/events/seen")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.body("[\"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba\",\"199cf48046964f8567fe49e22107c4c5d27271e7\"]")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/account/events/seen",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "[\"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba\",\"199cf48046964f8567fe49e22107c4c5d27271e7\"]",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/account/events/seen")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
request.body = "[\"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba\",\"199cf48046964f8567fe49e22107c4c5d27271e7\"]"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let postData = NSData(data: "["f1f5d68ef232e5d27d10f28bcef836efbb7cdeba","199cf48046964f8567fe49e22107c4c5d27271e7"]".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/account/events/seen")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/account/events/seen");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "[\"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba\",\"199cf48046964f8567fe49e22107c4c5d27271e7\"]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/account/events/seen"
payload := strings.NewReader("[\"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba\",\"199cf48046964f8567fe49e22107c4c5d27271e7\"]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Add seen
flag for specified account event(s)
Query string
None
Body payload
Example:
[
"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba",
"199cf48046964f8567fe49e22107c4c5d27271e7"
]
JSON Schema:
{
"examples": [
[
"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba",
"199cf48046964f8567fe49e22107c4c5d27271e7"
]
],
"example": [
"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba",
"199cf48046964f8567fe49e22107c4c5d27271e7"
],
"type": "array",
"maxItems": 100,
"items": {
"type": "string"
}
}
Response
Example response:
< HTTP/1.1 200
< date: Tue, 21 Jul 2020 09:17:41 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6982
< x-ratelimit-reset: 1595326565
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000
/ no response body: HTTP status 200 means SUCCESS /
User API
Get user info
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url 'https://api.sirv.com/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to get information about a user, including their name, email and S3 key.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
userId | string | Gt6ljl1AxwmtGBIHX0WBo3qKdtK |
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:52 GMT
< content-type: application/json; charset=utf-8
< content-length: 188
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6890
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"email": "restapi@sirv.com",
"firstName": "Rest",
"lastName": "Api",
"dateCreated": "2020-07-17T13:55:10.462Z",
"s3Secret": "****************************"
}
Statistics API
Get transfer stats
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url 'https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to check how much data was transferred per day during a certain period (date from/to). The request returns aggregated HTTP log data.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
from | date | Default: 1 month ago, rounded to start of day | 2020-07-01T00:00:00.000 |
to | date | Default: now, rounded to end of day | 2020-07-05T00:00:00.000 |
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:52 GMT
< content-type: application/json; charset=utf-8
< content-length: 470
< connection: close
< x-ratelimit-limit: 100
< x-ratelimit-remaining: 96
< x-ratelimit-reset: 1595075480
< x-ratelimit-type: rest:get:stats:http
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"1593561600000": {
"total": {
"count": 47619,
"size": 1440222650
}
},
"1593648000000": {
"total": {
"count": 75944,
"size": 2078130246
}
},
"1593734400000": {
"total": {
"count": 44928,
"size": 1248801543
}
},
"1593820800000": {
"total": {
"count": 26472,
"size": 727094151
}
},
"1593907200000": {
"total": {
"count": 30528,
"size": 877886049
}
}
}
Get spins views
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url 'https://api.sirv.com/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to get spins views stats over a certain period (date from/to). Date range is limited to 5 days.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
from | date | Default: 1 day ago | 2020-07-01T00:00:00.000 |
to | date | Default: now | 2020-07-05T00:00:00.000 |
alias | string | Filter by account name (alias) |
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:53 GMT
< content-type: application/json; charset=utf-8
< content-length: 4286915
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6887
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< vary: accept-encoding
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
[
{
"@timestamp": "2020-07-04T04:54:53.632Z",
"referer": "https://sirv.com/help/articles/360-photography-photoshop/",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36",
"user_agent_parsed": {
"name": "Chrome",
"os": "Windows 10",
"os_name": "Windows",
"os_major": "10",
"device": "Other",
"major": "83",
"minor": "0",
"patch": "4103",
"build": "116"
},
"referer_proto": "https",
"referer_host": "sirv.com",
"referer_uripath": "/help/articles/360-photography-photoshop/",
"event": {
"origin": "/bag/bag.spin?autospin=infinite",
"type": "spin",
"name": "viewerReady",
"data": {
"rows": 1,
"columns": 16,
"viewerSize": {
"width": 354,
"height": 354
}
}
},
"geoip": {
"country_code2": "IN",
"country_name": "India",
"region_name": "10",
"timezone": "Asia/Calcutta",
"real_region_name": "Haryana"
}
}
]
Get storage stats
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url 'https://api.sirv.com/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to check the total amount of data stored on a given day or each day over a certain period.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
from | date | Default: 1 month ago, rounded to start of day | 2020-07-01T00:00:00.000 |
to | date | Default: now, rounded to end of day | 2020-07-05T00:00:00.000 |
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:53 GMT
< content-type: application/json; charset=utf-8
< content-length: 2786
< connection: close
< x-ratelimit-limit: 100
< x-ratelimit-remaining: 96
< x-ratelimit-reset: 1595075481
< x-ratelimit-type: rest:get:stats:storage
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< vary: accept-encoding
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"1593734400000": {
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 49238608587,
"files": 65400,
"quotaExceededDate": null
},
"1593561600000": {
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 49238608587,
"files": 65413,
"quotaExceededDate": null
},
"1593907200000": {
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 49404765599,
"files": 64931,
"quotaExceededDate": null
},
"1593820800000": {
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 49360152901,
"files": 65357,
"quotaExceededDate": null
},
"1593993600000": {
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 49404765599,
"files": 64931,
"quotaExceededDate": null
},
"1593648000000": {
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 49238608587,
"files": 65405,
"quotaExceededDate": null
},
"1594339200000": {
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 49404768387,
"files": 64836,
"quotaExceededDate": null
},
"1594166400000": {
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 49404768387,
"files": 64932,
"quotaExceededDate": null
},
"1594252800000": {
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 49404768387,
"files": 64929,
"quotaExceededDate": null
},
"1594080000000": {
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 49404765599,
"files": 64931,
"quotaExceededDate": null
},
"1594425600000": {
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 49404768387,
"files": 64836,
"quotaExceededDate": null
},
"1594684800000": {
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 51853129932,
"files": 73732,
"quotaExceededDate": null
},
"1594598400000": {
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 49921058176,
"files": 64536,
"quotaExceededDate": null
},
"1594512000000": {
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 49428159099,
"files": 63605,
"quotaExceededDate": null
},
"1594771200000": {
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 51841192248,
"files": 73785,
"quotaExceededDate": null
},
"1594857600000": {
"plan": 100000000000,
"burstable": 500000000000,
"extra": 0,
"used": 51850463184,
"files": 73786,
"quotaExceededDate": null
}
}
Files API
Get approval flag
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url 'https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to get the file approval tag and optional comment for a file. Used as part of an image review and approval process.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
filename | string | /REST API Examples/blue-lake.jpg |
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:06 GMT
< content-type: application/json; charset=utf-8
< content-length: 100
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6873
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"datetime": "2020-07-18T11:45:10.567Z",
"approved": false,
"comment": "It looks too cold!"
}
Get meta description
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url 'https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to check the meta description of a file or folder. For images, this is the meta field that is used for showing alt tags on images.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
filename | string | /REST API Examples/blue-lake.jpg |
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:05 GMT
< content-type: application/json; charset=utf-8
< content-length: 46
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6880
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"description": "Blue Lake in the Winter"
}
Get product meta
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url 'https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to get the product meta fields for an image. This can be used by retailers for organizing images into product groups for an ecommerce store.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
filename | string | /REST API Examples/blue-lake.jpg |
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:07 GMT
< content-type: application/json; charset=utf-8
< content-length: 124
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6867
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"id": "LLBB77",
"name": "Blue Lake Card",
"brand": "BLUE LAKE LLC",
"category1": "Cards",
"category2": "Lakes"
}
Get file meta tags
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url 'https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to get all the meta tags of a file or folder.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
filename | string | /REST API Examples/blue-lake.jpg |
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:06 GMT
< content-type: application/json; charset=utf-8
< content-length: 81
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6876
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"tags": [
"blue",
"lake",
"winter",
"cold",
"water"
]
}
Get meta title
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url 'https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to check the meta title of a file or folder.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
filename | string | /REST API Examples/blue-lake.jpg |
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:05 GMT
< content-type: application/json; charset=utf-8
< content-length: 26
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6878
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"title": "Blue Lake"
}
Get folder options
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/files/options?filename=%2FREST%20API%20Examples", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url 'https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/options?filename=%2FREST%20API%20Examples",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to check the options of a folder. It will tell you the settings for spin scanning, spin naming, public listing and folder locking (Enterprise accounts only).
Query string
Parameter | Type | Description | Example |
---|---|---|---|
filename | string | /REST API Examples | |
withInherited | boolean | Include options inherited from parent folders |
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:04 GMT
< content-type: application/json; charset=utf-8
< content-length: 48
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6882
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"scanSpins": true,
"allowListing": false
}
Read folder contents
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/files/readdir?dirname=%2FREST%20API%20Examples", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url 'https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/readdir?dirname=%2FREST%20API%20Examples",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to get a list of all the files/folders within a folder. It will return the filename, mimetype, content type and file size. It will also return any folders that exist. A page of up to 100 results will be returned - use the 'continuation' field to request additional pages.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
dirname | string | /REST API Examples | |
continuation | string | Send it to get next page of results |
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Thu, 23 Jun 2022 17:17:35 GMT
< content-type: application/json; charset=utf-8
< content-length: 2250
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6967
< x-ratelimit-reset: 1656008218
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< vary: accept-encoding
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"contents": [
{
"filename": "aurora3.jpg",
"mtime": "2020-11-18T19:55:13.459Z",
"contentType": "image/webp",
"size": 201846,
"isDirectory": false,
"meta": {
"width": 2500,
"height": 1667,
"duration": 0
}
},
{
"filename": "aurora.jpg",
"mtime": "2022-06-23T17:17:32.585Z",
"contentType": "image/webp",
"size": 201846,
"isDirectory": false,
"meta": {
"width": 2500,
"height": 1667,
"duration": 0
}
},
{
"filename": "birdbath.jpg",
"mtime": "2020-07-17T13:31:39.385Z",
"contentType": "image/jpeg",
"size": 73151,
"isDirectory": false,
"meta": {
"width": 620,
"height": 372,
"duration": 0
}
},
{
"filename": "video.mp4",
"mtime": "2020-07-17T15:35:20.375Z",
"contentType": "video/mp4",
"size": 12860989,
"isDirectory": false,
"meta": {
"width": 1372,
"height": 1080,
"duration": 33.434
}
},
{
"filename": "video",
"mtime": "2020-07-17T15:36:52.477Z",
"size": 0,
"isDirectory": true,
"meta": {}
},
{
"filename": "uploaded.txt",
"mtime": "2022-06-23T17:17:34.898Z",
"contentType": "text/plain",
"size": 0,
"isDirectory": false,
"meta": {}
},
{
"filename": "coin",
"mtime": "2020-07-17T13:31:08.833Z",
"size": 0,
"isDirectory": true,
"meta": {}
},
{
"filename": "copies",
"mtime": "2020-12-09T09:40:13.049Z",
"size": 0,
"isDirectory": true,
"meta": {}
},
{
"filename": "blue-lake.jpg",
"mtime": "2020-07-17T13:31:39.450Z",
"contentType": "image/jpeg",
"size": 587065,
"isDirectory": false,
"meta": {
"width": 1578,
"height": 1002,
"duration": 0
}
},
{
"filename": "aurora-copy.jpg",
"mtime": "2022-06-23T17:17:35.452Z",
"contentType": "image/webp",
"size": 201846,
"isDirectory": false,
"meta": {
"width": 2500,
"height": 1667,
"duration": 0
}
}
]
}
Get file info
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/files/stat?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url 'https://api.sirv.com/v2/files/stat?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/stat?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/files/stat?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/stat?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/stat?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/stat?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/stat?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/stat?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/stat?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to get information about a file, including created time, modified time, content type and size. It returns Unix information.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
filename | string | /REST API Examples/blue-lake.jpg |
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:08 GMT
< content-type: application/json; charset=utf-8
< content-length: 227
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6865
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"mtime": "2020-07-17T13:31:39.450Z",
"ctime": "2020-07-17T13:31:39.347Z",
"contentType": "image/jpeg",
"size": 587065,
"isDirectory": false,
"meta": {
"width": 1578,
"height": 1002,
"duration": 0
}
}
Download file
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("GET", "/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url 'https://api.sirv.com/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.sirv.com/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to download a single file from an account.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
filename | string | /REST API Examples/uploaded.txt |
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Mon, 09 Aug 2021 13:31:31 GMT
< content-type: text/plain; charset=utf-8
< content-length: 0
< connection: close
< last-modified: Mon, 09 Aug 2021 13:31:31 GMT
< cache-control: max-age=86400
< etag: "61112e33-0"
< server: Sirv.API
< expires: Tue, 10 Aug 2021 13:31:31 GMT
< strict-transport-security: max-age=31536000
< accept-ranges: bytes
/ no response body: HTTP status 200 means SUCCESS /
Copy file
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url 'https://api.sirv.com/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to copy a single file.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
from | string | /REST API Examples/aurora.jpg | |
to | string | /REST API Examples/aurora-copy.jpg |
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:07 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6869
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000
/ no response body: HTTP status 200 means SUCCESS /
Delete file or empty folder
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url 'https://api.sirv.com/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to delete a single file or an empty folder.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
filename | string | /REST API Examples/aurora-copy.jpg |
Body payload
None
Response
Example response:
< HTTP/1.1 200
< date: Thu, 01 Dec 2022 19:12:27 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 3000
< x-ratelimit-remaining: 2999
< x-ratelimit-reset: 1669925546
< x-ratelimit-type: rest:post:files:delete
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000
/ no response body: HTTP status 200 means SUCCESS /
Fetch URL
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
payload = "[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]"
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/files/fetch", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url https://api.sirv.com/v2/files/fetch \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json' \
--data '[{"url":"https://demo.sirv.com/aurora.jpg","filename":"/REST API Examples/aurora.jpg"},{"url":"https://demo.sirv.com/missing.jpg","filename":"/REST API Examples/missing.jpg"}]'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/fetch",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]");
req.end();
var data = "[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/files/fetch");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/fetch")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.body("[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/fetch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "[{\"url</span>":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url</span>":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/fetch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
request.body = "[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let postData = NSData(data: "[{"url":"https://demo.sirv.com/aurora.jpg","filename":"/REST API Examples/aurora.jpg"},{"url":"https://demo.sirv.com/missing.jpg","filename":"/REST API Examples/missing.jpg"}]".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/fetch")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/fetch");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/fetch"
payload := strings.NewReader("[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to fetch a file(s) from a URL via HTTP and save it to your Sirv account. This can be any URL, either public or private (via HTTP authentication). In the url parameter, enter the full URL of the remote file. In the filename parameter, enter the folder path and filename where it should be saved e.g. /path/to/folder/new-filename.jpg. If the folder path does not already exist in your Sirv account new folder(s) will be created.
Query string
None
Body payload
Example:
[
{
"url": "https://demo.sirv.com/aurora.jpg",
"filename": "/REST API Examples/aurora.jpg"
},
{
"url": "https://demo.sirv.com/missing.jpg",
"filename": "/REST API Examples/missing.jpg"
}
]
JSON Schema:
{
"examples": [
[
{
"url": "https://demo.sirv.com/aurora.jpg",
"filename": "/REST API Examples/aurora.jpg"
},
{
"url": "https://demo.sirv.com/missing.jpg",
"filename": "/REST API Examples/missing.jpg"
}
]
],
"example": [
{
"url": "https://demo.sirv.com/aurora.jpg",
"filename": "/REST API Examples/aurora.jpg"
},
{
"url": "https://demo.sirv.com/missing.jpg",
"filename": "/REST API Examples/missing.jpg"
}
],
"type": "array",
"maxItems": 20,
"items": {
"type": "object",
"properties": {
"url": {
"type": "string",
"maxLength": 1024
},
"filename": {
"type": "string",
"pattern": "^\\/",
"maxLength": 1024
},
"auth": {
"type": "object",
"properties": {
"username": {
"type": "string",
"maxLength": 256
},
"password": {
"type": "string",
"maxLength": 256
}
},
"additionalProperties": false,
"patterns": []
},
"wait": {
"type": "boolean"
}
},
"additionalProperties": false,
"patterns": [],
"required": [
"url",
"filename"
]
}
}
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:04 GMT
< content-type: application/json; charset=utf-8
< content-length: 9882
< connection: close
< x-ratelimit-limit: 2000
< x-ratelimit-remaining: 1996
< x-ratelimit-reset: 1595075492
< x-ratelimit-type: rest:post:files:fetch
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< vary: accept-encoding
< server: Sirv.API
< strict-transport-security: max-age=31536000
[
{
"filename": "/REST API Examples/aurora.jpg",
"success": true,
"attempted": false,
"attempts": [
{
"url": "https://demo.sirv.com/aurora.jpg",
"initiator": {
"type": "api",
"remoteAddr": "176.105.166.4",
"date": "2020-07-17T15:47:35.316Z"
},
"statusCode": 200,
"headers": {
"result": {
"version": "HTTP/1.1",
"code": 200,
"reason": "OK"
},
"Date": "Fri, 17 Jul 2020 15:47:36 GMT",
"Content-Type": "image/webp",
"Content-Length": "201846",
"Connection": "keep-alive",
"Last-Modified": "Fri, 17 Jul 2020 15:47:36 GMT",
"ETag": "\"5f11c818-31476\"",
"Server": "Sirv.Imagination",
"X-Sirv-Server": "c1-extra1-fireball-13",
"X-Sirv-Cache": "MISS",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*",
"Expires": "Sun, 16 Aug 2020 15:47:36 GMT",
"Cache-Control": "max-age=2592000",
"X-Sirv-Meta-Width": "2500",
"X-Sirv-Meta-Height": "1667",
"X-Sirv-Shard": "c1-riak1",
"X-Account-Id": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"X-File-VersionId": "5evxYG8lnBgeA7cGBRTZzq7JQolRYviN:0",
"X-Account-Serial": "2020-06-15T19:18:53.901Z",
"Accept-Ranges": "bytes"
},
"timing": {
"ns": 0.007514,
"connect": 0.007912,
"start": 0.48724,
"total": 0.489622
},
"date": "2020-07-17T15:47:36.712Z"
}
],
"retryAfter": "2020-07-18T15:47:36.712Z"
},
{
"filename": "/REST API Examples/missing.jpg",
"success": false,
"attempted": false,
"attempts": [
{
"url": "https://demo.sirv.com/missing.jpg",
"initiator": {
"type": "api",
"remoteAddr": "176.105.166.4",
"date": "2020-07-18T08:35:51.026Z"
},
"statusCode": 404,
"headers": {
"result": {
"version": "HTTP/1.1",
"code": 404,
"reason": "Not Found"
},
"Date": "Sat, 18 Jul 2020 08:35:52 GMT",
"Content-Type": "text/html; charset=utf-8",
"Content-Length": "4140",
"Connection": "keep-alive",
"Vary": "Accept-Encoding",
"X-Account-Id": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"X-Account-Serial": "2020-06-15T19:18:53.901Z",
"ETag": "W/\"102c-wKpRt+Cg9Cnw/NpTSkF5+w\"",
"X-Sirv-Cache": "MISS",
"Server": "Sirv.Imagination",
"X-Sirv-Server": "c1-extra1-fireball-15",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*"
},
"timing": {
"ns": 0.018986,
"connect": 0.019303,
"start": 0.103774,
"total": 0.103829
},
"error": {
"name": "Error",
"message": "Request not successful: expected status code 200 but got 404"
},
"date": "2020-07-18T08:35:52.089Z"
}
],
"retryAfter": "2020-07-18T12:07:32.613Z"
}
]
Get JWT protected URL
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
payload = "{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}"
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/files/jwt", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url https://api.sirv.com/v2/files/jwt \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json' \
--data '{"filename":"/REST API Examples/aurora.jpg","key":"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq","alias":"demo-jwt","secureParams":{"w":300,"h":300},"expiresIn":300}'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/jwt",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}");
req.end();
var data = "{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/files/jwt");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/jwt")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.body("{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/jwt",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"filename</span>":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/jwt")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
request.body = "{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let postData = NSData(data: "{"filename":"/REST API Examples/aurora.jpg","key":"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq","alias":"demo-jwt","secureParams":{"w":300,"h":300},"expiresIn":300}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/jwt")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/jwt");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/jwt"
payload := strings.NewReader("{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to generate a secure file URL, protected with JWT (JSON Web Token).
Query string
None
Body payload
Example:
{
"filename": "/REST API Examples/aurora.jpg",
"key": "cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq",
"alias": "demo-jwt",
"secureParams": {
"w": 300,
"h": 300
},
"expiresIn": 300
}
JSON Schema:
{
"type": "object",
"properties": {
"filename": {
"examples": [
"/REST API Examples/aurora.jpg"
],
"example": "/REST API Examples/aurora.jpg",
"type": "string",
"pattern": "^\\/",
"maxLength": 1024
},
"key": {
"description": "Specify JWT secret",
"examples": [
"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq"
],
"example": "cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq",
"type": "string"
},
"alias": {
"description": "Specify account alias if your account has multiple aliases",
"examples": [
"demo-jwt"
],
"example": "demo-jwt",
"type": "string"
},
"insecureParams": {
"type": "object",
"properties": {},
"additionalProperties": true,
"patterns": []
},
"secureParams": {
"examples": [
{
"w": 300,
"h": 300
}
],
"example": {
"w": 300,
"h": 300
},
"type": "object",
"properties": {},
"additionalProperties": true,
"patterns": []
},
"expiresIn": {
"description": "Token expiration time in seconds",
"examples": [
300
],
"example": 300,
"type": "number"
}
},
"additionalProperties": false,
"patterns": [],
"required": [
"filename",
"key",
"expiresIn"
]
}
Response
Example response:
< HTTP/1.1 200
< date: Sat, 21 Nov 2020 07:44:30 GMT
< content-type: application/json; charset=utf-8
< content-length: 286
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6929
< x-ratelimit-reset: 1605948149
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"url": "https://demo-jwt.sirv.com/REST API Examples/aurora.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcmdzIjp7InciOjMwMCwiaCI6MzAwfSwiaWF0IjoxNjA1OTQ0NjcwLCJleHAiOjE2MDU5NDQ5NzAsImF1ZCI6Ii9SRVNUIEFQSSBFeGFtcGxlcy9hdXJvcmEuanBnIn0.c9FlTRZw_-t3WcMc0FPOhINrDZGrLKH2DuUn2H16yq4"
}
Set approval flag
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
payload = "{\"approved\":false,\"comment\":\"It looks too cold!\"}"
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url 'https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json' \
--data '{"approved":false,"comment":"It looks too cold!"}'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\"approved\":false,\"comment\":\"It looks too cold!\"}");
req.end();
var data = "{\"approved\":false,\"comment\":\"It looks too cold!\"}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.body("{\"approved\":false,\"comment\":\"It looks too cold!\"}")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"approved</span>":false,\"comment\":\"It looks too cold!\"}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
request.body = "{\"approved\":false,\"comment\":\"It looks too cold!\"}"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let postData = NSData(data: "{"approved":false,"comment":"It looks too cold!"}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"approved\":false,\"comment\":\"It looks too cold!\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"
payload := strings.NewReader("{\"approved\":false,\"comment\":\"It looks too cold!\"}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to set the file approval tag (approved or not) and an optional comment. Used as part of an image review and approval process.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
filename | string | /REST API Examples/blue-lake.jpg |
Body payload
Example:
{
"approved": false,
"comment": "It looks too cold!"
}
JSON Schema:
{
"type": "object",
"properties": {
"approved": {
"examples": [
false
],
"example": false,
"type": "boolean"
},
"comment": {
"examples": [
"It looks too cold!"
],
"example": "It looks too cold!",
"oneOf": [
{
"type": "string",
"maxLength": 256
}
]
}
},
"additionalProperties": false,
"patterns": [],
"required": [
"approved"
]
}
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:06 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6872
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000
/ no response body: HTTP status 200 means SUCCESS /
Set product meta
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
payload = "{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}"
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url 'https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json' \
--data '{"id":"LLBB77","name":"Blue Lake Card","brand":"BLUE LAKE LLC","category1":"Cards","category2":"Lakes"}'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}");
req.end();
var data = "{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.body("{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"id</span>":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
request.body = "{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let postData = NSData(data: "{"id":"LLBB77","name":"Blue Lake Card","brand":"BLUE LAKE LLC","category1":"Cards","category2":"Lakes"}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"
payload := strings.NewReader("{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to set product meta fields for an image. This can be used by retailers for organizing images into product groups for an ecommerce store.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
filename | string | /REST API Examples/blue-lake.jpg |
Body payload
Example:
{
"id": "LLBB77",
"name": "Blue Lake Card",
"brand": "BLUE LAKE LLC",
"category1": "Cards",
"category2": "Lakes"
}
JSON Schema:
{
"type": "object",
"properties": {
"id": {
"examples": [
"LLBB77"
],
"example": "LLBB77",
"type": "string",
"maxLength": 256
},
"name": {
"examples": [
"Blue Lake Card"
],
"example": "Blue Lake Card",
"type": "string",
"maxLength": 256
},
"brand": {
"examples": [
"BLUE LAKE LLC"
],
"example": "BLUE LAKE LLC",
"type": "string",
"maxLength": 256
},
"category1": {
"examples": [
"Cards"
],
"example": "Cards",
"type": "string",
"maxLength": 256
},
"category2": {
"examples": [
"Lakes"
],
"example": "Lakes",
"type": "string",
"maxLength": 256
}
},
"additionalProperties": false,
"patterns": []
}
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:08 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6866
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000
/ no response body: HTTP status 200 means SUCCESS /
Set meta description
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
payload = "{\"description\":\"Blue Lake in the Winter\"}"
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url 'https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json' \
--data '{"description":"Blue Lake in the Winter"}'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\"description\":\"Blue Lake in the Winter\"}");
req.end();
var data = "{\"description\":\"Blue Lake in the Winter\"}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.body("{\"description\":\"Blue Lake in the Winter\"}")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"description</span>":\"Blue Lake in the Winter\"}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
request.body = "{\"description\":\"Blue Lake in the Winter\"}"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let postData = NSData(data: "{"description":"Blue Lake in the Winter"}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"description\":\"Blue Lake in the Winter\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"
payload := strings.NewReader("{\"description\":\"Blue Lake in the Winter\"}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to set/change the meta description of a file or folder. For images, this is the meta field that is used for showing alt tags on images.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
filename | string | /REST API Examples/blue-lake.jpg |
Body payload
Example:
{
"description": "Blue Lake in the Winter"
}
JSON Schema:
{
"type": "object",
"properties": {
"description": {
"examples": [
"Blue Lake in the Winter"
],
"example": "Blue Lake in the Winter",
"type": "string"
}
},
"additionalProperties": false,
"patterns": [],
"required": [
"description"
]
}
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:05 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6879
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000
/ no response body: HTTP status 200 means SUCCESS /
Add file meta tags
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
payload = "{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}"
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url 'https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json' \
--data '{"tags":["blue","lake","winter","cold","water"]}'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}");
req.end();
var data = "{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.body("{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
request.body = "{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let postData = NSData(data: "{"tags":["blue","lake","winter","cold","water"]}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"
payload := strings.NewReader("{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to add a meta tag to a file or folder.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
filename | string | /REST API Examples/blue-lake.jpg |
Body payload
Example:
{
"tags": [
"blue",
"lake",
"winter",
"cold",
"water"
]
}
JSON Schema:
{
"type": "object",
"properties": {
"tags": {
"examples": [
[
"blue",
"lake",
"winter",
"cold",
"water"
]
],
"example": [
"blue",
"lake",
"winter",
"cold",
"water"
],
"type": "array",
"maxItems": 50,
"items": {
"type": "string"
}
}
},
"additionalProperties": false,
"patterns": [],
"required": [
"tags"
]
}
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:06 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6875
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000
/ no response body: HTTP status 200 means SUCCESS /
Set meta title
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
payload = "{\"title\":\"Blue Lake\"}"
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url 'https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json' \
--data '{"title":"Blue Lake"}'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\"title\":\"Blue Lake\"}");
req.end();
var data = "{\"title\":\"Blue Lake\"}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.body("{\"title\":\"Blue Lake\"}")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"title</span>":\"Blue Lake\"}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
request.body = "{\"title\":\"Blue Lake\"}"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let postData = NSData(data: "{"title":"Blue Lake"}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"title\":\"Blue Lake\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"
payload := strings.NewReader("{\"title\":\"Blue Lake\"}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to set the meta title of a file or folder.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
filename | string | /REST API Examples/blue-lake.jpg |
Body payload
Example:
{
"title": "Blue Lake"
}
JSON Schema:
{
"type": "object",
"properties": {
"title": {
"examples": [
"Blue Lake"
],
"example": "Blue Lake",
"type": "string"
}
},
"additionalProperties": false,
"patterns": [],
"required": [
"title"
]
}
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:05 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6877
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000
/ no response body: HTTP status 200 means SUCCESS /
Set folder options
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
payload = "{\"scanSpins\":true,\"allowListing\":false}"
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/files/options?filename=%2FREST%20API%20Examples", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url 'https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples' \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json' \
--data '{"scanSpins":true,"allowListing":false}'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/options?filename=%2FREST%20API%20Examples",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\"scanSpins\":true,\"allowListing\":false}");
req.end();
var data = "{\"scanSpins\":true,\"allowListing\":false}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.body("{\"scanSpins\":true,\"allowListing\":false}")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"scanSpins\":true,\"allowListing\":false}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
request.body = "{\"scanSpins\":true,\"allowListing\":false}"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let postData = NSData(data: "{"scanSpins":true,"allowListing":false}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"scanSpins\":true,\"allowListing\":false}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples"
payload := strings.NewReader("{\"scanSpins\":true,\"allowListing\":false}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to change the folder options. You can enable/disable spin scanning, change the spin naming convention and enable/disable publicly viewable folder listings.
Query string
Parameter | Type | Description | Example |
---|---|---|---|
filename | string | /REST API Examples |
Body payload
Example:
{
"scanSpins": true,
"allowListing": false
}
JSON Schema:
{
"type": "object",
"properties": {
"scanSpins": {
"examples": [
true
],
"example": true,
"type": "boolean"
},
"nameSpinsAfterFolder": {
"type": "boolean"
},
"allowListing": {
"examples": [
false
],
"example": false,
"type": "boolean"
}
},
"additionalProperties": false,
"patterns": []
}
Response
Example response:
< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:05 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6881
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000
/ no response body: HTTP status 200 means SUCCESS /
Search files
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
payload = "{\"query\":\"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash\",\"sort\":{\"filename.raw\":\"asc\"},\"from\":0,\"size\":5}"
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/files/search", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url https://api.sirv.com/v2/files/search \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json' \
--data '{"query":"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash","sort":{"filename.raw":"asc"},"from":0,"size":5}'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/search",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\"query\":\"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash\",\"sort\":{\"filename.raw\":\"asc\"},\"from\":0,\"size\":5}");
req.end();
var data = "{\"query\":\"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash\",\"sort\":{\"filename.raw\":\"asc\"},\"from\":0,\"size\":5}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/files/search");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/search")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.body("{\"query\":\"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash\",\"sort\":{\"filename.raw\":\"asc\"},\"from\":0,\"size\":5}")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"query</span>":\"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash\",\"sort\":{\"filename.raw\":\"asc\"},\"from\":0,\"size\":5}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
request.body = "{\"query\":\"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash\",\"sort\":{\"filename.raw\":\"asc\"},\"from\":0,\"size\":5}"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let postData = NSData(data: "{"query":"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\/.Trash","sort":{"filename.raw":"asc"},"from":0,"size":5}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/search")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/search");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"query\":\"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash\",\"sort\":{\"filename.raw\":\"asc\"},\"from\":0,\"size\":5}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/search"
payload := strings.NewReader("{\"query\":\"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash\",\"sort\":{\"filename.raw\":\"asc\"},\"from\":0,\"size\":5}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use this API method to search for files based on one or more criteria: file name; folder path; file extension; content type; created/modified time; or with some specific meta information.
Up to 1000 results can be returned. If you need more results, use the scroll API method.
Query string
None
Body payload
Example:
{
"query": "extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash",
"sort": {
"filename.raw": "asc"
},
"from": 0,
"size": 5
}
JSON Schema:
{
"type": "object",
"properties": {
"query": {
"examples": [
"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash"
],
"example": "extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash",
"type": "string",
"maxLength": 1024
},
"sort": {
"examples": [
{
"filename.raw": "asc"
}
],
"example": {
"filename.raw": "asc"
},
"type": "object",
"properties": {},
"additionalProperties": true,
"patterns": []
},
"from": {
"examples": [
0
],
"example": 0,
"type": "number",
"maximum": 1000
},
"size": {
"examples": [
5
],
"example": 5,
"type": "number",
"maximum": 100
},
"scroll": {
"description": "Start a scrolling search.",
"type": "boolean"
}
},
"additionalProperties": false,
"patterns": []
}
Response
Example response:
< HTTP/1.1 200
< date: Thu, 13 May 2021 08:21:31 GMT
< content-type: application/json; charset=utf-8
< content-length: 4441
< connection: close
< x-ratelimit-limit: 1000
< x-ratelimit-remaining: 999
< x-ratelimit-reset: 1620897691
< x-ratelimit-type: rest:post:files:search
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< vary: accept-encoding
< server: Sirv.API
< strict-transport-security: max-age=31536000
{
"hits": [
{
"_index": "sirvfs-v3",
"_type": "_doc",
"_id": "248e197b4546afd4da9ccdb2ee0d30cf844ecf44",
"_score": null,
"_routing": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"_source": {
"accountId": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"filename": "/REST API Examples/aurora-copy.jpg",
"dirname": "/REST API Examples",
"basename": "aurora-copy.jpg",
"extension": ".jpg",
"id": "RaxZM3sxunjRxsH7dUOU1KmBqASp3weH",
"ctime": "2021-05-12T09:30:08.895Z",
"mtime": "2021-05-12T09:30:09.806Z",
"size": 201846,
"contentType": "image/webp",
"meta": {
"width": 2500,
"height": 1667,
"format": "WEBP",
"duration": 0,
"EXIF": {
"ModifyDate": "2020-01-29T17:12:45Z"
}
}
},
"sort": [
"/REST API Examples/aurora-copy.jpg"
]
},
{
"_index": "sirvfs-v3",
"_type": "_doc",
"_id": "4b57cdf35a3568220bb9ad7a6f62f0048c8b4ae1",
"_score": null,
"_routing": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"_source": {
"accountId": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"filename": "/REST API Examples/aurora.jpg",
"dirname": "/REST API Examples",
"basename": "aurora.jpg",
"extension": ".jpg",
"id": "tkLbo0YuHJuBIEYj40lEUYRZZ8cLBGnF",
"ctime": "2020-07-17T13:31:39.348Z",
"mtime": "2021-05-12T09:30:05.386Z",
"size": 201846,
"contentType": "image/webp",
"meta": {
"width": 2500,
"height": 1667,
"format": "WEBP",
"duration": 0,
"EXIF": {
"ModifyDate": "2020-01-29T17:12:45Z"
}
}
},
"sort": [
"/REST API Examples/aurora.jpg"
]
},
{
"_index": "sirvfs-v3",
"_type": "_doc",
"_id": "1945fa0032fbcc5df46e4af56ac1f75fc71ff38d",
"_score": null,
"_routing": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"_source": {
"accountId": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"filename": "/REST API Examples/video/001.jpg",
"dirname": "/REST API Examples/video",
"basename": "001.jpg",
"extension": ".jpg",
"id": "IfnjioVCkRxIWPXrKi6gpHEVKx0KvFm4",
"ctime": "2020-07-17T15:36:52.528Z",
"mtime": "2021-05-12T09:29:49.907Z",
"size": 279982,
"contentType": "image/jpeg",
"meta": {
"width": 1372,
"height": 1080,
"format": "JPEG",
"duration": 0
}
},
"sort": [
"/REST API Examples/video/001.jpg"
]
},
{
"_index": "sirvfs-v3",
"_type": "_doc",
"_id": "61ebc8bf5a8ad3c092f29846afb14e988c4bddaa",
"_score": null,
"_routing": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"_source": {
"accountId": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"filename": "/REST API Examples/video/002.jpg",
"dirname": "/REST API Examples/video",
"basename": "002.jpg",
"extension": ".jpg",
"id": "F100f2RQYtqc4lu8RE5DCKn2GvXqkuov",
"ctime": "2020-07-17T15:36:52.520Z",
"mtime": "2021-05-12T09:29:50.109Z",
"size": 266295,
"contentType": "image/jpeg",
"meta": {
"width": 1372,
"height": 1080,
"format": "JPEG",
"duration": 0
}
},
"sort": [
"/REST API Examples/video/002.jpg"
]
},
{
"_index": "sirvfs-v3",
"_type": "_doc",
"_id": "1f9171cb31bcc108a9df664b3ad60a495cc3c4f8",
"_score": null,
"_routing": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"_source": {
"accountId": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"filename": "/REST API Examples/video/003.jpg",
"dirname": "/REST API Examples/video",
"basename": "003.jpg",
"extension": ".jpg",
"id": "To1IfJ0lftonDG6U2cI4IVTCU2LgNI4e",
"ctime": "2020-07-17T15:36:52.551Z",
"mtime": "2021-05-12T09:29:49.510Z",
"size": 259954,
"contentType": "image/jpeg",
"meta": {
"width": 1372,
"height": 1080,
"format": "JPEG",
"duration": 0
}
},
"sort": [
"/REST API Examples/video/003.jpg"
]
}
],
"total": 256,
"_relation": "eq"
}
Scroll through search results
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
payload = "{}"
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/files/search/scroll", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url https://api.sirv.com/v2/files/search/scroll \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json' \
--data '{}'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/search/scroll",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{}");
req.end();
var data = "{}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/files/search/scroll");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/search/scroll")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.body("{}")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/search/scroll",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer BEARER_TOKEN_HERE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sirv.com/v2/files/search/scroll")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer BEARER_TOKEN_HERE'
request.body = "{}"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
]
let postData = NSData(data: "{}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/search/scroll")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
var client = new RestClient("https://api.sirv.com/v2/files/search/scroll");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.sirv.com/v2/files/search/scroll"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Use the scroll API method after performing an API search if you need to retrieve more than 1000 results. Each call to the scroll API returns the next batch of results until there are no more results left to return.
To use scrolling, the initial search request should specify the "scroll" parameter. The search context will then be kept alive for 30 seconds between each scroll call.
Scrolling is not suitable for real time data - it is for fetching large amounts of data.
Query string
None
Body payload
Example:
{}
JSON Schema:
{
"type": "object",
"properties": {
"scrollId": {
"description": "Scroll ID returned from preceding /files/search or /files/search/scroll call.",
"type": "string"
}
},
"additionalProperties": false,
"patterns": [],
"required": [
"scrollId"
]
}
Response
Example response:
Convert spin to video
import http.client
conn = http.client.HTTPSConnection("api.sirv.com")
payload = "{\"filename\":\"/REST API Examples/coin/coin.spin\",\"options\":{\"width\":1920,\"height\":1080,\"loops\":3}}"
headers = {
'content-type': "application/json",
'authorization': "Bearer BEARER_TOKEN_HERE"
}
conn.request("POST", "/v2/files/spin2video", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request POST \
--url https://api.sirv.com/v2/files/spin2video \
--header 'authorization: Bearer BEARER_TOKEN_HERE' \
--header 'content-type: application/json' \
--data '{"filename":"/REST API Examples/coin/coin.spin","options":{"width":1920,"height":1080,"loops":3}}'
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.sirv.com",
"port": null,
"path": "/v2/files/spin2video",
"headers": {
"content-type": "application/json",
"authorization": "Bearer BEARER_TOKEN_HERE"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\"filename\":\"/REST API Examples/coin/coin.spin\",\"options\":{\"width\":1920,\"height\":1080,\"loops\":3}}");
req.end();
var data = "{\"filename\":\"/REST API Examples/coin/coin.spin\",\"options\":{\"width\":1920,\"height\":1080,\"loops\":3}}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sirv.com/v2/files/spin2video");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");
xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/spin2video")
.header("content-type", "application/json")
.header("authorization", "Bearer BEARER_TOKEN_HERE")
.body("{\"filename\":\"/REST API Examples/coin/coin.spin\",\"options\":{\"width\":1920,\"height\":1080,\"loops\":3}}")
.asString();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sirv.com/v2/files/spin2video",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"filename</span>":\"/REST API Examples/coin/coin.spin\",\"options\":