# Geolocations ## List Geolocations `client.Radar.Geolocations.List(ctx, query) (*GeolocationListResponse, error)` **get** `/radar/geolocations` Retrieves a list of geolocations. Geolocation names can be localized by sending an `Accept-Language` HTTP header with a BCP 47 language tag (e.g., `Accept-Language: pt-PT`). The full quality-value chain is supported (e.g., `pt-PT,pt;q=0.9,en;q=0.8`). ### Parameters - `query GeolocationListParams` - `Format param.Field[GeolocationListParamsFormat]` Format in which results will be returned. - `const GeolocationListParamsFormatJson GeolocationListParamsFormat = "JSON"` - `const GeolocationListParamsFormatCsv GeolocationListParamsFormat = "CSV"` - `GeoID param.Field[string]` Filters results by geolocation. Specify a comma-separated list of GeoNames IDs. - `Limit param.Field[int64]` Limits the number of objects returned in the response. - `Location param.Field[string]` Filters results by location. Specify a comma-separated list of alpha-2 location codes. - `Offset param.Field[int64]` Skips the specified number of objects before fetching the results. ### Returns - `type GeolocationListResponse struct{…}` - `Geolocations []GeolocationListResponseGeolocation` - `GeoID string` - `Latitude string` A numeric string. - `Longitude string` A numeric string. - `Name string` - `Parent GeolocationListResponseGeolocationsParent` - `GeoID string` - `Latitude string` A numeric string. - `Longitude string` A numeric string. - `Name string` - `Parent GeolocationListResponseGeolocationsParentParent` - `GeoID string` - `Latitude string` A numeric string. - `Longitude string` A numeric string. - `Name string` - `Type GeolocationListResponseGeolocationsParentParentType` The type of the geolocation. - `const GeolocationListResponseGeolocationsParentParentTypeContinent GeolocationListResponseGeolocationsParentParentType = "CONTINENT"` - `const GeolocationListResponseGeolocationsParentParentTypeCountry GeolocationListResponseGeolocationsParentParentType = "COUNTRY"` - `const GeolocationListResponseGeolocationsParentParentTypeAdm1 GeolocationListResponseGeolocationsParentParentType = "ADM1"` - `Code string` - `Locale string` BCP 47 locale code used for the geolocation name translation - `Type GeolocationListResponseGeolocationsParentType` The type of the geolocation. - `const GeolocationListResponseGeolocationsParentTypeContinent GeolocationListResponseGeolocationsParentType = "CONTINENT"` - `const GeolocationListResponseGeolocationsParentTypeCountry GeolocationListResponseGeolocationsParentType = "COUNTRY"` - `const GeolocationListResponseGeolocationsParentTypeAdm1 GeolocationListResponseGeolocationsParentType = "ADM1"` - `Code string` - `Locale string` BCP 47 locale code used for the geolocation name translation - `Type GeolocationListResponseGeolocationsType` The type of the geolocation. - `const GeolocationListResponseGeolocationsTypeContinent GeolocationListResponseGeolocationsType = "CONTINENT"` - `const GeolocationListResponseGeolocationsTypeCountry GeolocationListResponseGeolocationsType = "COUNTRY"` - `const GeolocationListResponseGeolocationsTypeAdm1 GeolocationListResponseGeolocationsType = "ADM1"` - `Code string` - `Locale string` BCP 47 locale code used for the geolocation name translation ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/radar" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) geolocations, err := client.Radar.Geolocations.List(context.TODO(), radar.GeolocationListParams{ }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", geolocations.Geolocations) } ``` #### Response ```json { "result": { "geolocations": [ { "geoId": "2267056", "latitude": "10", "longitude": "10", "name": "Lisbon", "parent": { "geoId": "2267056", "latitude": "10", "longitude": "10", "name": "Lisbon", "parent": { "geoId": "2267056", "latitude": "10", "longitude": "10", "name": "Lisbon", "type": "CONTINENT", "code": "PT-11", "locale": "pt-PT" }, "type": "CONTINENT", "code": "PT-11", "locale": "pt-PT" }, "type": "CONTINENT", "code": "PT-11", "locale": "pt-PT" } ] }, "success": true } ``` ## Get Geolocation details `client.Radar.Geolocations.Get(ctx, geoID, query) (*GeolocationGetResponse, error)` **get** `/radar/geolocations/{geo_id}` Retrieves the requested Geolocation information. Geolocation names can be localized by sending an `Accept-Language` HTTP header with a BCP 47 language tag (e.g., `Accept-Language: pt-PT`). The full quality-value chain is supported (e.g., `pt-PT,pt;q=0.9,en;q=0.8`). ### Parameters - `geoID string` Geolocation ID. Refer to [GeoNames](https://download.geonames.org/export/dump/readme.txt) - `query GeolocationGetParams` - `Format param.Field[GeolocationGetParamsFormat]` Format in which results will be returned. - `const GeolocationGetParamsFormatJson GeolocationGetParamsFormat = "JSON"` - `const GeolocationGetParamsFormatCsv GeolocationGetParamsFormat = "CSV"` ### Returns - `type GeolocationGetResponse struct{…}` - `Geolocation GeolocationGetResponseGeolocation` - `GeoID string` - `Latitude string` A numeric string. - `Longitude string` A numeric string. - `Name string` - `Parent GeolocationGetResponseGeolocationParent` - `GeoID string` - `Latitude string` A numeric string. - `Longitude string` A numeric string. - `Name string` - `Parent GeolocationGetResponseGeolocationParentParent` - `GeoID string` - `Latitude string` A numeric string. - `Longitude string` A numeric string. - `Name string` - `Type GeolocationGetResponseGeolocationParentParentType` The type of the geolocation. - `const GeolocationGetResponseGeolocationParentParentTypeContinent GeolocationGetResponseGeolocationParentParentType = "CONTINENT"` - `const GeolocationGetResponseGeolocationParentParentTypeCountry GeolocationGetResponseGeolocationParentParentType = "COUNTRY"` - `const GeolocationGetResponseGeolocationParentParentTypeAdm1 GeolocationGetResponseGeolocationParentParentType = "ADM1"` - `Code string` - `Locale string` BCP 47 locale code used for the geolocation name translation - `Type GeolocationGetResponseGeolocationParentType` The type of the geolocation. - `const GeolocationGetResponseGeolocationParentTypeContinent GeolocationGetResponseGeolocationParentType = "CONTINENT"` - `const GeolocationGetResponseGeolocationParentTypeCountry GeolocationGetResponseGeolocationParentType = "COUNTRY"` - `const GeolocationGetResponseGeolocationParentTypeAdm1 GeolocationGetResponseGeolocationParentType = "ADM1"` - `Code string` - `Locale string` BCP 47 locale code used for the geolocation name translation - `Type GeolocationGetResponseGeolocationType` The type of the geolocation. - `const GeolocationGetResponseGeolocationTypeContinent GeolocationGetResponseGeolocationType = "CONTINENT"` - `const GeolocationGetResponseGeolocationTypeCountry GeolocationGetResponseGeolocationType = "COUNTRY"` - `const GeolocationGetResponseGeolocationTypeAdm1 GeolocationGetResponseGeolocationType = "ADM1"` - `Code string` - `Locale string` BCP 47 locale code used for the geolocation name translation ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/radar" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) geolocation, err := client.Radar.Geolocations.Get( context.TODO(), "3190509", radar.GeolocationGetParams{ }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", geolocation.Geolocation) } ``` #### Response ```json { "result": { "geolocation": { "geoId": "2267056", "latitude": "10", "longitude": "10", "name": "Lisbon", "parent": { "geoId": "2267056", "latitude": "10", "longitude": "10", "name": "Lisbon", "parent": { "geoId": "2267056", "latitude": "10", "longitude": "10", "name": "Lisbon", "type": "CONTINENT", "code": "PT-11", "locale": "pt-PT" }, "type": "CONTINENT", "code": "PT-11", "locale": "pt-PT" }, "type": "CONTINENT", "code": "PT-11", "locale": "pt-PT" } }, "success": true } ```