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

Getting started

The first time you use the Sirv REST API, create an API client, then connect to Sirv. Once connected, you can use over 30 API methods.

API client

To use the Sirv REST API, create an API client from the Settings page of your Sirv account:

Create API Client

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

API Client Credentials

Connect to Sirv API

Each API call must be authenticated with a bearer token (JSON Web Token). You can get a token with a POST request. Use the token with the Sirv REST API methods listed below. When the token expires (see the expiresIn field, in seconds), you should request a new token.

Get API access token

import http.client

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

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

headers = { 'content-type': "application/json" }

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 'content-type: application/json' \
  --data '{"clientId":"ZcnZNfzwRhQExoHFoGpxWJ4p2R","clientSecret":"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q=="}'
var http = require("https");

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

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

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

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

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

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

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

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

xhr.open("POST", "https://api.sirv.com/v2/token"); xhr.setRequestHeader("content-type", "application/json");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/token")
  .header("content-type", "application/json")
  .body("{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/token", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}", CURLOPT_HTTPHEADER => array( "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.body = "{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json" ]

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

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Query string

None

Body payload

Example:

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

JSON Schema:

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

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 12:18:15 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.eyJjbGllbnRJZCI6IlpjblpOZnp3UmhRRXhvSEZvR3B4V0o0cDJSIiwiY2xpZW50TmFtZSI6Ik15IHdlYnNpdGUiLCJzY29wZSI6WyJhY2NvdW50OnJlYWQiLCJhY2NvdW50OndyaXRlIiwidXNlcjpyZWFkIiwidXNlcjp3cml0ZSIsImJpbGxpbmc6cmVhZCIsImJpbGxpbmc6d3JpdGUiLCJmaWxlczpyZWFkIiwiZmlsZXM6d3JpdGUiLCJ2aWRlb3MiLCJpbWFnZXMiXSwiaWF0IjoxNTk1MDc0Njk1LCJleHAiOjE1OTUwNzU4OTUsImF1ZCI6Ijk1cnR2cGxuY3p1Y25sZ2llNm1qdXUyaWI3Z29ncXoyIn0.tphWXF2mXQq3uGspkavcbjs_FLyA3UXptjp-e9ZgF50",
  "expiresIn": 1200,
  "scope": [
    "account:read",
    "account:write",
    "user:read",
    "user:write",
    "billing:read",
    "billing:write",
    "files:read",
    "files:write",
    "videos",
    "images"
  ]
}

Account API

Get account info

import http.client

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

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

conn.request("GET", "/v2/account", headers=headers)

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/account")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/account", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/account")

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

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/account")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/account");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/account"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to get information about the account, including its CDN URL; account name; additional domains; remote fetching status; date created and more.

Query string

None

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:49 GMT
< content-type: application/json; charset=utf-8
< content-length: 661
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6897
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "dateCreated": "2014-10-14T14:15:18.580Z",
  "alias": "demo",
  "fileSizeLimit": 50000000,
  "fetching": {
    "enabled": false,
    "type": "http",
    "http": {
      "auth": {
        "enabled": false
      },
      "url": "https://somesite.com/folder/"
    },
    "maxFilesize": 2097152
  },
  "minify": {
    "enabled": false
  },
  "cdnTempURL": "demo.sirv.com",
  "cdnURL": "demo.sirv.com",
  "aliases": {
    "demo": {
      "prefix": "/",
      "cdn": true
    },
    "anotherdemo": {
      "prefix": "/",
      "cdn": true
    },
    "demo-cdntest": {
      "prefix": "/"
    },
    "demo-jwt": {
      "prefix": "/",
      "cdn": true
    }
  }
}

Get API limits

import http.client

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

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

conn.request("GET", "/v2/account/limits", headers=headers)

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/account/limits")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/account/limits", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/account/limits")

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

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/account/limits")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/account/limits");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/account/limits"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this method to check the allowed number of API requests and the number of requests used in the past 60 minutes.

Query string

None

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:50 GMT
< content-type: application/json; charset=utf-8
< content-length: 2892
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6893
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< vary: accept-encoding
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "s3:global": {
    "count": 0,
    "limit": 7000,
    "remaining": 7000,
    "reset": 1595076350
  },
  "s3:PUT": {
    "count": 0,
    "limit": 2000,
    "remaining": 2000,
    "reset": 1595076350
  },
  "s3:GET": {
    "count": 0,
    "limit": 3000,
    "remaining": 3000,
    "reset": 1595076350
  },
  "s3:DELETE": {
    "count": 0,
    "limit": 3000,
    "remaining": 3000,
    "reset": 1595076350
  },
  "rest:global": {
    "count": 107,
    "limit": 7000,
    "remaining": 6893,
    "reset": 1595075478
  },
  "rest:post:files:search": {
    "count": 3,
    "limit": 1000,
    "remaining": 997,
    "reset": 1595075483
  },
  "rest:post:files:search:scroll": {
    "count": 0,
    "limit": 2000,
    "remaining": 2000,
    "reset": 1595076350
  },
  "rest:post:files:video2spin": {
    "count": 3,
    "limit": 200,
    "remaining": 197,
    "reset": 1595075483
  },
  "rest:post:files:spin2video": {
    "count": 3,
    "limit": 200,
    "remaining": 197,
    "reset": 1595075486
  },
  "rest:post:files:fetch": {
    "count": 3,
    "limit": 2000,
    "remaining": 1997,
    "reset": 1595075492
  },
  "rest:post:files:upload": {
    "count": 3,
    "limit": 2000,
    "remaining": 1997,
    "reset": 1595075494
  },
  "rest:post:files:delete": {
    "count": 3,
    "limit": 3000,
    "remaining": 2997,
    "reset": 1595075495
  },
  "rest:post:account": {
    "count": 4,
    "limit": 50,
    "remaining": 46,
    "reset": 1595075478
  },
  "rest:post:account:fetching": {
    "count": 0,
    "limit": 50,
    "remaining": 50,
    "reset": 1595076350
  },
  "rest:get:stats:http": {
    "count": 3,
    "limit": 100,
    "remaining": 97,
    "reset": 1595075480
  },
  "rest:get:stats:storage": {
    "count": 3,
    "limit": 100,
    "remaining": 97,
    "reset": 1595075481
  },
  "rest:post:account:new": {
    "count": 0,
    "limit": 5,
    "remaining": 5,
    "reset": 1595076350
  },
  "rest:post:user:accounts": {
    "count": 0,
    "limit": 20,
    "remaining": 20,
    "reset": 1595076350
  },
  "rest:get:rest:credentials": {
    "count": 0,
    "limit": 50,
    "remaining": 50,
    "reset": 1595076350
  },
  "rest:post:video:toSpin": {
    "count": 0,
    "limit": 400,
    "remaining": 400,
    "reset": 1595076350
  },
  "rest:post:upload:toSirv": {
    "count": 0,
    "limit": 2000,
    "remaining": 2000,
    "reset": 1595076350
  },
  "ftp:global": {
    "count": 0,
    "limit": 10000,
    "remaining": 10000,
    "reset": 1595076350
  },
  "ftp:STOR": {
    "count": 0,
    "limit": 2000,
    "remaining": 2000,
    "reset": 1595076350
  },
  "ftp:RETR": {
    "count": 0,
    "limit": 3000,
    "remaining": 3000,
    "reset": 1595076350
  },
  "ftp:DELE": {
    "count": 0,
    "limit": 3000,
    "remaining": 3000,
    "reset": 1595076350
  },
  "fetch:file": {
    "count": 1,
    "limit": 2000,
    "remaining": 1999,
    "reset": 1595075492
  }
}

