NAV
cURL Python Node.js JavaScript Java PHP Ruby Swift Go C#

Getting started

The Sirv API gives you 40+ popular commands for your Sirv account. Upload files, search files, rename files, add meta, get folder contents and more.

First, please create an API client...

API client

To use the Sirv REST API, start by creating an API client from the API settings page of your Sirv account:

Create API Client

Once created, you'll see your Client ID and Client Secret:

API Client Credentials

Connect to Sirv API

The first step in using the API is to obtain a bearer token. Once you have that token, you'll be able to use any of the 40+ API methods listed further down this page.

Get bearer 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=="}'
const http = require("https");

const options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/token", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

const req = http.request(options, function (res) { const chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.write("{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}"); req.end();

const data = "{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}";

const 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, [ 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 => [ "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))

}

Every API call will be authenticated with a bearer token, so your first step is to obtain a bearer token. Bearer tokens expire after 20 minutes (1200 seconds). If your token expires, request a new one, then continue with your work. After each API request you submit, you'll receive a response that contains useful information, including an expiresIn field (in seconds) telling you how long remains before your bearer token expires.

Query string

None

Body payload

Example:

{
  "clientId": "ZcnZNfzwRhQExoHFoGpxWJ4p2R",
  "clientSecret": "TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q=="
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "clientId": {
      "type": "string",
      "examples": [
        "ZcnZNfzwRhQExoHFoGpxWJ4p2R"
      ],
      "description": "API client ID"
    },
    "clientSecret": {
      "type": "string",
      "examples": [
        "TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q=="
      ],
      "description": "API client secret"
    }
  },
  "required": [
    "clientId",
    "clientSecret"
  ],
  "additionalProperties": false
}

Response

Example response:

< HTTP/1.1 200
< date: Tue, 27 Jun 2023 10:09:54 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.eyJjbGllbnRJZCI6IlpjblpOZnp3UmhRRXhvSEZvR3B4V0o0cDJSIiwiY2xpZW50TmFtZSI6Ik15IHdlYnNpdGUiLCJzY29wZSI6WyJhY2NvdW50OnJlYWQiLCJhY2NvdW50OndyaXRlIiwidXNlcjpyZWFkIiwidXNlcjp3cml0ZSIsImJpbGxpbmc6cmVhZCIsImJpbGxpbmc6d3JpdGUiLCJmaWxlczpyZWFkIiwiZmlsZXM6d3JpdGUiLCJ2aWRlb3MiLCJpbWFnZXMiXSwiaWF0IjoxNjg3ODYwNTk0LCJleHAiOjE2ODc4NjE3OTQsImF1ZCI6Ijk1cnR2cGxuY3p1Y25sZ2llNm1qdXUyaWI3Z29ncXoyIn0.jnFixXD4uWOXq4qiDk7yvXyNfso2fv0VUUlubbMlfD4",
  "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 all file 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", headers=headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request GET \
  --url https://api.sirv.com/v2/files/meta \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
const http = require("https");

const options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

const req = http.request(options, function (res) { const chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.end();

const data = null;

const 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"); 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")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [ CURLOPT_URL => "https://api.sirv.com/v2/files/meta", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "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")

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")! 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");
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"

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))

}

Get all the meta for a file, in a single request. Unlike the API methods for getting meta title, description, tags and product data, this API method will return all meta data, making it the fastest and easiest way to get meta via the API. (You can also get file meta simply by requesting a file URL with ?info appended - example)

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: Mon, 31 Jul 2023 12:01:23 GMT
< content-type: application/json; charset=utf-8
< content-length: 424
< connection: close
< x-global-ratelimit-limit: 7000
< x-global-ratelimit-remaining: 6955
< x-global-ratelimit-reset: 1690807228
< 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": [
    "lake",
    "water",
    "winter",
    "cold",
    "blue"
  ],
  "title": "Blue Lake",
  "description": "Blue Lake in the Winter",
  "product": {
    "id": "LLBB77",
    "name": "Blue Lake Card",
    "brand": "BLUE LAKE LLC",
    "category1": "Cards",
    "category2": "Lakes"
  },
  "approval": {
    "datetime": "2023-07-31T12:01:23.395Z",
    "approved": false,
    "comment": "It looks too cold!"
  }
}

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 /

Get user points of interest

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/poi", headers=headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request GET \
  --url https://api.sirv.com/v2/files/poi \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
const http = require("https");

const options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/poi", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

const req = http.request(options, function (res) { const chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.end();

const data = null;

const 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/poi"); 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/poi")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [ CURLOPT_URL => "https://api.sirv.com/v2/files/poi", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "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/poi")

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/poi")! 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/poi");
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/poi"

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 coordinates of all the POI (points of interest) on the image.

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: Wed, 21 Jun 2023 16:13:11 GMT
< content-type: application/json; charset=utf-8
< content-length: 87
< connection: close
< x-global-ratelimit-limit: 7000
< x-global-ratelimit-remaining: 6845
< x-global-ratelimit-reset: 1687364368
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "BlueLake": {
    "x": 0.5,
    "y": 0.5,
    "width": 0.5,
    "height": 0.5
  }
}

Get results of ZIP job

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/zip", headers=headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request GET \
  --url https://api.sirv.com/v2/files/zip \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
const http = require("https");

const options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/zip", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

const req = http.request(options, function (res) { const chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.end();

const data = null;

const 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/zip"); 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/zip")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [ CURLOPT_URL => "https://api.sirv.com/v2/files/zip", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "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/zip")

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/zip")! 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/zip");
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/zip"

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 get results and progress of ZIP job created with POST /files/zip method

Query string

