# OpenStreetMap Places Monitor (`keepable_injera/osm-places-monitor`) Actor

Find OpenStreetMap places by category in named administrative areas and report new or changed places.

- **URL**: https://apify.com/keepable_injera/osm-places-monitor.md
- **Developed by:** [Chee Chiaw Lim](https://apify.com/keepable_injera) (community)
- **Categories:** Business, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 places

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

## OpenStreetMap Places Monitor

Find places by category within named administrative areas using the public [Overpass API](https://overpass-api.de/api/interpreter). Records include all OSM tags, contact details, coordinates, attribution, and change metadata.

### Input

```json
{
  "areas": ["Ljubljana"],
  "categories": ["amenity=cafe"],
  "onlyNew": true,
  "maxItems": 200,
  "stateStoreName": "osm-places-monitor-state"
}
```

`areas` accepts 1 to 3 exact administrative area names. `categories` accepts 1 to 5 `key=value` strings. Keys and values allow letters, digits, underscores, and colons. Optional `adminLevel` is a string containing one or two digits. It narrows ambiguous area names. Without it, all administrative areas with the exact name match. No boundary match produces no places.

`maxItems` limits emitted records, from 1 to 10000. It does not limit the size of the Overpass response. Use small areas and narrow categories. Requests never tile areas.

### Output and change detection

Each record has `osmId`, `osmType`, `name`, `category`, `tags`, `lat`, `lon`, `address`, `phone`, `website`, `openingHours`, `area`, `osmUrl`, `attribution`, `license`, `licenseUrl`, `checkedAt`, `changeType`, and `changedFields`. Missing optional values are null. Ways and relations use their bounding-box center. `category` is the first matching input category. Overlapping areas emit each OSM ID once, with the first matching input area.

`changeType` is `new`, `changed`, or `unchanged`. `changedFields` lists changed normalized fields. Changes to any tag count. Tag key order and check timestamps do not count. New records have an empty `changedFields` list.

With `onlyNew: true`, the actor emits new and changed records. With `false`, it also emits unchanged records. Snapshots persist only after successful pushes. Items skipped by the output limit or charging limit remain eligible next time. State is scoped to the area list, category list, and admin level. Use separate named stores for independent histories. Removal detection is not implemented.

`RUN_SUMMARY` in the default key-value store records fetched, eligible, and pushed counts, timestamps, charging stops, and errors. Each successful result uses the PPE event `result`. No separate charge call is made.

### Public API limits

Requests use POST form field `data`, a query timeout of 60 seconds, and a client timeout of 90 seconds including body download. Requests run sequentially with at least 2 seconds between starts. HTTP 429 and 504 retry up to three times with exponential backoff and `Retry-After`. HTTP 429 waits at least 30 seconds. Other failures stop the run. Incomplete responses with an Overpass remark fail without updating snapshots.

The User-Agent is `osm-places-monitor/1.0 (+https://apify.com/keepable_injera)`. See [TERMS.md](TERMS.md) for the source-use decisions.

### Source attribution and licence

Data is © OpenStreetMap contributors, available under [ODbL-1.0](https://www.openstreetmap.org/copyright). Every record carries attribution and a licence link. You must credit OpenStreetMap and disclose the ODbL licence when using the data. Distributed derived databases are subject to ODbL share-alike requirements. See the linked copyright page for details.

### Local verification

Run `npm install`, then `npm test`. Tests use Node's test runner and stub network responses. Run `npm start` to query the real API using `storage/key_value_stores/default/INPUT.json`. Keep live storage separate from test storage and preserve the named state store between monitoring runs.

# Actor input Schema

## `areas` (type: `array`):

Exact administrative area names. Maximum 3.

## `categories` (type: `array`):

Maximum 5 key=value pairs. Letters, digits, underscores, and colons only.

## `adminLevel` (type: `string`):

Optional OSM administrative level. Disambiguates area names.

## `onlyNew` (type: `boolean`):

Emit new and changed places. Disable to include unchanged places.

## `maxItems` (type: `integer`):

Maximum emitted records per run.

## `stateStoreName` (type: `string`):

Named store for snapshots saved after successful pushes.

## Actor input object example

```json
{
  "areas": [
    "Valletta"
  ],
  "categories": [
    "amenity=cafe"
  ],
  "onlyNew": true,
  "maxItems": 200,
  "stateStoreName": "osm-places-monitor-state"
}
```

# Actor output Schema

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

No description

## `runSummary` (type: `string`):

No description

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("keepable_injera/osm-places-monitor").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("keepable_injera/osm-places-monitor").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 '{}' |
apify call keepable_injera/osm-places-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,keepable_injera/osm-places-monitor"
        }
    }
}
```

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/Pu5heeUXgJrcQ443J/builds/59ujZUC1esoeBye33/openapi.json
