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

Getting started

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

First, please create an API client...

API client

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

Create API Client

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

API Client Credentials

Connect to Sirv API

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

Get bearer token

import http.client

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

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

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

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

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

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

curl --request POST \
  --url https://api.sirv.com/v2/token \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"clientId":"ZcnZNfzwRhQExoHFoGpxWJ4p2R","clientSecret":"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q=="}'
const http = require("https");

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

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

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

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

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

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

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

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

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

xhr.send(data);

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

$curl = curl_init();

curl_setopt_array($curl, [ CURLOPT_URL => "https://api.sirv.com/v2/token", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}", CURLOPT_HTTPHEADER => [ "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ], ]);

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

curl_close($curl);

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

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

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

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

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}"

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

import Foundation

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

let postData = NSData(data: "{"clientId":"ZcnZNfzwRhQExoHFoGpxWJ4p2R","clientSecret":"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q=="}".data(using: String.Encoding.utf8)!)

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

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

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/token");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

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

func main() {

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

payload := strings.NewReader("{\"clientId\":\"ZcnZNfzwRhQExoHFoGpxWJ4p2R\",\"clientSecret\":\"TM3d0CfXxusKMpH3x7kHJYD40qJIR3omTIGXP6wPPkXpIUKLEz/dOJ9v6LbXra3y67XsaGK7iQPmnAuD+fzj+Q==\"}")

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

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

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

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

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

}

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

Query string

None

Body payload

Example:

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

JSON Schema:

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

Response

Example response:

< HTTP/1.1 200
< date: Tue, 27 Jun 2023 10:09:54 GMT
< content-type: application/json; charset=utf-8
< content-length: 697
< connection: close
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRJZCI6IlpjblpOZnp3UmhRRXhvSEZvR3B4V0o0cDJSIiwiY2xpZW50TmFtZSI6Ik15IHdlYnNpdGUiLCJzY29wZSI6WyJhY2NvdW50OnJlYWQiLCJhY2NvdW50OndyaXRlIiwidXNlcjpyZWFkIiwidXNlcjp3cml0ZSIsImJpbGxpbmc6cmVhZCIsImJpbGxpbmc6d3JpdGUiLCJmaWxlczpyZWFkIiwiZmlsZXM6d3JpdGUiLCJ2aWRlb3MiLCJpbWFnZXMiXSwiaWF0IjoxNjg3ODYwNTk0LCJleHAiOjE2ODc4NjE3OTQsImF1ZCI6Ijk1cnR2cGxuY3p1Y25sZ2llNm1qdXUyaWI3Z29ncXoyIn0.jnFixXD4uWOXq4qiDk7yvXyNfso2fv0VUUlubbMlfD4",
  "expiresIn": 1200,
  "scope": [
    "account:read",
    "account:write",
    "user:read",
    "user:write",
    "billing:read",
    "billing:write",
    "files:read",
    "files:write",
    "videos",
    "images"
  ]
}

Account API

Get account info

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

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

Query string

None

Body payload

None

Response

Example response:

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

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

Get API limits

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

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

Query string

None

Body payload

None

Response

Example response:

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

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

Get storage info

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

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

Query string

None

Body payload

None

Response

Example response:

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

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

Get users

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

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

Query string

None

Body payload

None

Response

Example response:

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

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

Get billing info

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

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

Query string

None

Body payload

None

Response

Example response:

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

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

Update account info

import http.client

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

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

}

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

Query string

None

Body payload

Example:

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

JSON Schema:

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

Response

Example response:

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

/ no response body: HTTP status 200 means SUCCESS /

List or search account events

import http.client

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

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

}

List all events triggered for account.

Query string

None

Body payload

Example:

{
  "module": "fetching"
}

JSON Schema:

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

Response

Example response:

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

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

Mark account event(s) as seen

import http.client

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

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

}

Add seen flag for specified account event(s)

Query string

None

Body payload

Example:

[
  "f1f5d68ef232e5d27d10f28bcef836efbb7cdeba",
  "199cf48046964f8567fe49e22107c4c5d27271e7"
]

JSON Schema:

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

Response

Example response:

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

/ no response body: HTTP status 200 means SUCCESS /

User API

Get user info

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

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

Query string

Parameter Type Description Example
userId string Gt6ljl1AxwmtGBIHX0WBo3qKdtK

Body payload

None

Response

Example response:

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

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

Statistics API

Get transfer stats

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

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

Query string

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

Body payload

None

Response

Example response:

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

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

Get spins views

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

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

Query string

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

Body payload

None

Response

Example response:

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

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

Get storage stats

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

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

Query string

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

Body payload

None

Response

Example response:

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

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

Files API

Get approval flag

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

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

Query string

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

Body payload

None

Response

Example response:

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

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

Get meta description

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

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

Query string

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

Body payload

None

Response

Example response:

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

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

Get product meta

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

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