Parameter Type Description Example
id string BLDgbVfrCYcLOceNSEf2ymIwLGQDXSCI

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Mon, 05 Feb 2024 13:30:28 GMT
< content-type: application/json; charset=utf-8
< content-length: 191
< connection: close
< x-global-ratelimit-limit: 7000
< x-global-ratelimit-remaining: 6681
< x-global-ratelimit-reset: 1707142905
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "progress": 100,
  "result": [
    {
      "filename": "Sirv January 18, 2023.zip",
      "size": 138237,
      "url": "https://goto.sirv.com/AvhriHTv7nOrMvgBBtPHy1tH1hbaeFCi"
    }
  ]
}

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}'
const http = require("https");

const options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/jwt", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

const req = http.request(options, function (res) { const chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { const 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();

const data = "{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}";

const 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, [ 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 => [ "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))

}

JWT protection is a powerful way to protect your files from being seen without permission. Use this API method to generate a token that can be appended to a URL or set of URLs, allowing a file to be served. Without a valid token, requests for any file within a JWT protected folder will be denied. Before using this method, you must enable JWT folder protection and obtain a key. Read the documentation to learn how to enable and use JWT protection: https://sirv.com/help/json-web-token-protected-signed-url#enable-jwt-protection

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": {
      "type": "string",
      "examples": [
        "/REST API Examples/aurora.jpg"
      ],
      "pattern": "^\\/",
      "maxLength": 1024
    },
    "key": {
      "type": "string",
      "examples": [
        "cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq"
      ],
      "description": "Specify JWT secret"
    },
    "alias": {
      "type": "string",
      "examples": [
        "demo-jwt"
      ],
      "description": "Specify account alias if your account has multiple aliases"
    },
    "insecureParams": {
      "type": "object",
      "properties": {},
      "additionalProperties": false
    },
    "secureParams": {
      "type": "object",
      "examples": [
        {
          "w": 300,
          "h": 300
        }
      ],
      "properties": {},
      "additionalProperties": false
    },
    "expiresIn": {
      "type": "number",
      "examples": [
        300
      ],
      "description": "Token expiration time in seconds"
    }
  },
  "required": [
    "filename",
    "key",
    "expiresIn"
  ],
  "additionalProperties": false
}

Response

Example response:

< HTTP/1.1 200
< date: Tue, 27 Jun 2023 10:10:19 GMT
< content-type: application/json; charset=utf-8
< content-length: 286
< connection: close
< x-global-ratelimit-limit: 7000
< x-global-ratelimit-remaining: 6967
< x-global-ratelimit-reset: 1687864194
< 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.eyJhcmdzIjp7InciOjMwMCwiaCI6MzAwfSwiaWF0IjoxNjg3ODYwNjE5LCJleHAiOjE2ODc4NjA5MTksImF1ZCI6Ii9SRVNUIEFQSSBFeGFtcGxlcy9hdXJvcmEuanBnIn0.-6wTZUlW-8kp43lU8_MxSuSlx8MHf8XYtS8lSXRjtU0"
}

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 all file meta

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"tags\":[\"lake\",\"water\"],\"title\":\"Blue Lake\",\"description\":\"Blue Lake in the Winter\",\"product\":{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"},\"approval\":{\"approved\":false,\"comment\":\"It looks too cold!\"}}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/meta", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url https://api.sirv.com/v2/files/meta \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"tags":["lake","water"],"title":"Blue Lake","description":"Blue Lake in the Winter","product":{"id":"LLBB77","name":"Blue Lake Card","brand":"BLUE LAKE LLC","category1":"Cards","category2":"Lakes"},"approval":{"approved":false,"comment":"It looks too cold!"}}'
const http = require("https");

const options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

const req = http.request(options, function (res) { const chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.write("{\"tags\":[\"lake\",\"water\"],\"title\":\"Blue Lake\",\"description\":\"Blue Lake in the Winter\",\"product\":{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"},\"approval\":{\"approved\":false,\"comment\":\"It looks too cold!\"}}"); req.end();

const data = "{\"tags\":[\"lake\",\"water\"],\"title\":\"Blue Lake\",\"description\":\"Blue Lake in the Winter\",\"product\":{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"},\"approval\":{\"approved\":false,\"comment\":\"It looks too cold!\"}}";

const 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"); 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")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"tags\":[\"lake\",\"water\"],\"title\":\"Blue Lake\",\"description\":\"Blue Lake in the Winter\",\"product\":{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"},\"approval\":{\"approved\":false,\"comment\":\"It looks too cold!\"}}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [ CURLOPT_URL => "https://api.sirv.com/v2/files/meta", 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</span>":[\"lake\",\"water\"],\"title\":\"Blue Lake\",\"description\":\"Blue Lake in the Winter\",\"product\":{\"id</span>":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"},\"approval\":{\"approved</span>":false,\"comment\":\"It looks too cold!\"}}", CURLOPT_HTTPHEADER => [ "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")

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\":[\"lake\",\"water\"],\"title\":\"Blue Lake\",\"description\":\"Blue Lake in the Winter\",\"product\":{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"},\"approval\":{\"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: "{"tags":["lake","water"],"title":"Blue Lake","description":"Blue Lake in the Winter","product":{"id":"LLBB77","name":"Blue Lake Card","brand":"BLUE LAKE LLC","category1":"Cards","category2":"Lakes"},"approval":{"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")! 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");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"tags\":[\"lake\",\"water\"],\"title\":\"Blue Lake\",\"description\":\"Blue Lake in the Winter\",\"product\":{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"},\"approval\":{\"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"

payload := strings.NewReader("{\"tags\":[\"lake\",\"water\"],\"title\":\"Blue Lake\",\"description\":\"Blue Lake in the Winter\",\"product\":{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"},\"approval\":{\"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))

}

