Tutorial

Detect Brand Logos in Images with a Logo Detection API

Learn how to detect brand logos in images using a logo detection API. Covers brand monitoring, counterfeit detection, and sponsorship tracking with cURL, Python, and JavaScript examples.

Detect Brand Logos in Images with a Logo Detection API

Brand logos are everywhere — on billboards, product packaging, social media posts, sports broadcasts, and storefronts. Being able to automatically detect and identify these logos in images opens the door to powerful applications in brand monitoring, intellectual property protection, and marketing analytics. A logo detection API handles the heavy lifting of computer vision model training and inference, letting you identify brand logos in any image with a single HTTP request. In this tutorial, you will learn how to integrate the Logo Detection API into your projects using cURL, Python, and JavaScript.

Logo detection demo — Apple logo detected on a MacBook with bounding box and confidence score

Why Logo Detection Matters

Logos are one of the most recognizable visual assets a company owns. Detecting them programmatically unlocks a range of business-critical capabilities that would be impractical to handle manually at scale.

Brand Monitoring

Companies invest heavily in their brand identity, yet they often have limited visibility into how their logos appear across the internet. A logo detection system can scan social media posts, news articles, and user-generated content to track where and how a brand is being represented. This includes unauthorized usage, logo modifications, and organic mentions that text-based monitoring tools would miss entirely because the brand name is never typed out — it only appears visually.

Counterfeit Detection

Counterfeit goods are a multi-billion-dollar problem. E-commerce platforms and brand protection teams use logo detection to scan product listings for suspicious logo usage. By comparing detected logos against known authentic versions, teams can flag potential counterfeits before they reach consumers. This is especially valuable on marketplaces where thousands of new listings appear every day and manual review is impossible.

Sponsorship Tracking

In sports, entertainment, and events, sponsors pay premium prices for logo placement on jerseys, banners, and equipment. Logo detection allows sponsors and broadcasters to quantify exactly how much screen time each logo receives during a broadcast or event. This data drives sponsorship valuations, renewal negotiations, and ROI calculations that were previously based on rough estimates.

Getting Started with the Logo Detection API

The Logo Detection API accepts either an image URL (sent as form-encoded data) or a direct image file upload (sent as multipart form data). It returns a JSON response containing every detected logo, along with a description of the brand, a confidence score, and a bounding polygon that marks the exact location of the logo within the image. Below are working examples in three languages.

cURL

Send an image URL using form-encoded data:

bash
curl --request POST \
  --url https://logos-detection.p.rapidapi.com/detect-logo \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --header 'x-rapidapi-host: logos-detection.p.rapidapi.com' \
  --header 'x-rapidapi-key: YOUR_API_KEY' \
  --data-urlencode 'url=https://example.com/photo.jpg'

Or upload a local file directly:

bash
curl --request POST \
  --url https://logos-detection.p.rapidapi.com/detect-logo \
  --header 'Content-Type: multipart/form-data' \
  --header 'x-rapidapi-host: logos-detection.p.rapidapi.com' \
  --header 'x-rapidapi-key: YOUR_API_KEY' \
  --form 'image=@/path/to/local-photo.jpg'

Python

Here is a Python script that demonstrates both the URL-based and file-based approaches, then iterates through the detected logos to print brand names, confidence scores, and bounding polygon coordinates:

python
import requests

api_url = "https://logos-detection.p.rapidapi.com/detect-logo"
headers = {
    "x-rapidapi-host": "logos-detection.p.rapidapi.com",
    "x-rapidapi-key": "YOUR_API_KEY",
}

# Option 1: Send an image URL
response = requests.post(
    api_url,
    headers={**headers, "Content-Type": "application/x-www-form-urlencoded"},
    data={"url": "https://example.com/photo.jpg"},
)

# Option 2: Upload a local file
# with open("local-photo.jpg", "rb") as f:
#     response = requests.post(
#         api_url,
#         headers=headers,
#         files={"image": ("photo.jpg", f, "image/jpeg")},
#     )

data = response.json()

# Iterate through detected logos
for logo in data["body"]["logos"]:
    name = logo["description"]
    score = logo["score"]
    coords = ", ".join(f"({v['x']}, {v['y']})" for v in logo["boundingPoly"])
    print(f"{name} (confidence: {score:.0%}) at [{coords}]")

JavaScript (fetch)

This example uploads a local file using the Fetch API with FormData, which works in both the browser and Node.js 18+:

javascript
// Upload a file using FormData
const formData = new FormData();
formData.append("image", fileInput.files[0]);

const response = await fetch(
  "https://logos-detection.p.rapidapi.com/detect-logo",
  {
    method: "POST",
    headers: {
      "x-rapidapi-host": "logos-detection.p.rapidapi.com",
      "x-rapidapi-key": "YOUR_API_KEY",
    },
    body: formData,
  }
);

const data = await response.json();

// Process each detected logo
data.body.logos.forEach((logo) => {
  const { description, score, boundingPoly } = logo;
  const coords = boundingPoly
    .map((v) => `(${v.x}, ${v.y})`)
    .join(", ");
  console.log(`${description} (confidence: ${(score * 100).toFixed(1)}%) at [${coords}]`);
});

Understanding the Response

The API returns a JSON object with a statusCode and a body containing a logos array. Here is a typical response:

json
{
  "statusCode": 200,
  "body": {
    "logos": [
      {
        "description": "Apple",
        "score": 0.65,
        "boundingPoly": [
          { "x": 349, "y": 529 },
          { "x": 402, "y": 529 },
          { "x": 402, "y": 601 },
          { "x": 349, "y": 601 }
        ]
      }
    ]
  }
}