Get storage info

import http.client

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

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

conn.request("GET", "/v2/account/storage", headers=headers)

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/account/storage")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/account/storage", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/account/storage")

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

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/account/storage")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/account/storage");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/account/storage"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this to check the current storage usage of an account. It will also return the total allowed storage; any extra storage provided; the temporary 30-day burstable storage allowance; the total files stored. If the account has exceeded its storage allowance, it will state the when that happened. If the account is one of a multi-account group, it will show the total storage used by all accounts.

Query string

None

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:50 GMT
< content-type: application/json; charset=utf-8
< content-length: 139
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6895
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "plan": 100000000000,
  "burstable": 500000000000,
  "extra": 0,
  "used": 51916252571,
  "files": 73143,
  "quotaExceededDate": null
}

Get users

import http.client

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

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

conn.request("GET", "/v2/account/users", headers=headers)

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/account/users")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/account/users", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/account/users")

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

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/account/users")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/account/users");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/account/users"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to get a list of all users of an account. It will return a list of user IDs and their roles. If you need a users email address, the user ID can be used to obtain it.

Query string

None

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:50 GMT
< content-type: application/json; charset=utf-8
< content-length: 833
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6894
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

[
  {
    "role": "primaryOwner",
    "userId": "************************"
  },
  {
    "role": "owner",
    "userId": "************************"
  },
  {
    "role": "owner",
    "userId": "************************"
  },
  {
    "role": "contributor",
    "userId": "************************"
  },
  {
    "role": "admin",
    "userId": "************************"
  },
  {
    "role": "owner",
    "userId": "************************"
  },
  {
    "role": "user",
    "userId": "************************"
  },
  {
    "role": "user",
    "userId": "************************"
  },
  {
    "role": "user",
    "userId": "************************"
  },
  {
    "role": "contributor",
    "userId": "************************"
  },
  {
    "role": "viewer",
    "userId": "************************"
  }
]

Get billing info

import http.client

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

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

conn.request("GET", "/v2/billing/plan", headers=headers)

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/billing/plan")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/billing/plan", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/billing/plan")

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

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/billing/plan")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/billing/plan");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/billing/plan"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to get all the billing plan information of an account, including price, storage and transfer allowances.

Query string

None

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:51 GMT
< content-type: application/json; charset=utf-8
< content-length: 294
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6891
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "dateActive": "2017-05-31T00:00:00.000Z",
  "id": "Business_5_v2",
  "period": "month",
  "name": "Business 5",
  "description": "The complete set of features, with large allowances and no branding",
  "price": {
    "month": 19,
    "year": 209,
    "quarter": 57
  },
  "storage": 1000000000,
  "burstableStorage": 5000000000
}

Update account info

import http.client

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

payload = "{\"fetching\":{\"enabled\":false}}"

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

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

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

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

curl --request POST \
  --url https://api.sirv.com/v2/account \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"fetching":{"enabled":false}}'
var http = require("https");

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

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

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

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

req.write("{\"fetching\":{\"enabled\":false}}"); req.end();

var data = "{\"fetching\":{\"enabled\":false}}";

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

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

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

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/account")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"fetching\":{\"enabled\":false}}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/account", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"fetching\":{\"enabled\":false}}", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/account")

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

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"fetching\":{\"enabled\":false}}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"fetching":{"enabled":false}}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/account")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/account");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"fetching\":{\"enabled\":false}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/account"

payload := strings.NewReader("{\"fetching\":{\"enabled\":false}}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this method to change the account options. You can enable or disable JS/CSS file minification. You can also enable/disable automatic fetching via HTTP or S3 from a remote location.

Query string

None

Body payload

Example:

{
  "fetching": {
    "enabled": false
  }
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "minify": {
      "type": "object",
      "properties": {
        "enabled": {
          "description": "Enable or disable automatic minification of JS/CSS files",
          "type": "boolean"
        }
      },
      "additionalProperties": false,
      "patterns": [],
      "required": [
        "enabled"
      ]
    },
    "fetching": {
      "type": "object",
      "properties": {
        "enabled": {
          "examples": [
            false
          ],
          "example": false,
          "type": "boolean"
        },
        "type": {
          "oneOf": [
            {
              "enum": [
                "http",
                "s3"
              ],
              "type": "string"
            }
          ]
        },
        "http": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "auth": {
                  "type": "object",
                  "properties": {
                    "enabled": {
                      "type": "boolean"
                    },
                    "username": {
                      "oneOf": [
                        {
                          "type": "string"
                        }
                      ]
                    },
                    "password": {
                      "oneOf": [
                        {
                          "type": "string"
                        }
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "patterns": [],
                  "required": [
                    "enabled"
                  ]
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                }
              },
              "additionalProperties": false,
              "patterns": [],
              "required": [
                "url"
              ]
            }
          ]
        },
        "s3": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "endpoint": {
                  "type": "string"
                },
                "accessKeyId": {
                  "type": "string"
                },
                "secretAccessKey": {
                  "type": "string"
                },
                "bucket": {
                  "type": "string"
                },
                "prefix": {
                  "type": "string"
                },
                "forcePathStyle": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false,
              "patterns": [],
              "required": [
                "accessKeyId",
                "secretAccessKey",
                "bucket"
              ]
            }
          ]
        }
      },
      "additionalProperties": false,
      "patterns": [],
      "required": [
        "enabled"
      ]
    },
    "aliases": {
      "type": "object",
      "properties": {},
      "additionalProperties": false,
      "patterns": [
        {
          "rule": {
            "type": "object",
            "properties": {
              "cdn": {
                "type": "boolean"
              },
              "prefix": {
                "type": "string"
              },
              "defaultProfile": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "patterns": []
          }
        }
      ]
    }
  },
  "additionalProperties": false,
  "patterns": []
}

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:50 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 50
< x-ratelimit-remaining: 46
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:post:account
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

/ no response body: HTTP status 200 means SUCCESS /

List or search account events

import http.client

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

payload = "{\"module\":\"fetching\"}"

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

conn.request("POST", "/v2/account/events/search", payload, headers)

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

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

curl --request POST \
  --url https://api.sirv.com/v2/account/events/search \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"module":"fetching"}'