Add multiple meta fields in a single request. Any of the 10 types of meta can be added or changed with this API method. If you're adding a lot of meta, this is the fastest and lowest load way to add meta data.

Query string

Parameter Type Description Example
filename string /REST API Examples/blue-lake.jpg

Body payload

Example:

{
  "tags": [
    "lake",
    "water"
  ],
  "title": "Blue Lake",
  "description": "Blue Lake in the Winter",
  "product": {
    "id": "LLBB77",
    "name": "Blue Lake Card",
    "brand": "BLUE LAKE LLC",
    "category1": "Cards",
    "category2": "Lakes"
  },
  "approval": {
    "approved": false,
    "comment": "It looks too cold!"
  }
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "tags": {
      "type": "array",
      "examples": [
        [
          [
            "lake",
            "water"
          ]
        ]
      ],
      "maxItems": 50,
      "items": {
        "type": "string",
        "maxLength": 32
      }
    },
    "title": {
      "type": "string",
      "examples": [
        "Blue Lake"
      ],
      "maxLength": 256
    },
    "description": {
      "type": "string",
      "examples": [
        "Blue Lake in the Winter"
      ],
      "maxLength": 1024
    },
    "product": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "examples": [
            "LLBB77"
          ],
          "maxLength": 256
        },
        "name": {
          "type": "string",
          "examples": [
            "Blue Lake Card"
          ],
          "maxLength": 256
        },
        "brand": {
          "type": "string",
          "examples": [
            "BLUE LAKE LLC"
          ],
          "maxLength": 256
        },
        "category1": {
          "type": "string",
          "examples": [
            "Cards"
          ],
          "maxLength": 256
        },
        "category2": {
          "type": "string",
          "examples": [
            "Lakes"
          ],
          "maxLength": 256
        }
      },
      "additionalProperties": false
    },
    "approval": {
      "type": "object",
      "properties": {
        "approved": {
          "type": "boolean",
          "examples": [
            false
          ]
        },
        "comment": {
          "type": "string",
          "examples": [
            "It looks too cold!"
          ],
          "maxLength": 256
        }
      },
      "required": [
        "approved"
      ],
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}

Response

Example response:

< HTTP/1.1 200
< date: Mon, 31 Jul 2023 12:01:23 GMT
< content-length: 0
< connection: close
< x-global-ratelimit-limit: 7000
< x-global-ratelimit-remaining: 6956
< x-global-ratelimit-reset: 1690807228
< 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\":{\"width\":1920,\"height\":1080,\"loops\":3}}", 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/spin2video")

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/coin/coin.spin\",\"options\":{\"width\":1920,\"height\":1080,\"loops\":3}}"

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/coin/coin.spin","options":{"width":1920,"height":1080,"loops":3}}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/spin2video")! 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/spin2video");
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/coin/coin.spin\",\"options\":{\"width\":1920,\"height\":1080,\"loops\":3}}", 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/spin2video"

payload := strings.NewReader("{\"filename\":\"/REST API Examples/coin/coin.spin\",\"options\":{\"width\":1920,\"height\":1080,\"loops\":3}}")

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 convert a 360 spin into an MP4 video. You can specify the width/height of the video and the number of rotations. If it is a multi-row spin, you can also specify which row should be converted.

Query string

None

Body payload

Example:

{
  "filename": "/REST API Examples/coin/coin.spin",
  "options": {
    "width": 1920,
    "height": 1080,
    "loops": 3
  }
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "filename": {
      "examples": [
        "/REST API Examples/coin/coin.spin"
      ],
      "example": "/REST API Examples/coin/coin.spin",
      "type": "string",
      "pattern": "^\\/",
      "maxLength": 1024
    },
    "options": {
      "type": "object",
      "properties": {
        "width": {
          "examples": [
            1920
          ],
          "example": 1920,
          "type": "number",
          "maximum": 1920
        },
        "height": {
          "examples": [
            1080
          ],
          "example": 1080,
          "type": "number",
          "maximum": 1080
        },
        "loops": {
          "examples": [
            3
          ],
          "example": 3,
          "type": "number",
          "maximum": 20
        },
        "row": {
          "enum": [
            "single",
            "all"
          ],
          "type": "string"
        }
      },
      "additionalProperties": false,
      "patterns": []
    }
  },
  "additionalProperties": false,
  "patterns": [],
  "required": [
    "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: 69
< connection: close
< x-ratelimit-limit: 200
< x-ratelimit-remaining: 196
< x-ratelimit-reset: 1595075486
< x-ratelimit-type: rest:post:files:spin2video
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "filename": "/REST API Examples/coin/coin_single_1920x1080.mp4"
}

Export spin to Amazon

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"filename\":\"/REST API Examples/coin/coin.spin\",\"asin\":\"ASIN1234\"}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/spin2amazon360", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url https://api.sirv.com/v2/files/spin2amazon360 \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"filename":"/REST API Examples/coin/coin.spin","asin":"ASIN1234"}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/spin2amazon360", "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\",\"asin\":\"ASIN1234\"}"); req.end();

var data = "{\"filename\":\"/REST API Examples/coin/coin.spin\",\"asin\":\"ASIN1234\"}";

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/spin2amazon360"); 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/spin2amazon360")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"filename\":\"/REST API Examples/coin/coin.spin\",\"asin\":\"ASIN1234\"}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/spin2amazon360", 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\",\"asin\":\"ASIN1234\"}", 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/spin2amazon360")

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/coin/coin.spin\",\"asin\":\"ASIN1234\"}"

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/coin/coin.spin","asin":"ASIN1234"}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/spin2amazon360")! 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/spin2amazon360");
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/coin/coin.spin\",\"asin\":\"ASIN1234\"}", 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/spin2amazon360"

