Skip to main content

Configuration API Reference

The AdUnblock Configuration API provides access to the latest JavaScript configuration files needed for ad blocker detection on your website.

Base URL

https://public.adunblocker.com

Authentication

This API endpoint is publicly accessible and does not require authentication.

Caching

The API responses are cached for optimal performance and support standard HTTP caching headers for efficient client-side caching.

Server Tag Configuration

Get JavaScript Configuration

Retrieve the latest JavaScript files needed for ad blocker detection.
curl -X GET https://public.adunblocker.com/api/vendor_scripts

Response

["https://cdn.example.com/detection-script.js"]

Response Format

The response is a JSON array containing JavaScript file URLs for ad blocker detection as strings.

Response Headers

HeaderDescription
Content-Typeapplication/json
ETagEntity tag for caching validation
Last-ModifiedTimestamp when the configuration was last updated

Usage Example

Once you fetch the configuration, you can dynamically load the JavaScript files:
// Fetch configuration
const scripts = await fetch(
  "https://public.adunblocker.com/api/vendor_scripts"
).then((response) => response.json());

// Load the JavaScript files
scripts.forEach((scriptUrl) => {
  const script = document.createElement("script");
  script.src = scriptUrl;
  script.async = true;
  document.head.appendChild(script);
});

Caching Recommendations

  • The API supports standard HTTP caching headers
  • Implement conditional requests using If-None-Match header with ETag
  • Cache responses locally for better performance
  • Check for updates periodically (e.g., every hour)
// Example with conditional request
const etag = localStorage.getItem("config-etag");
const headers = etag ? { "If-None-Match": etag } : {};

const response = await fetch("https://public.adunblocker.com/api/vendor_scripts", {
  headers,
});

if (response.status === 304) {
  // Use cached configuration
  console.log("Configuration unchanged");
} else {
  // Update cache
  const scripts = await response.json();
  localStorage.setItem("config-etag", response.headers.get("ETag"));
  localStorage.setItem("config-data", JSON.stringify(scripts));
}

Valid Script Sources (Deprecated)

This endpoint is deprecated and will be removed in a future version. Please use the /api/vendor_scripts endpoint instead.

Get Valid Script Sources

Retrieve a list of valid JavaScript source URLs for ad blocker detection.
curl -X GET https://config.adunblocker.com/valid_script_sources.json

Response

["https://cdn.example.com/detection-script.js"]

Response Format

The response is a JSON array containing valid JavaScript source URLs as strings.

Response Headers

HeaderDescription
Content-Typeapplication/json
ETagEntity tag for caching validation
Last-ModifiedTimestamp when the configuration was last updated

Migration Guide

If you’re currently using this endpoint, migrate to the new /api/vendor_scripts endpoint:
// Old (deprecated)
const sources = await fetch(
  "https://config.adunblocker.com/valid_script_sources.json"
).then((response) => response.json());

// New (recommended)
const scripts = await fetch(
  "https://public.adunblocker.com/api/vendor_scripts"
).then((response) => response.json());
// scripts is already an array, no need to access .js property