GeoResult
interface GeoResult {
ip: string | null;
country: Named | null;
state: { code: string | null; name: string } | null;
city: string | null;
postcode: string | null;
timezone: string | null;
latitude: number | null;
longitude: number | null;
language: string | null;
currency: string | null;
region: RegionName | null;
source: 'default' | 'cf';
}Where the visitor is, as Cloudflare's edge resolved it from their address: what GET /v1/geo reports. Every location is approximate, and null where the edge could not tell.
The example is GET /v1/geo?lang=en, from a browser in San Francisco set to English.
Example
{
"ip": "203.0.113.9",
"country": { "code": "US", "name": "United States" },
"state": { "code": "CA", "name": "California" },
"city": "San Francisco",
"postcode": "94103",
"timezone": "America/Los_Angeles",
"latitude": 37.77,
"longitude": -122.42,
"language": "en-US",
"currency": "USD",
"region": {
"code": "019",
"name": "Americas",
"subregion": { "code": "021", "name": "Northern America" }
},
"source": "cf"
}Properties
ip: string | null
The visitor's IP address. It identifies a person rather than a place, which is why GET /v1/geo is never cached.
country: Named | null
The country the visitor is in, named in ?lang=.
state: { code: string | null; name: string } | null
The region within the country, named as the edge names it, in English. code is the ISO 3166-2 suffix, when the edge sent one.
city: string | null
The city, as the edge names it.
postcode: string | null
The postcode of the visitor's area, as the edge resolved it.
timezone: string | null
An IANA time zone: America/Los_Angeles.
latitude: number | null
Approximate latitude, in degrees.
longitude: number | null
Approximate longitude, in degrees.
language: string | null
The browser's most preferred language, as a BCP 47 tag: what the browser is set to, not what is spoken where it is. A browser in Miami set to Spanish reports es-US, and one set to English in the same city en-US.
currency: string | null
The ISO 4217 currency in circulation where the visitor is. A reading of their location, not what to charge them: pricing stays the storefront's decision.
region: RegionName | null
The country's UN M49 region and subregion, named in ?lang=.
source: 'default' | 'cf'
cf when the edge resolved a country. default when it could not (a local request, or a Tor exit): country, currency and region are then null.