payload := strings.NewReader("{\"filename\":\"/REST API Examples/coin/coin.spin\",\"asin\":\"ASIN1234\"}")

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))

}

This API method will generate a zip file containing 360 spin images that meet Amazon's requirements for width, height, format and file naming. The response will contain the zip file URL.

You must know the ASIN (Amazon Standard Identification Number) to use this 360 spin zip method. The ASIN is displayed on the Amazon product page.

Query string

None

Body payload

Example:

{
  "filename": "/REST API Examples/coin/coin.spin",
  "asin": "ASIN1234"
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "filename": {
      "examples": [
        "/REST API Examples/coin/coin.spin"
      ],
      "example": "/REST API Examples/coin/coin.spin",
      "type": "string",
      "pattern": "^\\/",
      "maxLength": 1024
    },
    "asin": {
      "description": "Amazon Standard Identification Number",
      "examples": [
        "ASIN1234"
      ],
      "example": "ASIN1234",
      "type": "string"
    }
  },
  "additionalProperties": false,
  "patterns": [],
  "required": [
    "filename",
    "asin"
  ]
}

Response

Example response:

< HTTP/1.1 200
< date: Thu, 13 May 2021 08:21:47 GMT
< content-type: application/json; charset=utf-8
< content-length: 56
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6961
< x-ratelimit-reset: 1620897683
< 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

{
  "filename": "/REST API Examples/coin/ASIN1234.zip"
}

Export spin to Grainger

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"filename\":\"/REST API Examples/coin/coin.spin\",\"sku\":\"SKU1234\"}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/spin2grainger360", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url https://api.sirv.com/v2/files/spin2grainger360 \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"filename":"/REST API Examples/coin/coin.spin","sku":"SKU1234"}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/spin2grainger360", "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\",\"sku\":\"SKU1234\"}"); req.end();

var data = "{\"filename\":\"/REST API Examples/coin/coin.spin\",\"sku\":\"SKU1234\"}";

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/spin2grainger360"); 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/spin2grainger360")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"filename\":\"/REST API Examples/coin/coin.spin\",\"sku\":\"SKU1234\"}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/spin2grainger360", 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\",\"sku\":\"SKU1234\"}", 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/spin2grainger360")

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/coin/coin.spin\",\"sku\":\"SKU1234\"}"

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/coin/coin.spin","sku":"SKU1234"}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/spin2grainger360")! 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/spin2grainger360");
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/coin/coin.spin\",\"sku\":\"SKU1234\"}", 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/spin2grainger360"

payload := strings.NewReader("{\"filename\":\"/REST API Examples/coin/coin.spin\",\"sku\":\"SKU1234\"}")

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))

}

This API method will generate a zip file containing 360 spin images that meet Grainger's requirements for format and file naming. The response will contain the zip file URL.

You must know the Grainger SKU to use this 360 spin zip method.

Query string

None

Body payload

Example:

{
  "filename": "/REST API Examples/coin/coin.spin",
  "sku": "SKU1234"
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "filename": {
      "examples": [
        "/REST API Examples/coin/coin.spin"
      ],
      "example": "/REST API Examples/coin/coin.spin",
      "type": "string",
      "pattern": "^\\/",
      "maxLength": 1024
    },
    "sku": {
      "description": "Grainger SKU",
      "examples": [
        "SKU1234"
      ],
      "example": "SKU1234",
      "type": "string",
      "maxLength": 64
    }
  },
  "additionalProperties": false,
  "patterns": [],
  "required": [
    "filename",
    "sku"
  ]
}

Response

Example response:

< HTTP/1.1 200
< date: Thu, 26 Aug 2021 14:04:41 GMT
< content-type: application/json; charset=utf-8
< content-length: 55
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6959
< x-ratelimit-reset: 1629990234
< 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

{
  "filename": "/REST API Examples/coin/SKU1234.zip"
}

Export spin to Walmart

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"filename\":\"/REST API Examples/coin/coin.spin\",\"gtin\":\"00612052029955\"}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/spin2walmart360", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url https://api.sirv.com/v2/files/spin2walmart360 \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"filename":"/REST API Examples/coin/coin.spin","gtin":"00612052029955"}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/spin2walmart360", "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\",\"gtin\":\"00612052029955\"}"); req.end();

var data = "{\"filename\":\"/REST API Examples/coin/coin.spin\",\"gtin\":\"00612052029955\"}";

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/spin2walmart360"); 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/spin2walmart360")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"filename\":\"/REST API Examples/coin/coin.spin\",\"gtin\":\"00612052029955\"}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/spin2walmart360", 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\",\"gtin\":\"00612052029955\"}", 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/spin2walmart360")

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/coin/coin.spin\",\"gtin\":\"00612052029955\"}"

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/coin/coin.spin","gtin":"00612052029955"}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/spin2walmart360")! 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/spin2walmart360");
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/coin/coin.spin\",\"gtin\":\"00612052029955\"}", 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/spin2walmart360"

payload := strings.NewReader("{\"filename\":\"/REST API Examples/coin/coin.spin\",\"gtin\":\"00612052029955\"}")

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))

}

This API method will generate a zip file containing 360 spin images that meet Walmart's requirements for format and file naming. The response will contain the zip file URL.

You must know the Walmart GTIN to use this 360 spin zip method.

Query string

None

Body payload

Example:

{
  "filename": "/REST API Examples/coin/coin.spin",
  "gtin": "00612052029955"
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "filename": {
      "examples": [
        "/REST API Examples/coin/coin.spin"
      ],
      "example": "/REST API Examples/coin/coin.spin",
      "type": "string",
      "pattern": "^\\/",
      "maxLength": 1024
    },
    "gtin": {
      "description": "Walmart GTIN",
      "examples": [
        "00612052029955"
      ],
      "example": "00612052029955",
      "type": "string",
      "maxLength": 64
    }
  },
  "additionalProperties": false,
  "patterns": [],
  "required": [
    "filename",
    "gtin"
  ]
}