Query string

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

Body payload

None

Response

Example response:

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

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

Get file meta tags

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

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

Query string

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

Body payload

None

Response

Example response:

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

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

Get meta title

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

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

Query string

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

Body payload

None

Response

Example response:

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

{
  "title": "Blue Lake"
}

Get all file meta

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

const data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

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

Query string

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

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Mon, 31 Jul 2023 12:01:23 GMT
< content-type: application/json; charset=utf-8
< content-length: 424
< connection: close
< x-global-ratelimit-limit: 7000
< x-global-ratelimit-remaining: 6955
< x-global-ratelimit-reset: 1690807228
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "tags": [
    "lake",
    "water",
    "winter",
    "cold",
    "blue"
  ],
  "title": "Blue Lake",
  "description": "Blue Lake in the Winter",
  "product": {
    "id": "LLBB77",
    "name": "Blue Lake Card",
    "brand": "BLUE LAKE LLC",
    "category1": "Cards",
    "category2": "Lakes"
  },
  "approval": {
    "datetime": "2023-07-31T12:01:23.395Z",
    "approved": false,
    "comment": "It looks too cold!"
  }
}

Get folder options

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

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

Query string

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

Body payload

None

Response

Example response:

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

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

Read folder contents

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

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

import Foundation

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

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

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

dataTask.resume()

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

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

func main() {

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

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

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

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

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

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

}

Use this API method to get a list of all the files/folders within a folder. It will return the filename, mimetype, content type and file size. It will also return any folders that exist. A page of up to 100 results will be returned - use the 'continuation' field to request additional pages.

Query string

Parameter Type Description Example
dirname string /REST API Examples
continuation string Send it to get next page of results

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Thu, 23 Jun 2022 17:17:35 GMT
< content-type: application/json; charset=utf-8
< content-length: 2250
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6967
< x-ratelimit-reset: 1656008218
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< vary: accept-encoding
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "contents": [
    {
      "filename": "aurora3.jpg",
      "mtime": "2020-11-18T19:55:13.459Z",
      "contentType": "image/webp",
      "size": 201846,
      "isDirectory": false,
      "meta": {
        "width": 2500,
        "height": 1667,
        "duration": 0
      }
    },
    {
      "filename": "aurora.jpg",
      "mtime": "2022-06-23T17:17:32.585Z",
      "contentType": "image/webp",
      "size": 201846,
      "isDirectory": false,
      "meta": {
        "width": 2500,
        "height": 1667,
        "duration": 0
      }
    },
    {
      "filename": "birdbath.jpg",
      "mtime": "2020-07-17T13:31:39.385Z",
      "contentType": "image/jpeg",
      "size": 73151,
      "isDirectory": false,
      "meta": {
        "width": 620,
        "height": 372,
        "duration": 0
      }
    },
    {
      "filename": "video.mp4",
      "mtime": "2020-07-17T15:35:20.375Z",
      "contentType": "video/mp4",
      "size": 12860989,
      "isDirectory": false,
      "meta": {
        "width": 1372,
        "height": 1080,
        "duration": 33.434
      }
    },
    {
      "filename": "video",
      "mtime": "2020-07-17T15:36:52.477Z",
      "size": 0,
      "isDirectory": true,
      "meta": {}
    },
    {
      "filename": "uploaded.txt",
      "mtime": "2022-06-23T17:17:34.898Z",
      "contentType": "text/plain",
      "size": 0,
      "isDirectory": false,
      "meta": {}
    },
    {
      "filename": "coin",
      "mtime": "2020-07-17T13:31:08.833Z",
      "size": 0,
      "isDirectory": true,
      "meta": {}
    },
    {
      "filename": "copies",
      "mtime": "2020-12-09T09:40:13.049Z",
      "size": 0,
      "isDirectory": true,
      "meta": {}
    },
    {
      "filename": "blue-lake.jpg",
      "mtime": "2020-07-17T13:31:39.450Z",
      "contentType": "image/jpeg",
      "size": 587065,
      "isDirectory": false,
      "meta": {
        "width": 1578,
        "height": 1002,
        "duration": 0
      }
    },
    {
      "filename": "aurora-copy.jpg",
      "mtime": "2022-06-23T17:17:35.452Z",
      "contentType": "image/webp",
      "size": 201846,
      "isDirectory": false,
      "meta": {
        "width": 2500,
        "height": 1667,
        "duration": 0
      }
    }
  ]
}

Get file info

import http.client

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

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

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

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

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

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

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

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

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

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

req.end();

var data = null;

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

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

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

xhr.send(data);

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

$curl = curl_init();

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

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

curl_close($curl);

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

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

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

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

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

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/stat?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/stat?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/stat?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to get information about a file, including created time, modified time, content type and size. It returns Unix information.

Query string

