Where Am I?
Get request metadata from Cloudflare's edge including geolocation, colo, and more
Retrieve detailed metadata about incoming requests from Cloudflare's edge network, including geographic location, data center, ASN, and timezone.
API Reference
GET /whereami
Returns the Cloudflare request.cf object containing metadata about the incoming request.
Example Request
curl "https://your-worker.workers.dev/whereami"Success Response
The response includes whatever Cloudflare injects into request.cf for the incoming request. Common fields include:
country string
Two-letter ISO 3166-1 country code (e.g., "US", "GB")
city string
City name (e.g., "San Francisco")
region string
Region or state name (e.g., "California")
timezone string
IANA timezone identifier (e.g., "America/Los_Angeles")
colo string
Cloudflare data center IATA code (e.g., "SFO", "LHR")
asn number
Autonomous System Number of the client's ISP
{
"country": "US",
"city": "San Francisco",
"region": "California",
"timezone": "America/Los_Angeles",
"colo": "SFO",
"asn": 13335
}The exact fields returned depend on Cloudflare's detection capabilities. During local development, the response may be empty or contain minimal data. Full metadata is available when deployed.
Additional Request Metadata Fields
Depending on the request, the cf object may also include:
latitude/longitude- Geographic coordinatespostalCode- Postal/ZIP codemetroCode- Metro area codecontinent- Two-letter continent coderegionCode- ISO 3166-2 region codetlsVersion- TLS version used (e.g., "TLSv1.3")tlsCipher- TLS cipher suitehttpProtocol- HTTP protocol version (e.g., "HTTP/2")
See the Cloudflare request.cf documentation for a complete list.
Implementation Details
- Completely stateless - no external requests
- No database or KV storage required
- Returns raw
request.cfobject from Cloudflare - Works immediately after deployment
Use Cases
- Determine visitor geographic location without external APIs
- Display localized content based on country/region
- Show the nearest edge data center serving the request
- Analyze traffic patterns by ASN or location
- Build geographic routing logic
Limitations
- Returns Cloudflare
request.cfmetadata only; not a standalone geolocation API - Local development returns minimal or empty
cfdata - Available fields vary by request path and Cloudflare detection capabilities
Deployment
Deploy
Follow the deployment wizard to deploy the Worker to your Cloudflare account. No additional configuration required.
Test your deployment
curl "https://your-worker.workers.dev/whereami"Local Development
cd apps/experiments/whereami
npm install
npm run devTest locally:
curl "http://localhost:8787/whereami"Local development will return an empty object or minimal data since request.cf is only populated by Cloudflare's edge network.
Cloudflare Features Used
- Workers - Edge compute runtime
- request.cf - Incoming request metadata including geolocation