Response

Example response:

< HTTP/1.1 200
< date: Tue, 05 Oct 2021 14:32:31 GMT
< content-type: application/json; charset=utf-8
< content-length: 62
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6917
< x-ratelimit-reset: 1633447699
< 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

{
  "filename": "/REST API Examples/coin/00612052029955.zip"
}

Export spin to Home Depot

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"filename\":\"/REST API Examples/coin/coin.spin\",\"omsid\":\"100650378\",\"spinNumber\":2}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/spin2homedepot360", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url https://api.sirv.com/v2/files/spin2homedepot360 \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"filename":"/REST API Examples/coin/coin.spin","omsid":"100650378","spinNumber":2}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/spin2homedepot360", "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\",\"omsid\":\"100650378\",\"spinNumber\":2}"); req.end();

var data = "{\"filename\":\"/REST API Examples/coin/coin.spin\",\"omsid\":\"100650378\",\"spinNumber\":2}";

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/spin2homedepot360"); 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/spin2homedepot360")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"filename\":\"/REST API Examples/coin/coin.spin\",\"omsid\":\"100650378\",\"spinNumber\":2}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/spin2homedepot360", 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\",\"omsid\":\"100650378\",\"spinNumber\":2}", 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/spin2homedepot360")

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/coin/coin.spin\",\"omsid\":\"100650378\",\"spinNumber\":2}"

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/coin/coin.spin","omsid":"100650378","spinNumber":2}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/spin2homedepot360")! 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/spin2homedepot360");
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/coin/coin.spin\",\"omsid\":\"100650378\",\"spinNumber\":2}", 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/spin2homedepot360"

payload := strings.NewReader("{\"filename\":\"/REST API Examples/coin/coin.spin\",\"omsid\":\"100650378\",\"spinNumber\":2}")

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))

}

This API method will generate a zip file containing 360 spin images that meet Home Depot's requirements for image dimensions, format and naming. The response will contain the zip file URL for download.

You must know the Home Depot OMSID to use this 360 spin zip method.

Query string

None

Body payload

Example:

{
  "filename": "/REST API Examples/coin/coin.spin",
  "omsid": "100650378",
  "spinNumber": 2
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "filename": {
      "examples": [
        "/REST API Examples/coin/coin.spin"
      ],
      "example": "/REST API Examples/coin/coin.spin",
      "type": "string",
      "pattern": "^\\/",
      "maxLength": 1024
    },
    "omsid": {
      "description": "Home Depot OMSID",
      "examples": [
        "100650378"
      ],
      "example": "100650378",
      "type": "string",
      "maxLength": 9,
      "minLength": 9
    },
    "spinNumber": {
      "description": "Spin number in case product has more than 1 spin",
      "examples": [
        2
      ],
      "example": 2,
      "type": "number"
    }
  },
  "additionalProperties": false,
  "patterns": [],
  "required": [
    "filename",
    "omsid"
  ]
}

Response

Example response:

< HTTP/1.1 200
< date: Wed, 02 Feb 2022 15:17:37 GMT
< content-type: application/json; charset=utf-8
< content-length: 57
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6913
< x-ratelimit-reset: 1643815780
< 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

{
  "filename": "/REST API Examples/coin/100650378.zip"
}

Export spin to Lowe's

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"filename\":\"/REST API Examples/coin/coin.spin\",\"barcode\":\"1234567890\"}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/spin2lowes360", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url https://api.sirv.com/v2/files/spin2lowes360 \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"filename":"/REST API Examples/coin/coin.spin","barcode":"1234567890"}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/spin2lowes360", "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\",\"barcode\":\"1234567890\"}"); req.end();

var data = "{\"filename\":\"/REST API Examples/coin/coin.spin\",\"barcode\":\"1234567890\"}";

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/spin2lowes360"); 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/spin2lowes360")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"filename\":\"/REST API Examples/coin/coin.spin\",\"barcode\":\"1234567890\"}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/spin2lowes360", 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\",\"barcode\":\"1234567890\"}", 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/spin2lowes360")

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/coin/coin.spin\",\"barcode\":\"1234567890\"}"

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/coin/coin.spin","barcode":"1234567890"}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/spin2lowes360")! 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/spin2lowes360");
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/coin/coin.spin\",\"barcode\":\"1234567890\"}", 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/spin2lowes360"

payload := strings.NewReader("{\"filename\":\"/REST API Examples/coin/coin.spin\",\"barcode\":\"1234567890\"}")

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))

}

This API method will generate a zip file containing 360 spin images that meet Lowe's requirements for format and file naming. The response will contain the zip file URL.

You must know the Lowe's barcode to use this 360 spin zip method.

Query string

None

Body payload

Example:

{
  "filename": "/REST API Examples/coin/coin.spin",
  "barcode": "1234567890"
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "filename": {
      "examples": [
        "/REST API Examples/coin/coin.spin"
      ],
      "example": "/REST API Examples/coin/coin.spin",
      "type": "string",
      "pattern": "^\\/",
      "maxLength": 1024
    },
    "barcode": {
      "description": "Lowe's barcode",
      "examples": [
        "1234567890"
      ],
      "example": "1234567890",
      "type": "string"
    }
  },
  "additionalProperties": false,
  "patterns": [],
  "required": [
    "filename",
    "barcode"
  ]
}

Response

Example response:

< HTTP/1.1 200
< date: Wed, 02 Feb 2022 14:30:44 GMT
< content-type: application/json; charset=utf-8
< content-length: 58
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6956
< x-ratelimit-reset: 1643815780
< 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

{
  "filename": "/REST API Examples/coin/1234567890.zip"
}

Upload 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/upload?filename=%2FREST%20API%20Examples%2Fuploaded.txt", headers=headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url 'https://api.sirv.com/v2/files/upload?filename=%2FREST%20API%20Examples%2Fuploaded.txt' \
  --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/upload?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("POST", "https://api.sirv.com/v2/files/upload?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.post("https://api.sirv.com/v2/files/upload?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/upload?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 => "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/upload?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::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/upload?filename=%2FREST%20API%20Examples%2Fuploaded.txt")! 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/upload?filename=%2FREST%20API%20Examples%2Fuploaded.txt");
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/upload?filename=%2FREST%20API%20Examples%2Fuploaded.txt"

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 upload a file. If the folder path does not already exist, it will be created. Specify the appropriate content type. Use binary content encoding (not base64).

Query string

Parameter Type Description Example
filename string /REST API Examples/uploaded.txt

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Fri, 03 Jun 2022 15:21:07 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 2000
< x-ratelimit-remaining: 1999
< x-ratelimit-reset: 1654273267
< x-ratelimit-type: rest:post:files:upload
< 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 /

Create new 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/mkdir?dirname=%2FREST%20API%20Examples%2Fcopies", headers=headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url 'https://api.sirv.com/v2/files/mkdir?dirname=%2FREST%20API%20Examples%2Fcopies' \
  --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/mkdir?dirname=%2FREST%20API%20Examples%2Fcopies", "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/mkdir?dirname=%2FREST%20API%20Examples%2Fcopies"); 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/mkdir?dirname=%2FREST%20API%20Examples%2Fcopies")
  .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/mkdir?dirname=%2FREST%20API%20Examples%2Fcopies", 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/mkdir?dirname=%2FREST%20API%20Examples%2Fcopies")

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/mkdir?dirname=%2FREST%20API%20Examples%2Fcopies")! 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/mkdir?dirname=%2FREST%20API%20Examples%2Fcopies");
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/mkdir?dirname=%2FREST%20API%20Examples%2Fcopies"

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 create a new empty folder.

Query string

Parameter Type Description Example
dirname string /REST API Examples/copies

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Thu, 01 Dec 2022 19:12:31 GMT
< content-type: application/json; charset=utf-8
< content-length: 90
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6945
< x-ratelimit-reset: 1669925426
< 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

{
  "name": "RiakFsError",
  "message": "Path already exists: /REST API Examples/copies"
}

Rename file or 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/rename?from=%2FREST%20API%20Examples%2Fuploaded.txt&to=%2FREST%20API%20Examples%2Fcopies%2Fuploaded-copy.txt", headers=headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url 'https://api.sirv.com/v2/files/rename?from=%2FREST%20API%20Examples%2Fuploaded.txt&to=%2FREST%20API%20Examples%2Fcopies%2Fuploaded-copy.txt' \
  --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/rename?from=%2FREST%20API%20Examples%2Fuploaded.txt&to=%2FREST%20API%20Examples%2Fcopies%2Fuploaded-copy.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("POST", "https://api.sirv.com/v2/files/rename?from=%2FREST%20API%20Examples%2Fuploaded.txt&to=%2FREST%20API%20Examples%2Fcopies%2Fuploaded-copy.txt"); 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/rename?from=%2FREST%20API%20Examples%2Fuploaded.txt&to=%2FREST%20API%20Examples%2Fcopies%2Fuploaded-copy.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/rename?from=%2FREST%20API%20Examples%2Fuploaded.txt&to=%2FREST%20API%20Examples%2Fcopies%2Fuploaded-copy.txt", 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/rename?from=%2FREST%20API%20Examples%2Fuploaded.txt&to=%2FREST%20API%20Examples%2Fcopies%2Fuploaded-copy.txt")

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/rename?from=%2FREST%20API%20Examples%2Fuploaded.txt&to=%2FREST%20API%20Examples%2Fcopies%2Fuploaded-copy.txt")! 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/rename?from=%2FREST%20API%20Examples%2Fuploaded.txt&to=%2FREST%20API%20Examples%2Fcopies%2Fuploaded-copy.txt");
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/rename?from=%2FREST%20API%20Examples%2Fuploaded.txt&to=%2FREST%20API%20Examples%2Fcopies%2Fuploaded-copy.txt"

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 rename (or move) a file or folder.

Query string

Parameter Type Description Example
from string /REST API Examples/uploaded.txt
to string /REST API Examples/copies/uploaded-copy.txt

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Thu, 01 Dec 2022 19:12:32 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6944
< x-ratelimit-reset: 1669925426
< 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 /

Convert video to spin

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"filename\":\"/REST API Examples/video.mp4\",\"options\":{\"frames\":32}}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/video2spin", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url https://api.sirv.com/v2/files/video2spin \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"filename":"/REST API Examples/video.mp4","options":{"frames":32}}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/video2spin", "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/video.mp4\",\"options\":{\"frames\":32}}"); req.end();

var data = "{\"filename\":\"/REST API Examples/video.mp4\",\"options\":{\"frames\":32}}";

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/video2spin"); 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/video2spin")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"filename\":\"/REST API Examples/video.mp4\",\"options\":{\"frames\":32}}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/video2spin", 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/video.mp4\",\"options\":{\"frames\":32}}", 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/video2spin")

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/video.mp4\",\"options\":{\"frames\":32}}"

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/video.mp4","options":{"frames":32}}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/video2spin")! 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/video2spin");
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/video.mp4\",\"options\":{\"frames\":32}}", 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/video2spin"