Parameter Type Description Example
filename string /REST API Examples/blue-lake.jpg

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:08 GMT
< content-type: application/json; charset=utf-8
< content-length: 227
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6865
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "mtime": "2020-07-17T13:31:39.450Z",
  "ctime": "2020-07-17T13:31:39.347Z",
  "contentType": "image/jpeg",
  "size": 587065,
  "isDirectory": false,
  "meta": {
    "width": 1578,
    "height": 1002,
    "duration": 0
  }
}

Download file

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("GET", "/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt", headers=headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request GET \
  --url 'https://api.sirv.com/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
var http = require("https");

var options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

var req = http.request(options, function (res) { var chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.end();

var data = null;

var xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } });

xhr.open("GET", "https://api.sirv.com/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt")

http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/download?filename=%2FREST%20API%20Examples%2Fuploaded.txt"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to download a single file from an account.

Query string

Parameter Type Description Example
filename string /REST API Examples/uploaded.txt

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Mon, 09 Aug 2021 13:31:31 GMT
< content-type: text/plain; charset=utf-8
< content-length: 0
< connection: close
< last-modified: Mon, 09 Aug 2021 13:31:31 GMT
< cache-control: max-age=86400
< etag: "61112e33-0"
< server: Sirv.API
< expires: Tue, 10 Aug 2021 13:31:31 GMT
< strict-transport-security: max-age=31536000
< accept-ranges: bytes

/ no response body: HTTP status 200 means SUCCESS /

Get user points of interest

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("GET", "/v2/files/poi", headers=headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request GET \
  --url https://api.sirv.com/v2/files/poi \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
const http = require("https");

const options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/poi", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

const req = http.request(options, function (res) { const chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.end();

const data = null;

const xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } });

xhr.open("GET", "https://api.sirv.com/v2/files/poi"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/poi")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [ CURLOPT_URL => "https://api.sirv.com/v2/files/poi", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ], ]);

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/poi")

http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/poi")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/poi");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/poi"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to get coordinates of all the POI (points of interest) on the image.

Query string

Parameter Type Description Example
filename string /REST API Examples/blue-lake.jpg

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Wed, 21 Jun 2023 16:13:11 GMT
< content-type: application/json; charset=utf-8
< content-length: 87
< connection: close
< x-global-ratelimit-limit: 7000
< x-global-ratelimit-remaining: 6845
< x-global-ratelimit-reset: 1687364368
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "BlueLake": {
    "x": 0.5,
    "y": 0.5,
    "width": 0.5,
    "height": 0.5
  }
}

Get results of ZIP job

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("GET", "/v2/files/zip", headers=headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request GET \
  --url https://api.sirv.com/v2/files/zip \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
const http = require("https");

const options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/zip", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

const req = http.request(options, function (res) { const chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.end();

const data = null;

const xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } });

xhr.open("GET", "https://api.sirv.com/v2/files/zip"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.get("https://api.sirv.com/v2/files/zip")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [ CURLOPT_URL => "https://api.sirv.com/v2/files/zip", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ], ]);

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/zip")

http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/zip")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/zip");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/zip"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this method to get results and progress of ZIP job created with POST /files/zip method

Query string

Parameter Type Description Example
id string BLDgbVfrCYcLOceNSEf2ymIwLGQDXSCI

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Mon, 05 Feb 2024 13:30:28 GMT
< content-type: application/json; charset=utf-8
< content-length: 191
< connection: close
< x-global-ratelimit-limit: 7000
< x-global-ratelimit-remaining: 6681
< x-global-ratelimit-reset: 1707142905
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "progress": 100,
  "result": [
    {
      "filename": "Sirv January 18, 2023.zip",
      "size": 138237,
      "url": "https://goto.sirv.com/AvhriHTv7nOrMvgBBtPHy1tH1hbaeFCi"
    }
  ]
}

Get results of batch delete job

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("GET", "/v2/files/batch/delete", headers=headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request GET \
  --url https://api.sirv.com/v2/files/batch/delete \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
const http = require("https");

const options = { "method": "GET", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/batch/delete", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

const req = http.request(options, function (res) { const chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.end();

const data = null;

const xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } });

xhr.open("GET", "https://api.sirv.com/v2/files/batch/delete"); 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/batch/delete")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [ CURLOPT_URL => "https://api.sirv.com/v2/files/batch/delete", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ], ]);

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/batch/delete")

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/batch/delete")! 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/batch/delete");
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/batch/delete"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this method to get results and progress of batch delete job created with POST /files/batch/delete method

Query string

Parameter Type Description Example
id string BLDgbVfrCYcLOceNSEf2ymIwLGQDXSCI

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Thu, 24 Oct 2024 06:53:45 GMT
< content-type: application/json; charset=utf-8
< content-length: 2
< connection: close
< x-global-ratelimit-limit: 7000
< x-global-ratelimit-remaining: 6944
< x-global-ratelimit-reset: 1729756400
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< accept-ranges: bytes
< server: Sirv.API
< strict-transport-security: max-age=31536000