var http = require("https");

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

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

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

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

req.write("{\"module\":\"fetching\"}"); req.end();

var data = "{\"module\":\"fetching\"}";

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

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

xhr.open("POST", "https://api.sirv.com/v2/account/events/search"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/account/events/search")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"module\":\"fetching\"}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/account/events/search", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"module\":\"fetching\"}", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/account/events/search")

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

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

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"module":"fetching"}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/account/events/search")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/account/events/search");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"module\":\"fetching\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/account/events/search"

payload := strings.NewReader("{\"module\":\"fetching\"}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

List all events triggered for account.

Query string

None

Body payload

Example:

{
  "module": "fetching"
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "module": {
      "examples": [
        "fetching"
      ],
      "example": "fetching",
      "type": "string",
      "maxLength": 64
    },
    "type": {
      "type": "string",
      "maxLength": 64
    },
    "filename": {
      "type": "string",
      "maxLength": 1000
    },
    "level": {
      "enum": [
        "error",
        "warn",
        "info"
      ],
      "type": "string"
    }
  },
  "additionalProperties": false,
  "patterns": []
}

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:51 GMT
< content-type: application/json; charset=utf-8
< content-length: 4112
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6892
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< vary: accept-encoding
< server: Sirv.API
< strict-transport-security: max-age=31536000

[
  {
    "module": "fetching",
    "type": "http",
    "level": "error",
    "filename": "/REST API Examples/missing.jpg",
    "fetching": {
      "url": "https://demo.sirv.com/missing.jpg",
      "statusCode": 404,
      "maxFilesize": 2097152,
      "contentLength": "4140",
      "error": "Request not successful: expected status code 200 but got 404"
    },
    "initiator": {
      "type": "api",
      "remoteAddr": "176.105.166.4",
      "date": "2020-07-18T11:31:32.229Z"
    },
    "notify": true,
    "_seen": false,
    "_submitted": "2020-07-18T11:31:32.612Z",
    "_accountId": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
    "_id": "8fbb11a7dd77f7f64337e581ccbce2d62fc7cda0"
  }
]

Mark account event(s) as seen

import http.client

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

payload = "[\"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba\",\"199cf48046964f8567fe49e22107c4c5d27271e7\"]"

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

conn.request("POST", "/v2/account/events/seen", payload, headers)

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

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

curl --request POST \
  --url https://api.sirv.com/v2/account/events/seen \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '["f1f5d68ef232e5d27d10f28bcef836efbb7cdeba","199cf48046964f8567fe49e22107c4c5d27271e7"]'
var http = require("https");

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

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

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

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

req.write("[\"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba\",\"199cf48046964f8567fe49e22107c4c5d27271e7\"]"); req.end();

var data = "[\"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba\",\"199cf48046964f8567fe49e22107c4c5d27271e7\"]";

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

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

xhr.open("POST", "https://api.sirv.com/v2/account/events/seen"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/account/events/seen")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("[\"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba\",\"199cf48046964f8567fe49e22107c4c5d27271e7\"]")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/account/events/seen", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "[\"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba\",\"199cf48046964f8567fe49e22107c4c5d27271e7\"]", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/account/events/seen")

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

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "[\"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba\",\"199cf48046964f8567fe49e22107c4c5d27271e7\"]"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "["f1f5d68ef232e5d27d10f28bcef836efbb7cdeba","199cf48046964f8567fe49e22107c4c5d27271e7"]".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/account/events/seen")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/account/events/seen");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "[\"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba\",\"199cf48046964f8567fe49e22107c4c5d27271e7\"]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/account/events/seen"

payload := strings.NewReader("[\"f1f5d68ef232e5d27d10f28bcef836efbb7cdeba\",\"199cf48046964f8567fe49e22107c4c5d27271e7\"]")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Add seen flag for specified account event(s)

Query string

None

Body payload

Example:

[
  "f1f5d68ef232e5d27d10f28bcef836efbb7cdeba",
  "199cf48046964f8567fe49e22107c4c5d27271e7"
]

JSON Schema:

{
  "examples": [
    [
      "f1f5d68ef232e5d27d10f28bcef836efbb7cdeba",
      "199cf48046964f8567fe49e22107c4c5d27271e7"
    ]
  ],
  "example": [
    "f1f5d68ef232e5d27d10f28bcef836efbb7cdeba",
    "199cf48046964f8567fe49e22107c4c5d27271e7"
  ],
  "type": "array",
  "maxItems": 100,
  "items": {
    "type": "string"
  }
}

Response

Example response:

< HTTP/1.1 200
< date: Tue, 21 Jul 2020 09:17:41 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6982
< x-ratelimit-reset: 1595326565
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

/ no response body: HTTP status 200 means SUCCESS /

User API

Get user info

import http.client

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

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

conn.request("GET", "/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK", headers=headers)

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

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

curl --request GET \
  --url 'https://api.sirv.com/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
var http = require("https");

var options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.end();

var data = null;

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

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

xhr.open("GET", "https://api.sirv.com/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK")

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

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/user?userId=Gt6ljl1AxwmtGBIHX0WBo3qKdtK"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to get information about a user, including their name, email and S3 key.

Query string

Parameter Type Description Example
userId string Gt6ljl1AxwmtGBIHX0WBo3qKdtK

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:52 GMT
< content-type: application/json; charset=utf-8
< content-length: 188
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6890
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "email": "restapi@sirv.com",
  "firstName": "Rest",
  "lastName": "Api",
  "dateCreated": "2020-07-17T13:55:10.462Z",
  "s3Secret": "****************************"
}

Statistics API

Get transfer stats

import http.client

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

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

conn.request("GET", "/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000", headers=headers)

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

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

curl --request GET \
  --url 'https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
var http = require("https");

var options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.end();

var data = null;

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

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

xhr.open("GET", "https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")

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

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to check how much data was transferred per day during a certain period (date from/to). The request returns aggregated HTTP log data.

Query string

Parameter Type Description Example
from date Default: 1 month ago, rounded to start of day 2020-07-01T00:00:00.000
to date Default: now, rounded to end of day 2020-07-05T00:00:00.000

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:52 GMT
< content-type: application/json; charset=utf-8
< content-length: 470
< connection: close
< x-ratelimit-limit: 100
< x-ratelimit-remaining: 96
< x-ratelimit-reset: 1595075480
< x-ratelimit-type: rest:get:stats:http
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "1593561600000": {
    "total": {
      "count": 47619,
      "size": 1440222650
    }
  },
  "1593648000000": {
    "total": {
      "count": 75944,
      "size": 2078130246
    }
  },
  "1593734400000": {
    "total": {
      "count": 44928,
      "size": 1248801543
    }
  },
  "1593820800000": {
    "total": {
      "count": 26472,
      "size": 727094151
    }
  },
  "1593907200000": {
    "total": {
      "count": 30528,
      "size": 877886049
    }
  }
}

Get spins views

import http.client

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

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

