# Bulk Reverse Geocoding & Time Zone Lookup (`forlab/reverse-geocoding`) Actor

Turn latitude and longitude into country, state or region, and county or district with worldwide point-in-polygon lookup. Get IANA time zones, nearby towns and postal codes, or download GeoJSON boundaries. $0.50 per 1,000 coordinate lookups plus $0.001 per run.

- **URL**: https://apify.com/forlab/reverse-geocoding.md
- **Developed by:** [ForLab Digital](https://apify.com/forlab) (community)
- **Categories:** Developer tools, Travel, Lead generation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 coordinate lookups

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Bulk Reverse Geocoding & Time Zone Lookup

Convert latitude and longitude into the country, state or region, and county or district that contain each point. Use **point-in-polygon reverse geocoding** to assign records to administrative areas. Enrich store locations, GPS data or coordinates from a places export with structured regions, IANA time zones or nearby postal codes. You can also look up nearby towns or download a place's administrative boundary as GeoJSON.

Choose one operation per run. The Actor supplies its own [ForLab Geo API](https://api.forlab.io/docs/geo) key. Send up to 5,000 items in a run. On the Apify free plan, the Actor processes up to 1,000 items per run.

### Task examples

Paste a complete JSON input into the **Input** tab. Use decimal degrees for `lat` and `lon`.

#### Reverse geocode GPS coordinates to administrative areas

The New York point returns United States → New York → New York County. The İstanbul point also returns Osmanağa, a mahalle whose mapped boundary contains the point.

```json
{"operation":"contains","items":[{"lat":40.7128,"lon":-74.006},{"lat":40.9903,"lon":29.0291}]}
```

#### Find the IANA time zone for a coordinate

This example returns `Asia/Tokyo`. The response includes the UTC offset, daylight saving flag and local time at the time of the lookup.

```json
{"operation":"timezone","items":[{"lat":35.6762,"lon":139.6503}]}
```

#### Find the nearest postal codes to a coordinate

Get up to three postal-code matches near the Paris point, with distances in kilometers. Postal coverage varies by country.

```json
{"operation":"postal_nearby","items":[{"lat":48.8566,"lon":2.3522,"limit":3}]}
```

### Example output

Each item yields a dataset row. Sort by `index` to restore input order. The New York lookup returns:

```json
{
  "index": 0,
  "input": {"lat":40.7128,"lon":-74.006},
  "status": "ok",
  "data": {
    "match": "found",
    "places": [
      {"id":"US","type":"country","local_type":"country","name":"United States"},
      {"id":"US-NY","type":"region","local_type":"state","name":"New York"},
      {"id":"US-J03Q150B","type":"county","local_type":"county","name":"New York County"}
    ]
  }
}
```

- `status` is `ok` for an answer or `not_found` for a miss. `invalid`, `failed` and `skipped` rows have no lookup charge.
- `code` identifies the reason for a non-`ok` row.
- `data.match` and `data.places` describe a `contains` result. Group records by `places[].id` and read `type` and `local_type` for the kind of area.
- A `timezone` result includes `data.timezone`, `utc_offset`, `dst` and `local_time` when a zone is found. Nearby lookups return a `data` array with `distance_km` for each result.
- `boundary` holds `key`, `url` and `bytes` for the GeoJSON Feature in the run's key-value store. For this operation, `data` holds the Feature's properties.

The run's `OUTPUT` record summarizes statuses, charges, skipped items and attribution.

### Pricing

| Lookup | Price |
| --- | --- |
| Coordinate lookup (`contains`, `timezone`, `nearby` or `postal_nearby`) | $0.50 per 1,000 |
| GeoJSON boundary, overview or standard | $1.00 per 1,000 |
| Full GeoJSON boundary | $3.00 per 1,000 |
| Actor start | $0.001 per run |

One lookup is charged per answered item, including misses. Invalid, failed and skipped items are free. The Actor charges lookup events after saving results.

### Operations

| Operation | Fields per item | Result |
| --- | --- | --- |
| `contains` | `lat`, `lon` | Containing administrative units from general to specific |
| `timezone` | `lat`, `lon` | IANA time zone, offset, daylight saving flag and local time |
| `nearby` | `lat`, `lon`, `limit`, `radius` in km, `lang` | Nearby populated places with distances in km |
| `postal_nearby` | `lat`, `lon`, `limit`, `radius` in km | Nearest postal codes with distances in km |
| `boundary` | `id`, `detail` (`overview`, `standard` or `full`) | GeoJSON Feature for a place with a boundary |

### Coverage

Level 1 is the state, province or region. Level 2 is the county, district or equivalent. Level 3 can be a neighborhood, village or municipality. Available levels and boundaries vary by country.

- **Turkey** has complete province and district lists and boundaries. The official TÜİK mahalle and köy list is complete, with partial boundary coverage. Reverse geocoding can return a mahalle or köy where its mapped boundary contains the point.
- **Italy** has the complete ISTAT list of comuni at level 3. Comune polygons are unavailable, so this Actor cannot match a coordinate to a comune.

Use [Turkey Province, District & Mahalle Lookup](https://apify.com/forlab/geo-reference) to browse the official lists. See [coverage by country](https://forlab.io/en/projects/geo-api/coverage) for separate list and boundary counts.

### Try it before you buy

Try the country or place routes for free without a key in the [Geo API docs](https://api.forlab.io/docs/geo) to inspect reference data. Coordinate lookups use an API key on the direct API. See [service status](https://status.forlab.io) or email <api@forlab.io> for a higher-volume key.

### Frequently asked questions

#### Does reverse geocoding return a street address?

The output identifies administrative areas such as states, counties and districts. It does not return street names or house numbers, or convert a street address into coordinates. Use `postal_nearby` for nearby postal codes.

#### Can I get the time zone and administrative region together?

Run `contains` and `timezone` with the same items, then join both datasets by `index`.

#### What happens with a point in the ocean?

`contains` returns `match: "none"` outside all loaded land boundaries.

### Run it from code

```bash
curl -X POST "https://api.apify.com/v2/acts/forlab~reverse-geocoding/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"operation":"contains","items":[{"lat":40.7128,"lon":-74.006}]}'
```

The run summary carries the attribution for the returned data. Boundaries draw on OpenStreetMap and Overture Maps, nearby places and postal codes on GeoNames, and time zones on timezone-boundary-builder and IANA tzdata.

# Actor input Schema

## `operation` (type: `string`):

One operation per run; every item becomes one lookup and one result row. Item fields by operation — contains and timezone: lat and lon (required, decimal degrees). nearby and postal_nearby: lat and lon (required), limit, radius (km), (nearby only) lang. boundary: id (required, an ID from a contains or nearby row), detail (overview, standard or full; default overview). A wrong field, a wrong type or an empty value makes that item invalid: the row says so and the item is not charged.

## `items` (type: `array`):

1–5,000 objects (1,000 on the Apify free plan), one lookup each, up to 16 at a time. Every row keeps its item under input with the zero-based index; rows come out in completion order, so sort by index if you need the input order. Nothing is looked up or charged past your run cost limit.

## Actor input object example

```json
{
  "operation": "contains",
  "items": [
    {
      "lat": 40.7128,
      "lon": -74.006
    },
    {
      "lat": 51.5072,
      "lon": -0.1276
    },
    {
      "lat": 48.8566,
      "lon": 2.3522
    },
    {
      "lat": -33.8688,
      "lon": 151.2093
    },
    {
      "lat": 41.0082,
      "lon": 28.9784
    }
  ]
}
```

# Actor output Schema

## `results` (type: `string`):

One item per input item: the input under input with its index, a status (ok, not_found, invalid, failed or skipped), the API's code when it answered an error, the API's data when it answered, and for boundaries the key-value record that holds the GeoJSON.

## `summary` (type: `string`):

Counts per status and per charged event, why items were skipped, and the dataset version and attribution of the data served.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "items": [
        {
            "lat": 40.7128,
            "lon": -74.006
        },
        {
            "lat": 51.5072,
            "lon": -0.1276
        },
        {
            "lat": 48.8566,
            "lon": 2.3522
        },
        {
            "lat": -33.8688,
            "lon": 151.2093
        },
        {
            "lat": 41.0082,
            "lon": 28.9784
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("forlab/reverse-geocoding").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "items": [
        {
            "lat": 40.7128,
            "lon": -74.006,
        },
        {
            "lat": 51.5072,
            "lon": -0.1276,
        },
        {
            "lat": 48.8566,
            "lon": 2.3522,
        },
        {
            "lat": -33.8688,
            "lon": 151.2093,
        },
        {
            "lat": 41.0082,
            "lon": 28.9784,
        },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("forlab/reverse-geocoding").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "items": [
    {
      "lat": 40.7128,
      "lon": -74.006
    },
    {
      "lat": 51.5072,
      "lon": -0.1276
    },
    {
      "lat": 48.8566,
      "lon": 2.3522
    },
    {
      "lat": -33.8688,
      "lon": 151.2093
    },
    {
      "lat": 41.0082,
      "lon": 28.9784
    }
  ]
}' |
apify call forlab/reverse-geocoding --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,forlab/reverse-geocoding"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/dLmoqdZ76AbRTwWMJ/builds/m1dUNpYVQz4TDkpYE/openapi.json