{}

Delete a batch of files or directories

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"filenames\":[\"/REST API Examples/filename.jpg\",\"/REST API Examples/directory/\"]}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/batch/delete", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url https://api.sirv.com/v2/files/batch/delete \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"filenames":["/REST API Examples/filename.jpg","/REST API Examples/directory/"]}'
const http = require("https");

const options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/batch/delete", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

const req = http.request(options, function (res) { const chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.write("{\"filenames\":[\"/REST API Examples/filename.jpg\",\"/REST API Examples/directory/\"]}"); req.end();

const data = "{\"filenames\":[\"/REST API Examples/filename.jpg\",\"/REST API Examples/directory/\"]}";

const xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } });

xhr.open("POST", "https://api.sirv.com/v2/files/batch/delete"); 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/batch/delete")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"filenames\":[\"/REST API Examples/filename.jpg\",\"/REST API Examples/directory/\"]}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [ CURLOPT_URL => "https://api.sirv.com/v2/files/batch/delete", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"filenames</span>":[\"/REST API Examples/filename.jpg\",\"/REST API Examples/directory/\"]}", CURLOPT_HTTPHEADER => [ "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ], ]);

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/batch/delete")

http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"filenames\":[\"/REST API Examples/filename.jpg\",\"/REST API Examples/directory/\"]}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"filenames":["/REST API Examples/filename.jpg","/REST API Examples/directory/"]}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/batch/delete")! 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/batch/delete");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"filenames\":[\"/REST API Examples/filename.jpg\",\"/REST API Examples/directory/\"]}", 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/batch/delete"

payload := strings.NewReader("{\"filenames\":[\"/REST API Examples/filename.jpg\",\"/REST API Examples/directory/\"]}")

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 delete the list of filenames

Query string

None

Body payload

Example:

{
  "filenames": [
    "/REST API Examples/filename.jpg",
    "/REST API Examples/directory/"
  ]
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "filenames": {
      "type": "array",
      "examples": [
        [
          [
            "/REST API Examples/filename.jpg",
            "/REST API Examples/directory/"
          ]
        ]
      ],
      "maxItems": 1000,
      "items": {
        "type": "string",
        "maxLength": 1024
      }
    }
  },
  "required": [
    "filenames"
  ],
  "additionalProperties": false
}

Response

Example response:

< HTTP/1.1 200
< date: Thu, 24 Oct 2024 06:53:45 GMT
< content-type: application/json; charset=utf-8
< content-length: 46
< connection: close
< x-global-ratelimit-limit: 7000
< x-global-ratelimit-remaining: 6945
< x-global-ratelimit-reset: 1729756400
< x-ratelimit-limit: 25
< x-ratelimit-remaining: 24
< x-ratelimit-reset: 1729756425
< x-ratelimit-type: rest:post:files:batch:delete
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "id": "h02KtybW8LPV4MBaNFtqVswFybm0AQAl"
}

Copy file

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg", headers=headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url 'https://api.sirv.com/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

var req = http.request(options, function (res) { var chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.end();

var data = null;

var xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } });

xhr.open("POST", "https://api.sirv.com/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg")

http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg"

req, _ := http.NewRequest("POST", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to copy a single file.

Query string

Parameter Type Description Example
from string /REST API Examples/aurora.jpg
to string /REST API Examples/aurora-copy.jpg

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:07 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6869
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

/ no response body: HTTP status 200 means SUCCESS /

Delete file or empty folder

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg", headers=headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url 'https://api.sirv.com/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

var req = http.request(options, function (res) { var chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.end();

var data = null;

var xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } });

xhr.open("POST", "https://api.sirv.com/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg")

http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE'

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg"

req, _ := http.NewRequest("POST", url, nil)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to delete a single file or an empty folder.

Query string

Parameter Type Description Example
filename string /REST API Examples/aurora-copy.jpg

Body payload

None

Response

Example response:

< HTTP/1.1 200
< date: Thu, 01 Dec 2022 19:12:27 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 3000
< x-ratelimit-remaining: 2999
< x-ratelimit-reset: 1669925546
< x-ratelimit-type: rest:post:files:delete
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

/ no response body: HTTP status 200 means SUCCESS /

Fetch URL

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/fetch", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url https://api.sirv.com/v2/files/fetch \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '[{"url":"https://demo.sirv.com/aurora.jpg","filename":"/REST API Examples/aurora.jpg"},{"url":"https://demo.sirv.com/missing.jpg","filename":"/REST API Examples/missing.jpg"}]'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/fetch", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

var req = http.request(options, function (res) { var chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.write("[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]"); req.end();

var data = "[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]";

var xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } });

xhr.open("POST", "https://api.sirv.com/v2/files/fetch"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/fetch")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/fetch", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "[{\"url</span>":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url</span>":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/fetch")

