Get storage and billing info
Short answer
This page has 2 commands: Get storage info (GET /v2/account/storage) and Get billing info (GET /v2/billing/plan). Use this to check the current storage usage of an account. Each call needs a bearer token and counts towards your hourly API limit.
After reading this you will know
- How to get storage and billing info
- Which parameters each of the 2 commands takes
- Sample code in 9 languages and a sample answer
Every command on this page needs a bearer token and counts towards your hourly limit.
Get storage info
Section titled “Get storage info”https://api.sirv.com/v2/account/storage
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.
Example request
// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variableconst res = await fetch('https://api.sirv.com/v2/account/storage', { method: 'GET', headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },});console.log(res.status, await res.text());import requests
res = requests.get( 'https://api.sirv.com/v2/account/storage', headers={'authorization': 'Bearer BEARER_TOKEN'},)print(res.status_code, res.text)curl --request GET \ --url 'https://api.sirv.com/v2/account/storage' \ --header 'authorization: Bearer BEARER_TOKEN'import java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.sirv.com/v2/account/storage")) .header("authorization", "Bearer BEARER_TOKEN") .method("GET", HttpRequest.BodyPublishers.noBody()) .build();HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());System.out.println(response.statusCode() + " " + response.body());using System.Net.Http.Headers;
using var client = new HttpClient();var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.sirv.com/v2/account/storage");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "BEARER_TOKEN");var response = await client.SendAsync(request);Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");<?php$ch = curl_init('https://api.sirv.com/v2/account/storage');curl_setopt_array($ch, [ CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => ['authorization: Bearer BEARER_TOKEN'], CURLOPT_RETURNTRANSFER => true,]);echo curl_exec($ch);package main
import ( "fmt" "io" "net/http")
func main() { req, _ := http.NewRequest("GET", "https://api.sirv.com/v2/account/storage", nil) req.Header.Set("authorization", "Bearer BEARER_TOKEN") res, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer res.Body.Close() out, _ := io.ReadAll(res.Body) fmt.Println(res.Status, string(out))}require 'net/http'
uri = URI('https://api.sirv.com/v2/account/storage')req = Net::HTTP::Get.new(uri)req['authorization'] = 'Bearer BEARER_TOKEN'res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }puts res.code, res.bodyimport Foundation
var request = URLRequest(url: URL(string: "https://api.sirv.com/v2/account/storage")!)request.httpMethod = "GET"request.setValue("Bearer BEARER_TOKEN", forHTTPHeaderField: "authorization")let (data, response) = try await URLSession.shared.data(for: request)print((response as! HTTPURLResponse).statusCode, String(decoding: data, as: UTF8.self))Example response
{ "plan": 100000000000, "burstable": 500000000000, "extra": 0, "used": 51916252571, "files": 73143, "quotaExceededDate": null}Get billing info
Section titled “Get billing info”https://api.sirv.com/v2/billing/plan
Use this API method to get all the billing plan information of an account, including price, storage and transfer allowances.
Example request
// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variableconst res = await fetch('https://api.sirv.com/v2/billing/plan', { method: 'GET', headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },});console.log(res.status, await res.text());import requests
res = requests.get( 'https://api.sirv.com/v2/billing/plan', headers={'authorization': 'Bearer BEARER_TOKEN'},)print(res.status_code, res.text)curl --request GET \ --url 'https://api.sirv.com/v2/billing/plan' \ --header 'authorization: Bearer BEARER_TOKEN'import java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.sirv.com/v2/billing/plan")) .header("authorization", "Bearer BEARER_TOKEN") .method("GET", HttpRequest.BodyPublishers.noBody()) .build();HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());System.out.println(response.statusCode() + " " + response.body());using System.Net.Http.Headers;
using var client = new HttpClient();var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.sirv.com/v2/billing/plan");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "BEARER_TOKEN");var response = await client.SendAsync(request);Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");<?php$ch = curl_init('https://api.sirv.com/v2/billing/plan');curl_setopt_array($ch, [ CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => ['authorization: Bearer BEARER_TOKEN'], CURLOPT_RETURNTRANSFER => true,]);echo curl_exec($ch);package main
import ( "fmt" "io" "net/http")
func main() { req, _ := http.NewRequest("GET", "https://api.sirv.com/v2/billing/plan", nil) req.Header.Set("authorization", "Bearer BEARER_TOKEN") res, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer res.Body.Close() out, _ := io.ReadAll(res.Body) fmt.Println(res.Status, string(out))}require 'net/http'
uri = URI('https://api.sirv.com/v2/billing/plan')req = Net::HTTP::Get.new(uri)req['authorization'] = 'Bearer BEARER_TOKEN'res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }puts res.code, res.bodyimport Foundation
var request = URLRequest(url: URL(string: "https://api.sirv.com/v2/billing/plan")!)request.httpMethod = "GET"request.setValue("Bearer BEARER_TOKEN", forHTTPHeaderField: "authorization")let (data, response) = try await URLSession.shared.data(for: request)print((response as! HTTPURLResponse).statusCode, String(decoding: data, as: UTF8.self))Example response
{ "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}