> For the complete documentation index, see [llms.txt](https://neox.gitbook.io/epicguard-wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://neox.gitbook.io/epicguard-wiki/api/examples.md).

# Examples

In this page, you can find some code examples on how you can use the API.

## Find the country/city of an address

You can find the country codes on the MaxMind site: <https://dev.maxmind.com/geoip/legacy/codes>

```java
EpicGuardAPI api = EpicGuardAPI.INSTANCE; // obtain the EpicGuardAPI instance.

GeoManager geoManager = api.getGeoManager(); // GeoManager instance.
String countryCode = geoManager.countryCode("127.0.0.1"); // ISO code of the country.
String city = geoManager.city("127.0.0.1"); // city's name
```

## Blacklisting and checking whitelist

This example will check if an address is whitelisted, and then will blacklist it.

```java
EpicGuardAPI api = EpicGuardAPI.INSTANCE; // obtain the EpicGuardAPI instance.
String address = "127.0.0.1";

if (api.getWhitelistedAddresses().contains(address)) {
    api.blacklistAddress(address);
}
```

## Checking attack status

This example will check if the server is under attack, and print the current connections per second.

```java
EpicGuardAPI api = EpicGuardAPI.INSTANCE; // obtain the EpicGuardAPI instance.

if (api.isUnderAttack()) {
    System.out.println("Current connections/s: " + api.getConnectionsPerSecond())
}
```