http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "[{"url":"https://demo.sirv.com/aurora.jpg","filename":"/REST API Examples/aurora.jpg"},{"url":"https://demo.sirv.com/missing.jpg","filename":"/REST API Examples/missing.jpg"}]".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/fetch")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/fetch");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/fetch"

payload := strings.NewReader("[{\"url\":\"https://demo.sirv.com/aurora.jpg\",\"filename\":\"/REST API Examples/aurora.jpg\"},{\"url\":\"https://demo.sirv.com/missing.jpg\",\"filename\":\"/REST API Examples/missing.jpg\"}]")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to fetch a file(s) from a URL via HTTP and save it to your Sirv account. This can be any URL, either public or private (via HTTP authentication). In the url parameter, enter the full URL of the remote file. In the filename parameter, enter the folder path and filename where it should be saved e.g. /path/to/folder/new-filename.jpg. If the folder path does not already exist in your Sirv account new folder(s) will be created.

Query string

None

Body payload

Example:

[
  {
    "url": "https://demo.sirv.com/aurora.jpg",
    "filename": "/REST API Examples/aurora.jpg"
  },
  {
    "url": "https://demo.sirv.com/missing.jpg",
    "filename": "/REST API Examples/missing.jpg"
  }
]

JSON Schema:

{
  "examples": [
    [
      {
        "url": "https://demo.sirv.com/aurora.jpg",
        "filename": "/REST API Examples/aurora.jpg"
      },
      {
        "url": "https://demo.sirv.com/missing.jpg",
        "filename": "/REST API Examples/missing.jpg"
      }
    ]
  ],
  "example": [
    {
      "url": "https://demo.sirv.com/aurora.jpg",
      "filename": "/REST API Examples/aurora.jpg"
    },
    {
      "url": "https://demo.sirv.com/missing.jpg",
      "filename": "/REST API Examples/missing.jpg"
    }
  ],
  "type": "array",
  "maxItems": 20,
  "items": {
    "type": "object",
    "properties": {
      "url": {
        "type": "string",
        "maxLength": 1024
      },
      "filename": {
        "type": "string",
        "pattern": "^\\/",
        "maxLength": 1024
      },
      "auth": {
        "type": "object",
        "properties": {
          "username": {
            "type": "string",
            "maxLength": 256
          },
          "password": {
            "type": "string",
            "maxLength": 256
          }
        },
        "additionalProperties": false,
        "patterns": []
      },
      "wait": {
        "type": "boolean"
      }
    },
    "additionalProperties": false,
    "patterns": [],
    "required": [
      "url",
      "filename"
    ]
  }
}

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:04 GMT
< content-type: application/json; charset=utf-8
< content-length: 9882
< connection: close
< x-ratelimit-limit: 2000
< x-ratelimit-remaining: 1996
< x-ratelimit-reset: 1595075492
< x-ratelimit-type: rest:post:files:fetch
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< vary: accept-encoding
< server: Sirv.API
< strict-transport-security: max-age=31536000

[
  {
    "filename": "/REST API Examples/aurora.jpg",
    "success": true,
    "attempted": false,
    "attempts": [
      {
        "url": "https://demo.sirv.com/aurora.jpg",
        "initiator": {
          "type": "api",
          "remoteAddr": "176.105.166.4",
          "date": "2020-07-17T15:47:35.316Z"
        },
        "statusCode": 200,
        "headers": {
          "result": {
            "version": "HTTP/1.1",
            "code": 200,
            "reason": "OK"
          },
          "Date": "Fri, 17 Jul 2020 15:47:36 GMT",
          "Content-Type": "image/webp",
          "Content-Length": "201846",
          "Connection": "keep-alive",
          "Last-Modified": "Fri, 17 Jul 2020 15:47:36 GMT",
          "ETag": "\"5f11c818-31476\"",
          "Server": "Sirv.Imagination",
          "X-Sirv-Server": "c1-extra1-fireball-13",
          "X-Sirv-Cache": "MISS",
          "Access-Control-Allow-Origin": "*",
          "Access-Control-Allow-Headers": "*",
          "Expires": "Sun, 16 Aug 2020 15:47:36 GMT",
          "Cache-Control": "max-age=2592000",
          "X-Sirv-Meta-Width": "2500",
          "X-Sirv-Meta-Height": "1667",
          "X-Sirv-Shard": "c1-riak1",
          "X-Account-Id": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
          "X-File-VersionId": "5evxYG8lnBgeA7cGBRTZzq7JQolRYviN:0",
          "X-Account-Serial": "2020-06-15T19:18:53.901Z",
          "Accept-Ranges": "bytes"
        },
        "timing": {
          "ns": 0.007514,
          "connect": 0.007912,
          "start": 0.48724,
          "total": 0.489622
        },
        "date": "2020-07-17T15:47:36.712Z"
      }
    ],
    "retryAfter": "2020-07-18T15:47:36.712Z"
  },
  {
    "filename": "/REST API Examples/missing.jpg",
    "success": false,
    "attempted": false,
    "attempts": [
      {
        "url": "https://demo.sirv.com/missing.jpg",
        "initiator": {
          "type": "api",
          "remoteAddr": "176.105.166.4",
          "date": "2020-07-18T08:35:51.026Z"
        },
        "statusCode": 404,
        "headers": {
          "result": {
            "version": "HTTP/1.1",
            "code": 404,
            "reason": "Not Found"
          },
          "Date": "Sat, 18 Jul 2020 08:35:52 GMT",
          "Content-Type": "text/html; charset=utf-8",
          "Content-Length": "4140",
          "Connection": "keep-alive",
          "Vary": "Accept-Encoding",
          "X-Account-Id": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
          "X-Account-Serial": "2020-06-15T19:18:53.901Z",
          "ETag": "W/\"102c-wKpRt+Cg9Cnw/NpTSkF5+w\"",
          "X-Sirv-Cache": "MISS",
          "Server": "Sirv.Imagination",
          "X-Sirv-Server": "c1-extra1-fireball-15",
          "Access-Control-Allow-Origin": "*",
          "Access-Control-Allow-Headers": "*"
        },
        "timing": {
          "ns": 0.018986,
          "connect": 0.019303,
          "start": 0.103774,
          "total": 0.103829
        },
        "error": {
          "name": "Error",
          "message": "Request not successful: expected status code 200 but got 404"
        },
        "date": "2020-07-18T08:35:52.089Z"
      }
    ],
    "retryAfter": "2020-07-18T12:07:32.613Z"
  }
]

