Skip to main content

How Brandfetch Integration Works

From ChatGPT with the following prompt:

"How do I integrate Brandfetch into my Wordpress plugin to get the most current logo of a company?"

Brandfetch provides a REST API you can call from inside your plugin. You send a domain (e.g., "stripe.com") → Brandfetch returns the company profile → including the latest logo files.

1. Get Your Brandfetch API Key

  • Create a Brandfetch account
  • Go to Developers → API Keys
  • Copy your secret key

You'll need to send it via the HTTP Authorization header:

Authorization: Bearer YOUR_API_KEY

2. Create a Simple WordPress Plugin Structure

/wp-content/plugins/brandfetch-logo-fetcher/brandfetch-logo-fetcher.php

<?php
/**
* Plugin Name: Brandfetch Logo Fetcher
* Description: Fetches latest company logos via Brandfetch API.
*/

if (!defined('ABSPATH')) exit;

// Main function to fetch logo
function bf_get_company_logo($domain) {
$api_key = 'YOUR_API_KEY_HERE';
$url = 'https://api.brandfetch.io/v2/brands/' . $domain;

$response = wp_remote_get($url, [
'headers' => [
'Authorization' => 'Bearer ' . $api_key,
],
'timeout' => 20
]);

if (is_wp_error($response)) {
return false;
}

$body = json_decode(wp_remote_retrieve_body($response), true);

if (!isset($body['logos'])) {
return false;
}

// Get main logo (usually first in array)
$logo = $body['logos'][0]['formats'][0]['src'] ?? null;

return $logo;
}

// Shortcode: [brandfetch_logo domain="apple.com"]
function bf_logo_shortcode($atts) {
$atts = shortcode_atts(['domain' => ''], $atts);

if (empty($atts['domain'])) return 'No domain provided.';

$logo_url = bf_get_company_logo($atts['domain']);

if ($logo_url) {
return '<img src="'. esc_url($logo_url) .'" alt="Company Logo" style="max-height:100px;">';
}

return 'Logo not found.';
}
add_shortcode('brandfetch_logo', 'bf_logo_shortcode');

Brandfetch automatically keeps logo assets up to date.

When you hit:

GET https://api.brandfetch.io/v2/brands/{domain}

Brandfetch returns the latest brand profile it knows about. You don’t need to manually check for updates — Brandfetch handles that.

API calls cost money. Cache to speed up and save credits:

function bf_get_company_logo_cached($domain) {
$cache_key = 'bf_logo_' . md5($domain);
$cached = get_transient($cache_key);

if ($cached) return $cached;

$logo = bf_get_company_logo($domain);

// Cache for 1 week
set_transient($cache_key, $logo, WEEK_IN_SECONDS);

return $logo;
}

Swap out your shortcode to call the cached version.

Want a more advanced version?

I can generate:

  • a full admin settings page
  • a UI for entering domains
  • automatic logo retrieval on post save
  • Gutenberg block for inserting logos
  • HTTP error handling + fallback logos