Cloudflare Trace API
Overview
The Cloudflare Trace API exposes request metadata collected by Cloudflare's edge network, including your public IP address, country code, datacenter IATA code, HTTP version, TLS version, and user agent—all in a single request. No authentication or API key is required. It is particularly useful for quickly detecting a client's real IP, geographic location, and connection properties in server-side or testing contexts.
Beginner Tip
No sign-up or API key needed. Call https://cloudflare.com/cdn-cgi/trace and you get plain-text key=value output; the JSON version at /json returns structured data. This is one of the simplest and most reliable public APIs available.
Available Data
Example Response
{
"name": "Japan",
"capital": "Tokyo",
"population": 125800000,
"region": "Asia",
"languages": [
"Japanese"
],
"flag": "https://flagcdn.com/jp.svg",
"currencies": [
{
"code": "JPY",
"name": "Japanese yen"
}
]
} Field Reference
ip Your public IP address as seen by Cloudflare's edge. ts Unix timestamp (with fractional seconds) of the request. uag User-Agent string of the requesting client. loc Two-letter ISO 3166-1 country code of the request origin. tls TLS version used for the connection, e.g., TLSv1.3. http HTTP protocol version used, e.g., http/2. Implementation Example
const url = "https://github.com/fawazahmed0/cloudflare-trace-api";
const response = await fetch(url);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data); What Can You Build?
Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.
Common Errors & Troubleshooting
Matrix Score Breakdown
Fully tested on Apr 5, 2026
Technical Specifications
Related Tags
Similar APIs
View All →24 Pull Requests
⭐ Beginner's Pick24 Pull Requests is a community initiative that runs every December to encourage developers to contribute to open source projects.
Agify.io
⭐ Beginner's PickAgify.io is a free API that predicts the likely age of a person based solely on their first name, using a database of over 350 million historical records.
API Grátis
API Grátis is a Brazilian API aggregator that bundles multiple free utility services including CEP (postal code) lookup, CNPJ (company registry) data, vehicle plate information, and more — all under a single authentication token.
ApicAgent
⭐ Beginner's PickApicAgent parses User-Agent strings into structured device and browser information, returning details like browser name, version, OS, device type, and whether the client is a bot.
APIs.guru
⭐ Beginner's PickAPIs.guru maintains a crowd-sourced directory of OpenAPI (Swagger) specification files for hundreds of public web APIs, all normalized to OpenAPI 3.0 format.