Get and set a file's title and description
Short answer
This page has 4 commands: Get meta title (GET /v2/files/meta/title), Set meta title (POST /v2/files/meta/title), Get meta description (GET /v2/files/meta/description) and Set meta description (POST /v2/files/meta/description). Each call needs a bearer token and counts towards your hourly API limit. Below are the parameters, sample code in 9 languages and a sample answer.
After reading this you will know
- How to get and set a file's title and description
- Which parameters each of the 4 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 meta title
Section titled “Get meta title”https://api.sirv.com/v2/files/meta/title
Use this API method to check the meta title of a file or folder.
Query parameters
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
filename | string | Yes | /REST API Examples/blue-lake.jpg | Path of the file in your account, starting with /. |
Example request
// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variableconst res = await fetch('https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg', { 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/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg', headers={'authorization': 'Bearer BEARER_TOKEN'},)print(res.status_code, res.text)curl --request GET \ --url 'https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \ --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/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")) .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/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");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/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg');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/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", 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/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg')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/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")!)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
{ "title": "Blue Lake"}Set meta title
Section titled “Set meta title”https://api.sirv.com/v2/files/meta/title
Use this API method to set the meta title of a file or folder.
Query parameters
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
filename | string | Yes | /REST API Examples/blue-lake.jpg | Path of the file in your account, starting with /. |
Request body (JSON)
| Field | Type | Required | Example | Description |
|---|---|---|---|---|
title | string | Yes | Blue Lake | The new title of the file. |
Example request
// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variableconst res = await fetch('https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg', { method: 'POST', headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}`, 'content-type': 'application/json' }, body: JSON.stringify({ "title": "Blue Lake" }),});console.log(res.status, await res.text());import requests
res = requests.post( 'https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg', headers={'authorization': 'Bearer BEARER_TOKEN', 'content-type': 'application/json'}, json={ "title": "Blue Lake" },)print(res.status_code, res.text)curl --request POST \ --url 'https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \ --header 'authorization: Bearer BEARER_TOKEN' \ --header 'content-type: application/json' \ --data '{"title":"Blue Lake"}'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/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")) .header("authorization", "Bearer BEARER_TOKEN") .header("content-type", "application/json") .method("POST", HttpRequest.BodyPublishers.ofString(""" { "title": "Blue Lake" } """)) .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("POST"), "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "BEARER_TOKEN");request.Content = new StringContent("""{ "title": "Blue Lake"}""", System.Text.Encoding.UTF8, "application/json");var response = await client.SendAsync(request);Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");<?php$ch = curl_init('https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg');curl_setopt_array($ch, [ CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HTTPHEADER => ['authorization: Bearer BEARER_TOKEN', 'content-type: application/json'], CURLOPT_POSTFIELDS => json_encode([ 'title' => 'Blue Lake' ]), CURLOPT_RETURNTRANSFER => true,]);echo curl_exec($ch);package main
import ( "fmt" "io" "net/http" "strings")
func main() { body := strings.NewReader(`{ "title": "Blue Lake" }`) req, _ := http.NewRequest("POST", "https://api.sirv.com/v2/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", body) req.Header.Set("authorization", "Bearer BEARER_TOKEN") req.Header.Set("content-type", "application/json") 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/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg')req = Net::HTTP::Post.new(uri)req['authorization'] = 'Bearer BEARER_TOKEN'req['content-type'] = 'application/json'req.body = <<~'JSON' { "title": "Blue Lake" }JSONres = 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/files/meta/title?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")!)request.httpMethod = "POST"request.setValue("Bearer BEARER_TOKEN", forHTTPHeaderField: "authorization")request.setValue("application/json", forHTTPHeaderField: "content-type")request.httpBody = #"""{ "title": "Blue Lake"}"""#.data(using: .utf8)let (data, response) = try await URLSession.shared.data(for: request)print((response as! HTTPURLResponse).statusCode, String(decoding: data, as: UTF8.self))Response
HTTP 200 with an empty body when the command succeeds.
Get meta description
Section titled “Get meta description”https://api.sirv.com/v2/files/meta/description
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 parameters
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
filename | string | Yes | /REST API Examples/blue-lake.jpg | Path of the file in your account, starting with /. |
Example request
// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variableconst res = await fetch('https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg', { 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/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg', headers={'authorization': 'Bearer BEARER_TOKEN'},)print(res.status_code, res.text)curl --request GET \ --url 'https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \ --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/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")) .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/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");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/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg');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/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", 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/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg')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/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")!)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
{ "description": "Blue Lake in the Winter"}Set meta description
Section titled “Set meta description”https://api.sirv.com/v2/files/meta/description
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 parameters
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
filename | string | Yes | /REST API Examples/blue-lake.jpg | Path of the file in your account, starting with /. |
Request body (JSON)
| Field | Type | Required | Example | Description |
|---|---|---|---|---|
description | string | Yes | Blue Lake in the Winter | The new description of the file. |
Example request
// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variableconst res = await fetch('https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg', { method: 'POST', headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}`, 'content-type': 'application/json' }, body: JSON.stringify({ "description": "Blue Lake in the Winter" }),});console.log(res.status, await res.text());import requests
res = requests.post( 'https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg', headers={'authorization': 'Bearer BEARER_TOKEN', 'content-type': 'application/json'}, json={ "description": "Blue Lake in the Winter" },)print(res.status_code, res.text)curl --request POST \ --url 'https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg' \ --header 'authorization: Bearer BEARER_TOKEN' \ --header 'content-type: application/json' \ --data '{"description":"Blue Lake in the Winter"}'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/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")) .header("authorization", "Bearer BEARER_TOKEN") .header("content-type", "application/json") .method("POST", HttpRequest.BodyPublishers.ofString(""" { "description": "Blue Lake in the Winter" } """)) .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("POST"), "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg");request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "BEARER_TOKEN");request.Content = new StringContent("""{ "description": "Blue Lake in the Winter"}""", System.Text.Encoding.UTF8, "application/json");var response = await client.SendAsync(request);Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");<?php$ch = curl_init('https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg');curl_setopt_array($ch, [ CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HTTPHEADER => ['authorization: Bearer BEARER_TOKEN', 'content-type: application/json'], CURLOPT_POSTFIELDS => json_encode([ 'description' => 'Blue Lake in the Winter' ]), CURLOPT_RETURNTRANSFER => true,]);echo curl_exec($ch);package main
import ( "fmt" "io" "net/http" "strings")
func main() { body := strings.NewReader(`{ "description": "Blue Lake in the Winter" }`) req, _ := http.NewRequest("POST", "https://api.sirv.com/v2/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg", body) req.Header.Set("authorization", "Bearer BEARER_TOKEN") req.Header.Set("content-type", "application/json") 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/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg')req = Net::HTTP::Post.new(uri)req['authorization'] = 'Bearer BEARER_TOKEN'req['content-type'] = 'application/json'req.body = <<~'JSON' { "description": "Blue Lake in the Winter" }JSONres = 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/files/meta/description?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg")!)request.httpMethod = "POST"request.setValue("Bearer BEARER_TOKEN", forHTTPHeaderField: "authorization")request.setValue("application/json", forHTTPHeaderField: "content-type")request.httpBody = #"""{ "description": "Blue Lake in the Winter"}"""#.data(using: .utf8)let (data, response) = try await URLSession.shared.data(for: request)print((response as! HTTPURLResponse).statusCode, String(decoding: data, as: UTF8.self))Response
HTTP 200 with an empty body when the command succeeds.