conn.request("GET", "/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000", headers=headers)

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

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

curl --request GET \
  --url 'https://api.sirv.com/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
var http = require("https");

var options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.end();

var data = null;

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

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

xhr.open("GET", "https://api.sirv.com/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")

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

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/stats/spins/views?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to get spins views stats over a certain period (date from/to). Date range is limited to 5 days.

Query string

Parameter Type Description Example
from date Default: 1 day ago 2020-07-01T00:00:00.000
to date Default: now 2020-07-05T00:00:00.000
alias string Filter by account name (alias)

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:53 GMT
< content-type: application/json; charset=utf-8
< content-length: 4286915
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6887
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< vary: accept-encoding
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

[
  {
    "@timestamp": "2020-07-04T04:54:53.632Z",
    "referer": "https://sirv.com/help/articles/360-photography-photoshop/",
    "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36",
    "user_agent_parsed": {
      "name": "Chrome",
      "os": "Windows 10",
      "os_name": "Windows",
      "os_major": "10",
      "device": "Other",
      "major": "83",
      "minor": "0",
      "patch": "4103",
      "build": "116"
    },
    "referer_proto": "https",
    "referer_host": "sirv.com",
    "referer_uripath": "/help/articles/360-photography-photoshop/",
    "event": {
      "origin": "/bag/bag.spin?autospin=infinite",
      "type": "spin",
      "name": "viewerReady",
      "data": {
        "rows": 1,
        "columns": 16,
        "viewerSize": {
          "width": 354,
          "height": 354
        }
      }
    },
    "geoip": {
      "country_code2": "IN",
      "country_name": "India",
      "region_name": "10",
      "timezone": "Asia/Calcutta",
      "real_region_name": "Haryana"
    }
  }
]

Get storage stats

import http.client

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

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

conn.request("GET", "/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000", headers=headers)

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

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

curl --request GET \
  --url 'https://api.sirv.com/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
var http = require("https");

var options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.end();

var data = null;

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

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

xhr.open("GET", "https://api.sirv.com/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")

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

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/stats/storage?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to check the total amount of data stored on a given day or each day over a certain period.

Query string

Parameter Type Description Example
from date Default: 1 month ago, rounded to start of day 2020-07-01T00:00:00.000
to date Default: now, rounded to end of day 2020-07-05T00:00:00.000

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:45:53 GMT
< content-type: application/json; charset=utf-8
< content-length: 2786
< connection: close
< x-ratelimit-limit: 100
< x-ratelimit-remaining: 96
< x-ratelimit-reset: 1595075481
< x-ratelimit-type: rest:get:stats:storage
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< vary: accept-encoding
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "1593734400000": {
    "plan": 100000000000,
    "burstable": 500000000000,
    "extra": 0,
    "used": 49238608587,
    "files": 65400,
    "quotaExceededDate": null
  },
  "1593561600000": {
    "plan": 100000000000,
    "burstable": 500000000000,
    "extra": 0,
    "used": 49238608587,
    "files": 65413,
    "quotaExceededDate": null
  },
  "1593907200000": {
    "plan": 100000000000,
    "burstable": 500000000000,
    "extra": 0,
    "used": 49404765599,
    "files": 64931,
    "quotaExceededDate": null
  },
  "1593820800000": {
    "plan": 100000000000,
    "burstable": 500000000000,
    "extra": 0,
    "used": 49360152901,
    "files": 65357,
    "quotaExceededDate": null
  },
  "1593993600000": {
    "plan": 100000000000,
    "burstable": 500000000000,
    "extra": 0,
    "used": 49404765599,
    "files": 64931,
    "quotaExceededDate": null
  },
  "1593648000000": {
    "plan": 100000000000,
    "burstable": 500000000000,
    "extra": 0,
    "used": 49238608587,
    "files": 65405,
    "quotaExceededDate": null
  },
  "1594339200000": {
    "plan": 100000000000,
    "burstable": 500000000000,
    "extra": 0,
    "used": 49404768387,
    "files": 64836,
    "quotaExceededDate": null
  },
  "1594166400000": {
    "plan": 100000000000,
    "burstable": 500000000000,
    "extra": 0,
    "used": 49404768387,
    "files": 64932,
    "quotaExceededDate": null
  },
  "1594252800000": {
    "plan": 100000000000,
    "burstable": 500000000000,
    "extra": 0,
    "used": 49404768387,
    "files": 64929,
    "quotaExceededDate": null
  },
  "1594080000000": {
    "plan": 100000000000,
    "burstable": 500000000000,
    "extra": 0,
    "used": 49404765599,
    "files": 64931,
    "quotaExceededDate": null
  },
  "1594425600000": {
    "plan": 100000000000,
    "burstable": 500000000000,
    "extra": 0,
    "used": 49404768387,
    "files": 64836,
    "quotaExceededDate": null
  },
  "1594684800000": {
    "plan": 100000000000,
    "burstable": 500000000000,
    "extra": 0,
    "used": 51853129932,
    "files": 73732,
    "quotaExceededDate": null
  },
  "1594598400000": {
    "plan": 100000000000,
    "burstable": 500000000000,
    "extra": 0,
    "used": 49921058176,
    "files": 64536,
    "quotaExceededDate": null
  },
  "1594512000000": {
    "plan": 100000000000,
    "burstable": 500000000000,
    "extra": 0,
    "used": 49428159099,
    "files": 63605,
    "quotaExceededDate": null
  },
  "1594771200000": {
    "plan": 100000000000,
    "burstable": 500000000000,
    "extra": 0,
    "used": 51841192248,
    "files": 73785,
    "quotaExceededDate": null
  },
  "1594857600000": {
    "plan": 100000000000,
    "burstable": 500000000000,
    "extra": 0,
    "used": 51850463184,
    "files": 73786,
    "quotaExceededDate": null
  }
}

Files API

Get approval flag

import http.client

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

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

conn.request("GET", "/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", headers=headers)

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

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

curl --request GET \
  --url 'https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
var http = require("https");

var options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.end();

var data = null;

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

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

xhr.open("GET", "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")

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

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to get the file approval tag and optional comment for a file. Used as part of an image review and approval process.

Query string

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

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:06 GMT
< content-type: application/json; charset=utf-8
< content-length: 100
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6873
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "datetime": "2020-07-18T11:45:10.567Z",
  "approved": false,
  "comment": "It looks too cold!"
}

Get meta description

import http.client

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

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

conn.request("GET", "/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", headers=headers)

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

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

curl --request GET \
  --url 'https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
var http = require("https");

var options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.end();

var data = null;

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

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

xhr.open("GET", "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")

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

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to check the meta description of a file or folder. For images, this is the meta field that is used for showing alt tags on images.

Query string

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

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:05 GMT
< content-type: application/json; charset=utf-8
< content-length: 46
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6880
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "description": "Blue Lake in the Winter"
}

Get product meta

import http.client

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

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

