API Endpoint
GET /whereami
Returns the Cloudflarerequest.cf object containing metadata about the incoming request.
Example Request
Success Response
The response includes whatever Cloudflare injects intorequest.cf for the incoming request. Common fields include:
Two-letter ISO 3166-1 country code (e.g., “US”, “GB”)
City name (e.g., “San Francisco”)
Region or state name (e.g., “California”)
IANA timezone identifier (e.g., “America/Los_Angeles”)
Cloudflare data center IATA code (e.g., “SFO”, “LHR”)
Autonomous System Number of the client’s ISP
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.
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
Deployment
Deploy
Follow the deployment wizard to deploy the Worker to your Cloudflare account. No additional configuration required.
Local Development
Additional Request Metadata Fields
Depending on the request, thecf 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”)
Implementation Details
- Completely stateless — no external requests
- No database or KV storage required
- Returns raw
request.cfobject from Cloudflare - Works immediately after deployment
Cloudflare Features Used
- Workers — Edge compute runtime
- request.cf — Incoming request metadata including geolocation