Let's break down each field:

  • description — The name of the detected brand or logo. This is the human-readable label that the model has matched, such as "Google", "Nike", or "Apple".
  • score — A floating-point confidence value between 0 and 1. A score of 0.95 means the model is 95% confident in its identification. For production use, filtering results to a minimum threshold of 0.7 or higher is recommended to avoid false positives.
  • boundingPoly — An array of vertex objects that defines the polygon outlining the logo in the image. Each vertex has an x and y coordinate in pixels, measured from the top-left corner of the image. The four vertices typically form a rectangle, but the polygon format allows for more complex shapes when a logo is viewed at an angle or is partially occluded.

When an image contains multiple logos, the logos array will include a separate object for each detection. If no logos are found, the array will be empty. Your application should always handle the empty-array case gracefully.

Real-World Use Cases

Logo detection is a versatile capability that powers applications across industries. Here are four scenarios where developers and businesses are putting it to work.

Brand Monitoring on Social Media

Social media platforms generate billions of images daily. Text-based social listening tools catch mentions where someone types a brand name, but they completely miss visual-only mentions — someone wearing a branded t-shirt, a photo of a storefront, or a product unboxing video thumbnail. By running logo detection on images from social feeds, marketing teams can track brand visibility in user-generated content, measure organic reach, and detect unauthorized logo usage. This visual intelligence layer complements traditional sentiment analysis to give a complete picture of brand perception. If you also need to identify what other objects appear alongside logos in those images, the object detection API can help with that.

Counterfeit Detection on E-Commerce Platforms

Online marketplaces face constant pressure to remove counterfeit listings. Logo detection automates the first line of defense by scanning every product image for brand logos and flagging listings that use trademarked logos without authorization. The bounding polygon data lets you compare the detected logo's size, position, and aspect ratio against known authentic placements, catching subtle differences that human reviewers might miss when processing thousands of listings per day.

Sponsorship ROI in Sports and Events

Sponsors need to know exactly how much exposure their brand receives during a live broadcast or event. Logo detection can process frames from video footage to calculate total screen time, logo size relative to the frame, and placement quality (center screen versus periphery). These metrics feed directly into sponsorship valuation models and help both sponsors and rights holders negotiate data-driven deals. Combined with image labeling, you can also categorize the context in which the logo appears — whether it is on a jersey, a banner, or a piece of equipment.

Competitive Intelligence

Understanding where competitor logos show up provides strategic insights. Retail chains can analyze shelf photos across store locations to measure competitor product placement and share of shelf. Marketing teams can track competitor logo frequency in event photography, press coverage, and influencer content. This data helps companies benchmark their visual presence against competitors and identify gaps in their brand visibility strategy. Over time, trend analysis reveals whether a competitor is increasing or decreasing their visual footprint in specific channels.

Tips and Best Practices

Use High-Quality Images

Logo detection accuracy depends heavily on image quality. Blurry, heavily compressed, or extremely low-resolution images make it harder for the model to identify logos. Aim for images where logos are at least 50 pixels wide. If you are pulling images from social media, prefer the highest resolution version available rather than thumbnails. Resizing images to a reasonable maximum (such as 1600 pixels on the longest side) is fine, but avoid aggressive downscaling that makes small logos unreadable.

Filter by Confidence Score

Not every detection warrants action. Set a confidence threshold that matches the consequences of a false positive in your use case. For brand monitoring dashboards where a false positive is a minor inconvenience, a threshold of 0.6 may be appropriate. For automated counterfeit takedowns where a false positive could remove a legitimate listing, use a higher threshold like 0.85 and route borderline cases to human reviewers.

Handle Multiple Logos Per Image

Real-world images often contain more than one logo. A sports broadcast frame might show logos from a dozen sponsors simultaneously. Design your processing pipeline to iterate through the entire logos array rather than assuming a single result. Track each logo independently, and use the bounding polygon coordinates to associate each detection with a specific region of the image for downstream analysis or visualization.

Use Bounding Polygons for Visual Overlays

The bounding polygon vertices are ideal for drawing visual annotations on top of images. Use HTML Canvas, SVG, or a server-side image library like Pillow (Python) or Sharp (Node.js) to render colored outlines around detected logos. This is especially useful for quality assurance dashboards, where reviewers need to quickly verify that the API detected the right logo in the right location. Keep annotations as overlays rather than burning them into the original image, so you preserve the source file for future reprocessing.

Batch Processing and Rate Limiting

When you need to process large volumes of images — for instance, scanning an entire product catalog or processing a day's worth of social media images — implement concurrency with sensible limits. Use a job queue or a worker pool with three to five concurrent requests, and implement exponential backoff when you receive 429 (rate limit) responses. Cache results by image hash to avoid reprocessing identical images, and log both successful and failed requests so you can monitor throughput and error rates over time.

Logo detection transforms unstructured visual data into actionable brand intelligence. Whether you are monitoring your brand across social media, fighting counterfeits on e-commerce platforms, or quantifying sponsorship exposure in sports broadcasts, the Logo Detection API gives you the tools to do it at scale with a single REST endpoint. Grab your API key, try the examples above, and start turning images into insights.

Ready to Try Logo Detection?

Check out the full API documentation, live demos, and code samples on the Logo Detection spotlight page.

Related Articles

Continue learning with these related guides and tutorials.