conn.request("GET", "/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", headers=headers)

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

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

curl --request GET \
  --url 'https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
var http = require("https");

var options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.end();

var data = null;

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

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

xhr.open("GET", "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")

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

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to get the product meta fields for an image. This can be used by retailers for organizing images into product groups for an ecommerce store.

Query string

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

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:07 GMT
< content-type: application/json; charset=utf-8
< content-length: 124
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6867
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "id": "LLBB77",
  "name": "Blue Lake Card",
  "brand": "BLUE LAKE LLC",
  "category1": "Cards",
  "category2": "Lakes"
}

Get file meta tags

import http.client

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

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

conn.request("GET", "/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", headers=headers)

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

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

curl --request GET \
  --url 'https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
var http = require("https");

var options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.end();

var data = null;

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

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

xhr.open("GET", "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")

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

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to get all the meta tags of a file or folder.

Query string

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

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:06 GMT
< content-type: application/json; charset=utf-8
< content-length: 81
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6876
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "tags": [
    "blue",
    "lake",
    "winter",
    "cold",
    "water"
  ]
}

Get meta title

import http.client

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

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

conn.request("GET", "/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", headers=headers)

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

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

curl --request GET \
  --url 'https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
var http = require("https");

var options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.end();

var data = null;

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

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

xhr.open("GET", "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")

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

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to check the meta title of a file or folder.

Query string

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

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:05 GMT
< content-type: application/json; charset=utf-8
< content-length: 26
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6878
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "title": "Blue Lake"
}

Get folder options

import http.client

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

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

conn.request("GET", "/v2/files/options?filename=%2FREST%20API%20Examples", headers=headers)

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

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

curl --request GET \
  --url 'https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
var http = require("https");

var options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/options?filename=%2FREST%20API%20Examples", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.end();

var data = null;

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

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

xhr.open("GET", "https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples")

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

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to check the options of a folder. It will tell you the settings for spin scanning, spin naming, public listing and folder locking (Enterprise accounts only).

Query string

Parameter Type Description Example
filename string /REST API Examples
withInherited boolean Include options inherited from parent folders

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:04 GMT
< content-type: application/json; charset=utf-8
< content-length: 48
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6882
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "scanSpins": true,
  "allowListing": false
}

Read folder contents

import http.client

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

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

conn.request("GET", "/v2/files/readdir?dirname=%2FREST%20API%20Examples", headers=headers)

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

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

curl --request GET \
  --url 'https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
var http = require("https");

var options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/readdir?dirname=%2FREST%20API%20Examples", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.end();

var data = null;

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

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

xhr.open("GET", "https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples")

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

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to check all the files within a folder. It will return the filename, mimetype, content type and file size. It will also return any folders that exist.

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: Sat, 18 Jul 2020 11:46:07 GMT
< content-type: application/json; charset=utf-8
< content-length: 1847
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6868
< 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

{
  "contents": [
    {
      "filename": "aurora.jpg",
      "mtime": "2020-07-17T15:47:36.701Z",
      "contentType": "image/webp",
      "size": 201846,
      "isDirectory": false,
      "meta": {
        "width": 2500,
        "height": 1667,
        "duration": 0
      }
    },
    {
      "filename": "aurora-copy.jpg",
      "mtime": "2020-07-18T11:46:07.194Z",
      "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": "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": "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": "uploaded.txt",
      "mtime": "2020-07-18T08:55:35.325Z",
      "contentType": "binary/octet-stream",
      "size": 0,
      "isDirectory": false,
      "meta": {}
    },
    {
      "filename": "video",
      "mtime": "2020-07-17T15:36:52.477Z",
      "size": 0,
      "isDirectory": true,
      "meta": {}
    },
    {
      "filename": "coin",
      "mtime": "2020-07-17T13:31:08.833Z",
      "size": 0,
      "isDirectory": true,
      "meta": {}
    }
  ]
}

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

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 directory

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 directory.

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: Sat, 18 Jul 2020 11:46:07 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 3000
< x-ratelimit-remaining: 2996
< x-ratelimit-reset: 1595075495
< x-ratelimit-type: rest:post:files:delete
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

/ no response body: HTTP status 200 means SUCCESS /

Fetch URL

import http.client

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

payload = "[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]"

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

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

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

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

curl --request POST \
  --url https://api.sirv.com/v2/files/fetch \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '[{"url":"https://demo.sirv.com/aurora.jpg","filename":"/REST API Examples/aurora.jpg"},{"url":"https://demo.sirv.com/missing.jpg","filename":"/REST API Examples/missing.jpg"}]'
var http = require("https");

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

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

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

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

req.write("[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]"); req.end();

var data = "[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]";

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

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

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

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/fetch")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/fetch", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "[{\"url</span>":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url</span>":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/fetch")

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

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "[{"url":"https://demo.sirv.com/aurora.jpg","filename":"/REST API Examples/aurora.jpg"},{"url":"https://demo.sirv.com/missing.jpg","filename":"/REST API Examples/missing.jpg"}]".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/fetch")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/fetch");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/fetch"