payload := strings.NewReader("{\"filename\":\"/REST API Examples/video.mp4\",\"options\":{\"frames\":32}}")

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 create a 360 spin from a video file. Choose the start and end time if you only wish to convert part of the video.

Query string

None

Body payload

Example:

{
  "filename": "/REST API Examples/video.mp4",
  "options": {
    "frames": 32
  }
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "filename": {
      "examples": [
        "/REST API Examples/video.mp4"
      ],
      "example": "/REST API Examples/video.mp4",
      "type": "string",
      "pattern": "^\\/",
      "maxLength": 1024
    },
    "options": {
      "type": "object",
      "properties": {
        "start": {
          "type": "number"
        },
        "end": {
          "type": "number"
        },
        "frames": {
          "examples": [
            32
          ],
          "example": 32,
          "type": "number",
          "maximum": 512,
          "minimum": 8
        }
      },
      "additionalProperties": false,
      "patterns": []
    }
  },
  "additionalProperties": false,
  "patterns": [],
  "required": [
    "filename"
  ]
}

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:58 GMT
< content-type: application/json; charset=utf-8
< content-length: 55
< connection: close
< x-ratelimit-limit: 200
< x-ratelimit-remaining: 196
< x-ratelimit-reset: 1595075483
< x-ratelimit-type: rest:post:files:video2spin
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "filename": "/REST API Examples/video/video.spin"
}

Set point of interest

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"name\":\"BlueLake\",\"x\":0.5,\"y\":0.5,\"width\":0.5,\"height\":0.5}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/poi", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url https://api.sirv.com/v2/files/poi \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"name":"BlueLake","x":0.5,"y":0.5,"width":0.5,"height":0.5}'
const http = require("https");

const options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/poi", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

const req = http.request(options, function (res) { const chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.write("{\"name\":\"BlueLake\",\"x\":0.5,\"y\":0.5,\"width\":0.5,\"height\":0.5}"); req.end();

const data = "{\"name\":\"BlueLake\",\"x\":0.5,\"y\":0.5,\"width\":0.5,\"height\":0.5}";

const 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/poi"); 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/poi")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"name\":\"BlueLake\",\"x\":0.5,\"y\":0.5,\"width\":0.5,\"height\":0.5}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [ CURLOPT_URL => "https://api.sirv.com/v2/files/poi", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"name\":\"BlueLake\",\"x\":0.5,\"y\":0.5,\"width\":0.5,\"height\":0.5}", CURLOPT_HTTPHEADER => [ "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/poi")

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 = "{\"name\":\"BlueLake\",\"x\":0.5,\"y\":0.5,\"width\":0.5,\"height\":0.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: "{"name":"BlueLake","x":0.5,"y":0.5,"width":0.5,"height":0.5}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/poi")! 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/poi");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"name\":\"BlueLake\",\"x\":0.5,\"y\":0.5,\"width\":0.5,\"height\":0.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/poi"

payload := strings.NewReader("{\"name\":\"BlueLake\",\"x\":0.5,\"y\":0.5,\"width\":0.5,\"height\":0.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 set coordinates of the POI (point of interest) on the image.

Query string

Parameter Type Description Example
filename string /REST API Examples/blue-lake.jpg

Body payload

Example:

{
  "name": "BlueLake",
  "x": 0.5,
  "y": 0.5,
  "width": 0.5,
  "height": 0.5
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "examples": [
        "BlueLake"
      ],
      "description": "Name of the POI",
      "maxLength": 16
    },
    "x": {
      "type": "number",
      "examples": [
        0.5
      ],
      "description": "Relative X coordinate of the center of the POI",
      "minimum": 0,
      "maximum": 1
    },
    "y": {
      "type": "number",
      "examples": [
        0.5
      ],
      "description": "Relative Y coordinate of the center of the POI",
      "minimum": 0,
      "maximum": 1
    },
    "width": {
      "type": "number",
      "examples": [
        0.5
      ],
      "description": "Relative width of the POI",
      "minimum": 0,
      "maximum": 1
    },
    "height": {
      "type": "number",
      "examples": [
        0.5
      ],
      "description": "Relative height of the POI",
      "minimum": 0,
      "maximum": 1
    }
  },
  "additionalProperties": false
}

Response

Example response:

< HTTP/1.1 200
< date: Wed, 21 Jun 2023 15:47:23 GMT
< content-length: 0
< connection: close
< x-global-ratelimit-limit: 7000
< x-global-ratelimit-remaining: 6888
< x-global-ratelimit-reset: 1687364368
< 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 /

Zip a batch of files or directories

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"filenames\":[\"/REST API Examples/coin/coin_01.jpg\",\"/REST API Examples/coin/coin_02.jpg\"],\"zipFilename\":\"Sirv January 18, 2023.zip\"}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/zip", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url https://api.sirv.com/v2/files/zip \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"filenames":["/REST API Examples/coin/coin_01.jpg","/REST API Examples/coin/coin_02.jpg"],"zipFilename":"Sirv January 18, 2023.zip"}'
const http = require("https");

const options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/zip", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