Get JWT protected URL

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/jwt", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url https://api.sirv.com/v2/files/jwt \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"filename":"/REST API Examples/aurora.jpg","key":"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq","alias":"demo-jwt","secureParams":{"w":300,"h":300},"expiresIn":300}'
const http = require("https");

const options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/jwt", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

const req = http.request(options, function (res) { const chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.write("{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}"); req.end();

const data = "{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}";

const xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } });

xhr.open("POST", "https://api.sirv.com/v2/files/jwt"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/jwt")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [ CURLOPT_URL => "https://api.sirv.com/v2/files/jwt", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"filename</span>":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}", CURLOPT_HTTPHEADER => [ "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ], ]);

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/jwt")

http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"filename":"/REST API Examples/aurora.jpg","key":"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq","alias":"demo-jwt","secureParams":{"w":300,"h":300},"expiresIn":300}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/jwt")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/jwt");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/jwt"

payload := strings.NewReader("{\"filename\":\"/REST API Examples/aurora.jpg\",\"key\":\"cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq\",\"alias\":\"demo-jwt\",\"secureParams\":{\"w\":300,\"h\":300},\"expiresIn\":300}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

JWT protection is a powerful way to protect your files from being seen without permission. Use this API method to generate a token that can be appended to a URL or set of URLs, allowing a file to be served. Without a valid token, requests for any file within a JWT protected folder will be denied. Before using this method, you must enable JWT folder protection and obtain a key. Read the documentation to learn how to enable and use JWT protection: https://sirv.com/help/json-web-token-protected-signed-url#enable-jwt-protection

Query string

None

Body payload

Example:

{
  "filename": "/REST API Examples/aurora.jpg",
  "key": "cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq",
  "alias": "demo-jwt",
  "secureParams": {
    "w": 300,
    "h": 300
  },
  "expiresIn": 300
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "filename": {
      "type": "string",
      "examples": [
        "/REST API Examples/aurora.jpg"
      ],
      "pattern": "^\\/",
      "maxLength": 1024
    },
    "key": {
      "type": "string",
      "examples": [
        "cIxWUYfCjRHAy1BpcoIVNI5TivXszVPq"
      ],
      "description": "Specify JWT secret"
    },
    "alias": {
      "type": "string",
      "examples": [
        "demo-jwt"
      ],
      "description": "Specify account alias if your account has multiple aliases"
    },
    "insecureParams": {
      "type": "object",
      "properties": {},
      "additionalProperties": false
    },
    "secureParams": {
      "type": "object",
      "examples": [
        {
          "w": 300,
          "h": 300
        }
      ],
      "properties": {},
      "additionalProperties": false
    },
    "expiresIn": {
      "type": "number",
      "examples": [
        300
      ],
      "description": "Token expiration time in seconds"
    }
  },
  "required": [
    "filename",
    "key",
    "expiresIn"
  ],
  "additionalProperties": false
}

Response

Example response:

< HTTP/1.1 200
< date: Tue, 27 Jun 2023 10:10:19 GMT
< content-type: application/json; charset=utf-8
< content-length: 286
< connection: close
< x-global-ratelimit-limit: 7000
< x-global-ratelimit-remaining: 6967
< x-global-ratelimit-reset: 1687864194
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