payload := strings.NewReader("[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to fetch a file(s) from a URL via HTTP and save it to your Sirv account. This can be any URL, either public or private (via HTTP authentication). In the url parameter, enter the full URL of the remote file. In the filename parameter, enter the folder path and filename where it should be saved e.g. /path/to/folder/new-filename.jpg. If the folder path does not already exist in your Sirv account new folder(s) will be created.

Query string

None

Body payload

Example:

[
  {
    "url": "https://demo.sirv.com/aurora.jpg",
    "filename": "/REST API Examples/aurora.jpg"
  },
  {
    "url": "https://demo.sirv.com/missing.jpg",
    "filename": "/REST API Examples/missing.jpg"
  }
]

JSON Schema:

{
  "examples": [
    [
      {
        "url": "https://demo.sirv.com/aurora.jpg",
        "filename": "/REST API Examples/aurora.jpg"
      },
      {
        "url": "https://demo.sirv.com/missing.jpg",
        "filename": "/REST API Examples/missing.jpg"
      }
    ]
  ],
  "example": [
    {
      "url": "https://demo.sirv.com/aurora.jpg",
      "filename": "/REST API Examples/aurora.jpg"
    },
    {
      "url": "https://demo.sirv.com/missing.jpg",
      "filename": "/REST API Examples/missing.jpg"
    }
  ],
  "type": "array",
  "maxItems": 20,
  "items": {
    "type": "object",
    "properties": {
      "url": {
        "type": "string",
        "maxLength": 1024
      },
      "filename": {
        "type": "string",
        "pattern": "^\\/",
        "maxLength": 1024
      },
      "auth": {
        "type": "object",
        "properties": {
          "username": {
            "type": "string",
            "maxLength": 256
          },
          "password": {
            "type": "string",
            "maxLength": 256
          }
        },
        "additionalProperties": false,
        "patterns": []
      },
      "wait": {
        "type": "boolean"
      }
    },
    "additionalProperties": false,
    "patterns": [],
    "required": [
      "url",
      "filename"
    ]
  }
}

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:04 GMT
< content-type: application/json; charset=utf-8
< content-length: 9882
< connection: close
< x-ratelimit-limit: 2000
< x-ratelimit-remaining: 1996
< x-ratelimit-reset: 1595075492
< x-ratelimit-type: rest:post:files:fetch
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< vary: accept-encoding
< server: Sirv.API
< strict-transport-security: max-age=31536000

[
  {
    "filename": "/REST API Examples/aurora.jpg",
    "success": true,
    "attempted": false,
    "attempts": [
      {
        "url": "https://demo.sirv.com/aurora.jpg",
        "initiator": {
          "type": "api",
          "remoteAddr": "176.105.166.4",
          "date": "2020-07-17T15:47:35.316Z"
        },
        "statusCode": 200,
        "headers": {
          "result": {
            "version": "HTTP/1.1",
            "code": 200,
            "reason": "OK"
          },
          "Date": "Fri, 17 Jul 2020 15:47:36 GMT",
          "Content-Type": "image/webp",
          "Content-Length": "201846",
          "Connection": "keep-alive",
          "Last-Modified": "Fri, 17 Jul 2020 15:47:36 GMT",
          "ETag": "\"5f11c818-31476\"",
          "Server": "Sirv.Imagination",
          "X-Sirv-Server": "c1-extra1-fireball-13",
          "X-Sirv-Cache": "MISS",
          "Access-Control-Allow-Origin": "*",
          "Access-Control-Allow-Headers": "*",
          "Expires": "Sun, 16 Aug 2020 15:47:36 GMT",
          "Cache-Control": "max-age=2592000",
          "X-Sirv-Meta-Width": "2500",
          "X-Sirv-Meta-Height": "1667",
          "X-Sirv-Shard": "c1-riak1",
          "X-Account-Id": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
          "X-File-VersionId": "5evxYG8lnBgeA7cGBRTZzq7JQolRYviN:0",
          "X-Account-Serial": "2020-06-15T19:18:53.901Z",
          "Accept-Ranges": "bytes"
        },
        "timing": {
          "ns": 0.007514,
          "connect": 0.007912,
          "start": 0.48724,
          "total": 0.489622
        },
        "date": "2020-07-17T15:47:36.712Z"
      }
    ],
    "retryAfter": "2020-07-18T15:47:36.712Z"
  },
  {
    "filename": "/REST API Examples/missing.jpg",
    "success": false,
    "attempted": false,
    "attempts": [
      {
        "url": "https://demo.sirv.com/missing.jpg",
        "initiator": {
          "type": "api",
          "remoteAddr": "176.105.166.4",
          "date": "2020-07-18T08:35:51.026Z"
        },
        "statusCode": 404,
        "headers": {
          "result": {
            "version": "HTTP/1.1",
            "code": 404,
            "reason": "Not Found"
          },
          "Date": "Sat, 18 Jul 2020 08:35:52 GMT",
          "Content-Type": "text/html; charset=utf-8",
          "Content-Length": "4140",
          "Connection": "keep-alive",
          "Vary": "Accept-Encoding",
          "X-Account-Id": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
          "X-Account-Serial": "2020-06-15T19:18:53.901Z",
          "ETag": "W/\"102c-wKpRt+Cg9Cnw/NpTSkF5+w\"",
          "X-Sirv-Cache": "MISS",
          "Server": "Sirv.Imagination",
          "X-Sirv-Server": "c1-extra1-fireball-15",
          "Access-Control-Allow-Origin": "*",
          "Access-Control-Allow-Headers": "*"
        },
        "timing": {
          "ns": 0.018986,
          "connect": 0.019303,
          "start": 0.103774,
          "total": 0.103829
        },
        "error": {
          "name": "Error",
          "message": "Request not successful: expected status code 200 but got 404"
        },
        "date": "2020-07-18T08:35:52.089Z"
      }
    ],
    "retryAfter": "2020-07-18T12:07:32.613Z"
  }
]

Get JWT protected URL

import http.client

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

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

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

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

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

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

curl --request POST \
  --url https://api.sirv.com/v2/files/jwt \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"filename":"/REST API Examples/aurora.jpg","key":"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq","alias":"demo-jwt","secureParams":{"w":300,"h":300},"expiresIn":300}'
var http = require("https");

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

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

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

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

req.write("{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}"); req.end();

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

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

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

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

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/jwt")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/jwt", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"filename</span>":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/jwt")

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

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"filename":"/REST API Examples/aurora.jpg","key":"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq","alias":"demo-jwt","secureParams":{"w":300,"h":300},"expiresIn":300}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/jwt")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/jwt");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/jwt"

payload := strings.NewReader("{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to generate a secure file URL, protected with JWT (JSON Web Token).

Query string

None

Body payload

Example:

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

JSON Schema:

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

Response

Example response:

< HTTP/1.1 200
< date: Sat, 21 Nov 2020 07:44:30 GMT
< content-type: application/json; charset=utf-8
< content-length: 286
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6929
< x-ratelimit-reset: 1605948149
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "url": "https://demo-jwt.sirv.com/REST API Examples/aurora.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcmdzIjp7InciOjMwMCwiaCI6MzAwfSwiaWF0IjoxNjA1OTQ0NjcwLCJleHAiOjE2MDU5NDQ5NzAsImF1ZCI6Ii9SRVNUIEFQSSBFeGFtcGxlcy9hdXJvcmEuanBnIn0.c9FlTRZw_-t3WcMc0FPOhINrDZGrLKH2DuUn2H16yq4"
}

Set approval flag

import http.client

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

payload = "{\"approved\":false,\"comment\":\"It looks too cold!\"}"

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

conn.request("POST", "/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", payload, headers)

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

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

curl --request POST \
  --url 'https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"approved":false,"comment":"It looks too cold!"}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.write("{\"approved\":false,\"comment\":\"It looks too cold!\"}"); req.end();

var data = "{\"approved\":false,\"comment\":\"It looks too cold!\"}";

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

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