const req = http.request(options, function (res) { const chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.write("{\"filenames\":[\"/REST API Examples/coin/coin_01.jpg\",\"/REST API Examples/coin/coin_02.jpg\"],\"zipFilename\":\"Sirv January 18, 2023.zip\"}"); req.end();

const data = "{\"filenames\":[\"/REST API Examples/coin/coin_01.jpg\",\"/REST API Examples/coin/coin_02.jpg\"],\"zipFilename\":\"Sirv January 18, 2023.zip\"}";

const 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/zip"); 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/zip")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"filenames\":[\"/REST API Examples/coin/coin_01.jpg\",\"/REST API Examples/coin/coin_02.jpg\"],\"zipFilename\":\"Sirv January 18, 2023.zip\"}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [ CURLOPT_URL => "https://api.sirv.com/v2/files/zip", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"filenames</span>":[\"/REST API Examples/coin/coin_01.jpg\",\"/REST API Examples/coin/coin_02.jpg\"],\"zipFilename\":\"Sirv January 18, 2023.zip\"}", CURLOPT_HTTPHEADER => [ "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/zip")

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 = "{\"filenames\":[\"/REST API Examples/coin/coin_01.jpg\",\"/REST API Examples/coin/coin_02.jpg\"],\"zipFilename\":\"Sirv January 18, 2023.zip\"}"

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: "{"filenames":["/REST API Examples/coin/coin_01.jpg","/REST API Examples/coin/coin_02.jpg"],"zipFilename":"Sirv January 18, 2023.zip"}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/zip")! 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/zip");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"filenames\":[\"/REST API Examples/coin/coin_01.jpg\",\"/REST API Examples/coin/coin_02.jpg\"],\"zipFilename\":\"Sirv January 18, 2023.zip\"}", 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/zip"

payload := strings.NewReader("{\"filenames\":[\"/REST API Examples/coin/coin_01.jpg\",\"/REST API Examples/coin/coin_02.jpg\"],\"zipFilename\":\"Sirv January 18, 2023.zip\"}")

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 create a ZIP archive from the list of filenames

Query string

None

Body payload

Example:

{
  "filenames": [
    "/REST API Examples/coin/coin_01.jpg",
    "/REST API Examples/coin/coin_02.jpg"
  ],
  "zipFilename": "Sirv January 18, 2023.zip"
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "filenames": {
      "type": "array",
      "examples": [
        [
          [
            "/REST API Examples/coin/coin_01.jpg",
            "/REST API Examples/coin/coin_02.jpg"
          ]
        ]
      ],
      "maxItems": 1000,
      "items": {
        "type": "string",
        "maxLength": 1024
      }
    },
    "zipFilename": {
      "type": "string",
      "examples": [
        "Sirv January 18, 2023.zip"
      ],
      "maxLength": 64
    }
  },
  "required": [
    "filenames"
  ],
  "additionalProperties": false
}

Response

Example response:

< HTTP/1.1 200
< date: Mon, 05 Feb 2024 13:30:28 GMT
< content-type: application/json; charset=utf-8
< content-length: 46
< connection: close
< x-global-ratelimit-limit: 7000
< x-global-ratelimit-remaining: 6682
< x-global-ratelimit-reset: 1707142905
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "id": "emrXdtsZrBjPYlDawmhRDqWCXKSeqGUG"
}

Delete file meta tags

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"tags\":[\"ocean\"]}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("DELETE", "/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 DELETE \
  --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":["ocean"]}'
var http = require("https");

var options = { "method": "DELETE", "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\":[\"ocean\"]}"); req.end();

var data = "{\"tags\":[\"ocean\"]}";

var xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } });

xhr.open("DELETE", "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.delete("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\":[\"ocean\"]}")
  .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 => "DELETE", CURLOPT_POSTFIELDS => "{\"tags\":[\"ocean\"]}", 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::Delete.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"tags\":[\"ocean\"]}"

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":["ocean"]}".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 = "DELETE" 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.DELETE);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"tags\":[\"ocean\"]}", 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\":[\"ocean\"]}")

req, _ := http.NewRequest("DELETE", 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 delete a meta tag from a file or folder.

Query string

Parameter Type Description Example
filename string /REST API Examples/blue-lake.jpg

Body payload

Example:

{
  "tags": [
    "ocean"
  ]
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "tags": {
      "examples": [
        [
          "ocean"
        ]
      ],
      "example": [
        "ocean"
      ],
      "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: 6874
< 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 point of interest

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"name\":\"BlueLake\"}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("DELETE", "/v2/files/poi", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request DELETE \
  --url https://api.sirv.com/v2/files/poi \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"name":"BlueLake"}'
const http = require("https");

const options = { "method": "DELETE", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/poi", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

const req = http.request(options, function (res) { const chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.write("{\"name\":\"BlueLake\"}"); req.end();

const data = "{\"name\":\"BlueLake\"}";

const xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } });

xhr.open("DELETE", "https://api.sirv.com/v2/files/poi"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.delete("https://api.sirv.com/v2/files/poi")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"name\":\"BlueLake\"}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [ CURLOPT_URL => "https://api.sirv.com/v2/files/poi", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "DELETE", CURLOPT_POSTFIELDS => "{\"name\":\"BlueLake\"}", CURLOPT_HTTPHEADER => [ "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/poi")

http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Delete.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"name\":\"BlueLake\"}"

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: "{"name":"BlueLake"}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/poi")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "DELETE" 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/poi");
var request = new RestRequest(Method.DELETE);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"name\":\"BlueLake\"}", 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/poi"

payload := strings.NewReader("{\"name\":\"BlueLake\"}")

req, _ := http.NewRequest("DELETE", 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 delete POI (point of interest) on the image.

Query string

Parameter Type Description Example
filename string /REST API Examples/blue-lake.jpg

Body payload

Example:

{
  "name": "BlueLake"
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "examples": [
        "BlueLake"
      ],
      "description": "Name of the POI",
      "maxLength": 16
    }
  },
  "additionalProperties": false
}

Response

Example response:

< HTTP/1.1 200
< date: Wed, 21 Jun 2023 15:47:23 GMT
< content-length: 0
< connection: close
< x-global-ratelimit-limit: 7000
< x-global-ratelimit-remaining: 6887
< x-global-ratelimit-reset: 1687364368
< 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 /