{
  "url": "https://demo-jwt.sirv.com/REST API Examples/aurora.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcmdzIjp7InciOjMwMCwiaCI6MzAwfSwiaWF0IjoxNjg3ODYwNjE5LCJleHAiOjE2ODc4NjA5MTksImF1ZCI6Ii9SRVNUIEFQSSBFeGFtcGxlcy9hdXJvcmEuanBnIn0.-6wTZUlW-8kp43lU8_MxSuSlx8MHf8XYtS8lSXRjtU0"
}

Set approval flag

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"approved\":false,\"comment\":\"It looks too cold!\"}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url 'https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"approved":false,"comment":"It looks too cold!"}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

var req = http.request(options, function (res) { var chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.write("{\"approved\":false,\"comment\":\"It looks too cold!\"}"); req.end();

var data = "{\"approved\":false,\"comment\":\"It looks too cold!\"}";

var xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } });

xhr.open("POST", "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"approved\":false,\"comment\":\"It looks too cold!\"}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"approved</span>":false,\"comment\":\"It looks too cold!\"}", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")

http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"approved\":false,\"comment\":\"It looks too cold!\"}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"approved":false,"comment":"It looks too cold!"}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"approved\":false,\"comment\":\"It looks too cold!\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/meta/approval?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"

payload := strings.NewReader("{\"approved\":false,\"comment\":\"It looks too cold!\"}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to set the file approval tag (approved or not) and an optional comment. Used as part of an image review and approval process.

Query string

Parameter Type Description Example
filename string /REST API Examples/blue-lake.jpg

Body payload

Example:

{
  "approved": false,
  "comment": "It looks too cold!"
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "approved": {
      "examples": [
        false
      ],
      "example": false,
      "type": "boolean"
    },
    "comment": {
      "examples": [
        "It looks too cold!"
      ],
      "example": "It looks too cold!",
      "oneOf": [
        {
          "type": "string",
          "maxLength": 256
        }
      ]
    }
  },
  "additionalProperties": false,
  "patterns": [],
  "required": [
    "approved"
  ]
}

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:06 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6872
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

/ no response body: HTTP status 200 means SUCCESS /

Set product meta

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url 'https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"id":"LLBB77","name":"Blue Lake Card","brand":"BLUE LAKE LLC","category1":"Cards","category2":"Lakes"}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

var req = http.request(options, function (res) { var chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.write("{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}"); req.end();

var data = "{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}";

var xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } });

xhr.open("POST", "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"id</span>":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")

http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"id":"LLBB77","name":"Blue Lake Card","brand":"BLUE LAKE LLC","category1":"Cards","category2":"Lakes"}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/meta/product?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"

payload := strings.NewReader("{\"id\":\"LLBB77\",\"name\":\"Blue Lake Card\",\"brand\":\"BLUE LAKE LLC\",\"category1\":\"Cards\",\"category2\":\"Lakes\"}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to set product meta fields for an image. This can be used by retailers for organizing images into product groups for an ecommerce store.

Query string

Parameter Type Description Example
filename string /REST API Examples/blue-lake.jpg

Body payload

Example:

{
  "id": "LLBB77",
  "name": "Blue Lake Card",
  "brand": "BLUE LAKE LLC",
  "category1": "Cards",
  "category2": "Lakes"
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "id": {
      "examples": [
        "LLBB77"
      ],
      "example": "LLBB77",
      "type": "string",
      "maxLength": 256
    },
    "name": {
      "examples": [
        "Blue Lake Card"
      ],
      "example": "Blue Lake Card",
      "type": "string",
      "maxLength": 256
    },
    "brand": {
      "examples": [
        "BLUE LAKE LLC"
      ],
      "example": "BLUE LAKE LLC",
      "type": "string",
      "maxLength": 256
    },
    "category1": {
      "examples": [
        "Cards"
      ],
      "example": "Cards",
      "type": "string",
      "maxLength": 256
    },
    "category2": {
      "examples": [
        "Lakes"
      ],
      "example": "Lakes",
      "type": "string",
      "maxLength": 256
    }
  },
  "additionalProperties": false,
  "patterns": []
}

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:08 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6866
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

/ no response body: HTTP status 200 means SUCCESS /

Set meta description

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"description\":\"Blue Lake in the Winter\"}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url 'https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"description":"Blue Lake in the Winter"}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

var req = http.request(options, function (res) { var chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.write("{\"description\":\"Blue Lake in the Winter\"}"); req.end();

var data = "{\"description\":\"Blue Lake in the Winter\"}";

var xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } });

xhr.open("POST", "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"description\":\"Blue Lake in the Winter\"}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"description</span>":\"Blue Lake in the Winter\"}", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")

http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"description\":\"Blue Lake in the Winter\"}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"description":"Blue Lake in the Winter"}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"description\":\"Blue Lake in the Winter\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"

payload := strings.NewReader("{\"description\":\"Blue Lake in the Winter\"}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to set/change the meta description of a file or folder. For images, this is the meta field that is used for showing alt tags on images.

Query string

Parameter Type Description Example
filename string /REST API Examples/blue-lake.jpg

Body payload

Example:

{
  "description": "Blue Lake in the Winter"
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "description": {
      "examples": [
        "Blue Lake in the Winter"
      ],
      "example": "Blue Lake in the Winter",
      "type": "string"
    }
  },
  "additionalProperties": false,
  "patterns": [],
  "required": [
    "description"
  ]
}

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:05 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6879
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

/ no response body: HTTP status 200 means SUCCESS /

Add file meta tags

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url 'https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"tags":["blue","lake","winter","cold","water"]}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

var req = http.request(options, function (res) { var chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.write("{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}"); req.end();

var data = "{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}";

var xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } });

xhr.open("POST", "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")

http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"tags":["blue","lake","winter","cold","water"]}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data

let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } })

dataTask.resume()

var client = new RestClient("https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer BEARER_TOKEN_HERE");
request.AddParameter("application/json", "{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import ( "fmt" "strings" "net/http" "io/ioutil" )

func main() {

url := "https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"

payload := strings.NewReader("{\"tags\":[\"blue\",\"lake\",\"winter\",\"cold\",\"water\"]}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json") req.Header.Add("authorization", "Bearer BEARER_TOKEN_HERE")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res) fmt.Println(string(body))

}

Use this API method to add a meta tag to a file or folder.

Query string

Parameter Type Description Example
filename string /REST API Examples/blue-lake.jpg

Body payload

Example:

{
  "tags": [
    "blue",
    "lake",
    "winter",
    "cold",
    "water"
  ]
}

JSON Schema:

{
  "type": "object",
  "properties": {
    "tags": {
      "examples": [
        [
          "blue",
          "lake",
          "winter",
          "cold",
          "water"
        ]
      ],
      "example": [
        "blue",
        "lake",
        "winter",
        "cold",
        "water"
      ],
      "type": "array",
      "maxItems": 50,
      "items": {
        "type": "string"
      }
    }
  },
  "additionalProperties": false,
  "patterns": [],
  "required": [
    "tags"
  ]
}

Response

Example response:

< HTTP/1.1 200
< date: Sat, 18 Jul 2020 11:46:06 GMT
< content-length: 0
< connection: close
< x-ratelimit-limit: 7000
< x-ratelimit-remaining: 6875
< x-ratelimit-reset: 1595075478
< x-ratelimit-type: rest:global
< access-control-allow-origin: *
< access-control-expose-headers: *
< cache-control: no-cache
< server: Sirv.API
< strict-transport-security: max-age=31536000

/ no response body: HTTP status 200 means SUCCESS /

Set meta title

import http.client

conn = http.client.HTTPSConnection("api.sirv.com")

payload = "{\"title\":\"Blue Lake\"}"

headers = { 'content-type': "application/json", 'authorization': "Bearer BEARER_TOKEN_HERE" }

conn.request("POST", "/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", payload, headers)

res = conn.getresponse() data = res.read()

print(data.decode("utf-8"))

curl --request POST \
  --url 'https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \
  --header 'authorization: Bearer BEARER_TOKEN_HERE' \
  --header 'content-type: application/json' \
  --data '{"title":"Blue Lake"}'
var http = require("https");

var options = { "method": "POST", "hostname": "api.sirv.com", "port": null, "path": "/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", "headers": { "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" } };

var req = http.request(options, function (res) { var chunks = [];

res.on("data", function (chunk) { chunks.push(chunk); });

res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); });

req.write("{\"title\":\"Blue Lake\"}"); req.end();

var data = "{\"title\":\"Blue Lake\"}";

var xhr = new XMLHttpRequest(); xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } });

xhr.open("POST", "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg"); xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("authorization", "Bearer BEARER_TOKEN_HERE");

xhr.send(data);

HttpResponse<String> response = Unirest.post("https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")
  .header("content-type", "application/json")
  .header("authorization", "Bearer BEARER_TOKEN_HERE")
  .body("{\"title\":\"Blue Lake\"}")
  .asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"title</span>":\"Blue Lake\"}", CURLOPT_HTTPHEADER => array( "authorization: Bearer BEARER_TOKEN_HERE", "content-type: application/json" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")

http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url) request["content-type"] = 'application/json' request["authorization"] = 'Bearer BEARER_TOKEN_HERE' request.body = "{\"title\":\"Blue Lake\"}"

response = http.request(request) puts response.read_body

import Foundation

let headers = [ "content-type": "application/json", "authorization": "Bearer BEARER_TOKEN_HERE" ]

let postData = NSData(data: "{"title":"Blue Lake"}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data