xhr.open("POST", "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"approved\":false,\"comment\":\"It looks too cold!\"}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"approved</span>":false,\"comment\":\"It looks too cold!\"}", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")

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

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"approved\":false,\"comment\":\"It looks too cold!\"}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"approved":false,"comment":"It looks too cold!"}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"approved\":false,\"comment\":\"It looks too cold!\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"

payload := strings.NewReader("{\"approved\":false,\"comment\":\"It looks too cold!\"}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to set the file approval tag (approved or not) and an optional comment. Used as part of an image review and approval process.

Query string

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

Body payload

Example:

{
  "approved": false,
  "comment": "It looks too cold!"
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "approved": {
      "examples": [
        false
      ],
      "example": false,
      "type": "boolean"
    },
    "comment": {
      "examples": [
        "It looks too cold!"
      ],
      "example": "It looks too cold!",
      "oneOf": [
        {
          "type": "string",
          "maxLength": 256
        }
      ]
    }
  },
  "additionalProperties": false,
  "patterns": [],
  "required": [
    "approved"
  ]
}

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:06 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6872
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

/ no response body: HTTP status 200 means SUCCESS /

Set product meta

import http.client

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

payload = "{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}"

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

conn.request("POST", "/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", payload, headers)

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

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

curl --request POST \
  --url 'https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"id":"LLBB77","name":"Blue Lake Card","brand":"BLUE LAKE LLC","category1":"Cards","category2":"Lakes"}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.write("{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}"); req.end();

var data = "{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}";

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

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

xhr.open("POST", "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"id</span>":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")

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

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"id":"LLBB77","name":"Blue Lake Card","brand":"BLUE LAKE LLC","category1":"Cards","category2":"Lakes"}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"

payload := strings.NewReader("{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to set product meta fields for an image. This can be used by retailers for organizing images into product groups for an ecommerce store.

Query string

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

Body payload

Example:

{
  "id": "LLBB77",
  "name": "Blue Lake Card",
  "brand": "BLUE LAKE LLC",
  "category1": "Cards",
  "category2": "Lakes"
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "id": {
      "examples": [
        "LLBB77"
      ],
      "example": "LLBB77",
      "type": "string",
      "maxLength": 256
    },
    "name": {
      "examples": [
        "Blue Lake Card"
      ],
      "example": "Blue Lake Card",
      "type": "string",
      "maxLength": 256
    },
    "brand": {
      "examples": [
        "BLUE LAKE LLC"
      ],
      "example": "BLUE LAKE LLC",
      "type": "string",
      "maxLength": 256
    },
    "category1": {
      "examples": [
        "Cards"
      ],
      "example": "Cards",
      "type": "string",
      "maxLength": 256
    },
    "category2": {
      "examples": [
        "Lakes"
      ],
      "example": "Lakes",
      "type": "string",
      "maxLength": 256
    }
  },
  "additionalProperties": false,
  "patterns": []
}

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:08 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6866
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

/ no response body: HTTP status 200 means SUCCESS /

Set meta description

import http.client

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

payload = "{\"description\":\"Blue Lake in the Winter\"}"

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

conn.request("POST", "/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", payload, headers)

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

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

curl --request POST \
  --url 'https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"description":"Blue Lake in the Winter"}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.write("{\"description\":\"Blue Lake in the Winter\"}"); req.end();

var data = "{\"description\":\"Blue Lake in the Winter\"}";

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

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

xhr.open("POST", "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"description\":\"Blue Lake in the Winter\"}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"description</span>":\"Blue Lake in the Winter\"}", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")

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

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"description\":\"Blue Lake in the Winter\"}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"description":"Blue Lake in the Winter"}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"description\":\"Blue Lake in the Winter\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"

payload := strings.NewReader("{\"description\":\"Blue Lake in the Winter\"}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to set/change the meta description of a file or folder. For images, this is the meta field that is used for showing alt tags on images.

Query string

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

Body payload

Example:

{
  "description": "Blue Lake in the Winter"
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "description": {
      "examples": [
        "Blue Lake in the Winter"
      ],
      "example": "Blue Lake in the Winter",
      "type": "string"
    }
  },
  "additionalProperties": false,
  "patterns": [],
  "required": [
    "description"
  ]
}

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:05 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6879
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

/ no response body: HTTP status 200 means SUCCESS /

Add file meta tags

import http.client

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

payload = "{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}"

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

conn.request("POST", "/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", payload, headers)

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

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

curl --request POST \
  --url 'https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"tags":["blue","lake","winter","cold","water"]}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.write("{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}"); req.end();

var data = "{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}";

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

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

xhr.open("POST", "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")

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

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"tags":["blue","lake","winter","cold","water"]}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"

payload := strings.NewReader("{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to add a meta tag to a file or folder.

Query string

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

Body payload

Example:

{
  "tags": [
    "blue",
    "lake",
    "winter",
    "cold",
    "water"
  ]
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "tags": {
      "examples": [
        [
          "blue",
          "lake",
          "winter",
          "cold",
          "water"
        ]
      ],
      "example": [
        "blue",
        "lake",
        "winter",
        "cold",
        "water"
      ],
      "type": "array",
      "maxItems": 50,
      "items": {
        "type": "string"
      }
    }
  },
  "additionalProperties": false,
  "patterns": [],
  "required": [
    "tags"
  ]
}

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:06 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6875
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

/ no response body: HTTP status 200 means SUCCESS /

Set meta title

import http.client

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

payload = "{\"title\":\"Blue Lake\"}"

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

conn.request("POST", "/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", payload, headers)

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

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

curl --request POST \
  --url 'https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"title":"Blue Lake"}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.write("{\"title\":\"Blue Lake\"}"); req.end();

var data = "{\"title\":\"Blue Lake\"}";

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

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

