---
title: geo_lookup
summary: Look up the geographic data associated with a particular IP address.
url: https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/geo/fn.geo_lookup/
---

**Kind:** Function  
**Module:** [geo](https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/geo/)  
**Package:** compute-sdk-cpp 0.7.0  
**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/geo.h#L37

```cpp
fastly::expected<std::optional<Geo>> fastly::geo::geo_lookup(std::string_view ip)
```

Look up the geographic data associated with a particular IP address.

Returns `std::nullopt` if no geographic data is available, such as when the IP address is reserved for private use.

###### Examples

To get geographic information for the downstream client:

**Parameters**

- `ip`: `std::string_view`

**Returns**

`fastly::expected<std::optional<Geo>>`

```cpp
auto client_ip{fastly::Request::from_client().get_client_ip_addr().value()};
auto geo{fastly::geo::geo_lookup(client_ip).value()};
if (geo.conn_type() == fastly::geo::ConnType::Satellite) {
    std::cout << "receiving a request from outer space 🛸";
}
```
