Check availability and prefetch a brand
curl --request HEAD \
--url https://api.brandfetch.io/v2/brands/{identifier} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.brandfetch.io/v2/brands/{identifier}"
headers = {"Authorization": "Bearer <token>"}
response = requests.head(url, headers=headers)
print(response.text)const options = {method: 'HEAD', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.brandfetch.io/v2/brands/{identifier}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.brandfetch.io/v2/brands/{identifier}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "HEAD",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.brandfetch.io/v2/brands/{identifier}"
req, _ := http.NewRequest("HEAD", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.head("https://api.brandfetch.io/v2/brands/{identifier}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.brandfetch.io/v2/brands/{identifier}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Head.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyBrand API
Brand API prefetch (HEAD)
Check whether Brandfetch already holds a brand with HEAD /v2/brands/, and queue a crawl when it does not, so the GET that follows is answered quickly.
HEAD
/
v2
/
brands
/
{identifier}
Check availability and prefetch a brand
curl --request HEAD \
--url https://api.brandfetch.io/v2/brands/{identifier} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.brandfetch.io/v2/brands/{identifier}"
headers = {"Authorization": "Bearer <token>"}
response = requests.head(url, headers=headers)
print(response.text)const options = {method: 'HEAD', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.brandfetch.io/v2/brands/{identifier}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.brandfetch.io/v2/brands/{identifier}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "HEAD",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.brandfetch.io/v2/brands/{identifier}"
req, _ := http.NewRequest("HEAD", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.head("https://api.brandfetch.io/v2/brands/{identifier}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.brandfetch.io/v2/brands/{identifier}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Head.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyA
HEAD request is the availability check: 200 when Brandfetch already
holds the brand, 202 when it does not and a crawl has been queued, 404
when nothing can be fetched for the identifier, including a brand that has
been removed. HEAD takes no allowNsfw parameter: a held brand answers
200 however a later GET is filtered. It never consumes a credit,
and it is available on paid plans only, so a free plan receives 403 with the
header x-bf-error: paid_plan_required. A 503 with
x-bf-error: temporarily_unavailable means the crawl could not be queued;
retry later.Use it to warm a brand ahead of time, for example at signup with the new
user’s email address, so the GET that renders your brand screen is
answered from our store instead of waiting on a live crawl. See
Prefetching brands.The same check works on the explicit domain route,
HEAD /v2/brands/domain/{domain}.Authorizations
Path Parameters
Response
The brand is held. A GET answers from the store.
Was this page helpful?