xhr.open("POST", "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"title\":\"Blue Lake\"}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"title</span>":\"Blue Lake\"}", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")

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

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"title\":\"Blue Lake\"}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"title":"Blue Lake"}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"title\":\"Blue Lake\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"

payload := strings.NewReader("{\"title\":\"Blue Lake\"}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to set the meta title of a file or folder.

Query string

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

Body payload

Example:

{
  "title": "Blue Lake"
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "title": {
      "examples": [
        "Blue Lake"
      ],
      "example": "Blue Lake",
      "type": "string"
    }
  },
  "additionalProperties": false,
  "patterns": [],
  "required": [
    "title"
  ]
}

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:05 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6877
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

/ no response body: HTTP status 200 means SUCCESS /

Set folder options

import http.client

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

payload = "{\"scanSpins\":true,\"allowListing\":false}"

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

conn.request("POST", "/v2/files/options?filename=%2FREST%20API%20Examples", payload, headers)

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

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

curl --request POST \
  --url 'https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"scanSpins":true,"allowListing":false}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/options?filename=%2FREST%20API%20Examples", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

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

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

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

req.write("{\"scanSpins\":true,\"allowListing\":false}"); req.end();

var data = "{\"scanSpins\":true,\"allowListing\":false}";

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

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

xhr.open("POST", "https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"scanSpins\":true,\"allowListing\":false}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"scanSpins\":true,\"allowListing\":false}", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples")

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

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"scanSpins\":true,\"allowListing\":false}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"scanSpins":true,"allowListing":false}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"scanSpins\":true,\"allowListing\":false}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/options?filename=%2FREST%20API%20Examples"

payload := strings.NewReader("{\"scanSpins\":true,\"allowListing\":false}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to change the folder options. You can enable/disable spin scanning, change the spin naming convention and enable/disable publicly viewable folder listings.

Query string

Parameter Type Description Example
filename string /REST API Examples

Body payload

Example:

{
  "scanSpins": true,
  "allowListing": false
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "scanSpins": {
      "examples": [
        true
      ],
      "example": true,
      "type": "boolean"
    },
    "nameSpinsAfterFolder": {
      "type": "boolean"
    },
    "allowListing": {
      "examples": [
        false
      ],
      "example": false,
      "type": "boolean"
    }
  },
  "additionalProperties": false,
  "patterns": []
}

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:05 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6881
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

/ no response body: HTTP status 200 means SUCCESS /

Search files

import http.client

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

payload = "{\"query\":\"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash\",\"sort\":{\"filename.raw\":\"asc\"},\"from\":0,\"size\":5}"

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

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

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

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

curl --request POST \
  --url https://api.sirv.com/v2/files/search \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"query":"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash","sort":{"filename.raw":"asc"},"from":0,"size":5}'
var http = require("https");

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

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

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

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

req.write("{\"query\":\"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash\",\"sort\":{\"filename.raw\":\"asc\"},\"from\":0,\"size\":5}"); req.end();

var data = "{\"query\":\"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash\",\"sort\":{\"filename.raw\":\"asc\"},\"from\":0,\"size\":5}";

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

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

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

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/search")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"query\":\"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash\",\"sort\":{\"filename.raw\":\"asc\"},\"from\":0,\"size\":5}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/search", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"query</span>":\"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash\",\"sort\":{\"filename.raw\":\"asc\"},\"from\":0,\"size\":5}", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/search")

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

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"query\":\"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash\",\"sort\":{\"filename.raw\":\"asc\"},\"from\":0,\"size\":5}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"query":"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\/.Trash","sort":{"filename.raw":"asc"},"from":0,"size":5}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/search")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/search");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"query\":\"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash\",\"sort\":{\"filename.raw\":\"asc\"},\"from\":0,\"size\":5}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/search"

payload := strings.NewReader("{\"query\":\"extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash\",\"sort\":{\"filename.raw\":\"asc\"},\"from\":0,\"size\":5}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to search for files with a certain name, location, extension, type, created/modified time or with some specific meta information.

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: Sat, 18 Jul 2020 11:45:56 GMT
< content-type: application/json; charset=utf-8
< content-length: 5403
< connection: close
< x-ratelimit-limit: 1000
< x-ratelimit-remaining: 996
< x-ratelimit-reset: 1595075483
< 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": "A337z9ylnhT9tyCnmzy8CGDmylK6DhOz",
        "ctime": "2020-07-18T11:45:11.231Z",
        "mtime": "2020-07-18T11:45:11.282Z",
        "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": "2020-07-17T15:47:36.701Z",
        "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": "ac9224d68ecaa7e6b2b2ddbd840190c190391db2",
      "_score": null,
      "_routing": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
      "_source": {
        "accountId": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
        "filename": "/REST API Examples/birdbath.jpg",
        "dirname": "/REST API Examples",
        "basename": "birdbath.jpg",
        "extension": ".jpg",
        "id": "Husg8zi0IBla2fl98FjTvc16ojcKm0TR",
        "ctime": "2020-07-17T13:31:39.348Z",
        "mtime": "2020-07-17T13:31:39.385Z",
        "size": 73151,
        "contentType": "image/jpeg",
        "meta": {
          "width": 620,
          "height": 372,
          "format": "JPEG",
          "duration": 0
        }
      },
      "sort": [
        "/REST API Examples/birdbath.jpg"
      ]
    },
    {
      "_index": "sirvfs-v3",
      "_type": "_doc",
      "_id": "1b86315bcaadbc77626f40f0bf9e2ed63c370194",
      "_score": null,
      "_routing": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
      "_source": {
        "accountId": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
        "filename": "/REST API Examples/blue-lake.jpg",
        "dirname": "/REST API Examples",
        "basename": "blue-lake.jpg",
        "extension": ".jpg",
        "id": "t8b6TbESDLYThXazo9KUCGWilVXq6fOo",
        "ctime": "2020-07-17T13:31:39.347Z",
        "mtime": "2020-07-17T13:31:39.450Z",
        "size": 587065,
        "contentType": "image/jpeg",
        "meta": {
          "title": "Blue Lake",
          "description": "Blue Lake in the Winter",
          "tags": [
            "blue",
            "lake",
            "winter",
            "cold",
            "water"
          ],
          "approval": {
            "approved": false,
            "datetime": "2020-07-18T11:45:10.567Z"
          },
          "product": {
            "id": "LLBB77",
            "name": "Blue Lake Card",
            "brand": "BLUE LAKE LLC",
            "category1": "Cards",
            "category2": "Lakes"
          },
          "width": 1578,
          "height": 1002,
          "format": "JPEG",
          "duration": 0,
          "EXIF": {
            "DateTimeOriginal": "2018-01-01T13:57:00Z",
            "CreateDate": "2018-01-01T13:57:00Z",
            "ModifyDate": "2018-01-02T19:26:34Z",
            "ImageDescription": "cof",
            "Make": "HUAWEI",
            "Model": "EVA-L09"
          }
        }
      },
      "sort": [
        "/REST API Examples/blue-lake.jpg"
      ]
    },
    {
      "_index": "sirvfs-v3",
      "_type": "_doc",
      "_id": "57c6df356e0db18178a2b188ff0c2f8c352d7efe",
      "_score": null,
      "_routing": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
      "_source": {
        "accountId": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
        "filename": "/REST API Examples/coin/coin_01.jpg",
        "dirname": "/REST API Examples/coin",
        "basename": "coin_01.jpg",
        "extension": ".jpg",
        "id": "kkzhuxEQEVixRk6o4G1QjrQ0ih0VGVNi",
        "ctime": "2020-07-17T13:31:08.874Z",
        "mtime": "2020-07-17T13:31:08.893Z",
        "size": 135255,
        "contentType": "image/jpeg",
        "meta": {
          "width": 1056,
          "height": 1056,
          "format": "JPEG",
          "duration": 0,
          "EXIF": {
            "ModifyDate": "2018-02-03T17:12:43Z",
            "ColorSpace": "Uncalibrated"
          }
        }
      },
      "sort": [
        "/REST API Examples/coin/coin_01.jpg"
      ]
    }
  ],
  "total": 9970,
  "_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 this API method to scroll through search results.

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"
}

Upload file

import http.client

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

payload = open('/path/to/local-image.jpg', 'rb')

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

conn.request("POST", "/v2/files/upload?filename=%2Fpath%2Fto%2Fuploaded-image.jpg", payload, headers)

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

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

curl --request POST \
 --url 'https://api.sirv.com/v2/files/upload?filename=%2Fpath%2Fto%2Fuploaded-image.jpg' \
 --header 'authorization: Bearer BEARER_TOKEN_HERE' \
 --header 'content-type: image/jpeg'  \
 --data "@/path/to/local-file.jpg"
var http = require("https");
var fs = require("fs");

fs.readFile('/path/to/local-image.jpg', (err, fileData) => { if (err) throw err