# AI location intelligence (`saadithya/ai-location-intelligence`) Actor

Analyze multiple locations (via Google Maps URLs) for a given business type and generate a suitability score using OpenStreetMap (Overpass API) + OpenAI (GPT-4o)

- **URL**: https://apify.com/saadithya/ai-location-intelligence.md
- **Developed by:** [Aadhithya](https://apify.com/saadithya) (community)
- **Categories:** Other, AI, Real estate
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $100.00 / 1,000 location-analyses

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## AI Location Intelligence Analyzer

A production-ready Apify Actor that analyzes multiple locations for business suitability using OpenStreetMap data and OpenAI GPT-4o.

### 🎯 What It Does

This Actor converts Google Maps URLs into actionable location intelligence by:
- Extracting coordinates from Google Maps URLs
- Using AI to select relevant OpenStreetMap data layers
- Fetching nearby points of interest (POIs) from OpenStreetMap
- Analyzing location suitability with GPT-4o
- Generating a comprehensive suitability score (1-10)

### 📊 Output

Each analyzed location returns:
- **Score**: Overall suitability (1-10)
- **Footfall**: Expected foot traffic (Low/Medium/High)
- **Competition**: Competitive density (Low/Medium/High)
- **Accessibility**: Location accessibility (Poor/Moderate/Good)
- **Summary**: AI-generated analysis explanation
- **POI Counts**: Breakdown of nearby points of interest

### 🚀 Quick Start

#### 1. Installation

```bash
npm install
````

#### 2. Local Testing

Create an `input.json` file:

```json
{
  "locationUrls": [
    "https://maps.google.com/?q=12.9716,77.5946",
    "https://www.google.com/maps/@40.7128,-74.0060,15z"
  ],
  "businessDescription": "restaurant",
  "radiusMeters": 1000,
  "openaiApiKey": "your_openai_api_key_here",
  "model": "gpt-4o",
  "testMode": false
}
```

Run locally:

```bash
npm start
```

#### 3. Test Mode

To test without API calls:

```json
{
  "businessDescription": "restaurant",
  "testMode": true
}
```

### 📝 Input Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `locationUrls` | array | ✅ | - | List of Google Maps URLs with coordinates |
| `businessDescription` | string | ✅ | - | Business type (e.g., "restaurant", "gym") |
| `radiusMeters` | number | ❌ | 1000 | Search radius in meters (100-10000) |
| `testMode` | boolean | ❌ | false | Run with mock data (no API calls) |

### 🔐 Environment Variables

These must be set in Actor Settings (not in input):

| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| `OPENAI_API_KEY` | ✅ | - | Your OpenAI API key (get at https://platform.openai.com/api-keys) |
| `OPENAI_MODEL` | ❌ | gpt-4o | OpenAI model (gpt-4o, gpt-4o-mini, gpt-3.5-turbo) |

### 🌍 Supported URL Formats

- `https://maps.google.com/?q=12.9716,77.5946`
- `https://www.google.com/maps/@12.9716,77.5946,15z`
- `https://maps.google.com/?ll=12.9716,77.5946`

### 💰 Pricing

This Actor uses pay-per-event pricing:

- **Event**: `location-analysis`
- **Charged**: Only when analysis completes successfully
- **Test mode**: Free (no charges)

### 🛡️ Error Handling

- Failed coordinate parsing → Skips URL with warning
- Overpass API errors → Continues with next location
- OpenAI API errors → Falls back to rule-based analysis
- Never crashes the Actor

### ⚡ Performance

- Processes locations sequentially
- 2-second delay between requests (respects Overpass rate limits)
- 30-second timeout per Overpass call
- Typical runtime: 1-3 minutes for 5 locations

### 🔧 Advanced Usage

#### API Integration

```bash
curl https://api.apify.com/v2/acts/YOUR_USERNAME~ai-location-intelligence-analyzer/runs \
  -d '{
    "locationUrls": ["https://maps.google.com/?q=12.9716,77.5946"],
    "businessDescription": "coffee shop",
    "openaiApiKey": "sk-..."
  }' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_APIFY_TOKEN'
```

#### Dataset Output

Results are stored in Apify dataset with the following structure:

```json
{
  "latitude": 12.9716,
  "longitude": 77.5946,
  "businessType": "restaurant",
  "score": 8,
  "footfall": "High",
  "competition": "Medium",
  "accessibility": "Good",
  "summary": "Excellent location with high foot traffic...",
  "poiCounts": {
    "restaurants": 25,
    "schools": 8,
    "transport": 12
  }
}
```

### 📦 Tech Stack

- **Runtime**: Node.js 20
- **Platform**: Apify Actor
- **AI**: OpenAI GPT-4o
- **Data**: OpenStreetMap (Overpass API)
- **Dependencies**:
  - `apify` - Apify SDK
  - `openai` - OpenAI API client

### 🌟 Use Cases

- 🏪 Retail site selection
- 🍽️ Restaurant location analysis
- 🏋️ Fitness center placement
- 💼 Coworking space scouting
- 🏥 Healthcare facility planning
- 🏪 Franchise expansion planning

### 📋 Examples

#### Example 1: Analyze Restaurant Locations

**Input**:

```json
{
  "locationUrls": [
    "https://maps.google.com/?q=12.9716,77.5946",
    "https://www.google.com/maps/@40.7128,-74.0060,15z"
  ],
  "businessDescription": "restaurant",
  "radiusMeters": 1000
}
```

**Environment Variables** (set in Actor Settings):

- `OPENAI_API_KEY`: your\_openai\_api\_key
- `OPENAI_MODEL`: gpt-4o (optional, default is gpt-4o)

#### Example 2: Test Mode (Free)

```json
{
  "businessDescription": "coffee shop",
  "testMode": true
}
```

#### Example 3: Gym Location Analysis

**Input**:

```json
{
  "locationUrls": [
    "https://maps.google.com/?q=34.0522,-118.2437"
  ],
  "businessDescription": "gym",
  "radiusMeters": 2000
}
```

**Environment Variables**:

- `OPENAI_API_KEY`: your\_openai\_api\_key
- `OPENAI_MODEL`: gpt-4o-mini (optional)

#### Example Output

```json
{
  "latitude": 12.9716,
  "longitude": 77.5946,
  "businessType": "restaurant",
  "score": 8,
  "footfall": "High",
  "competition": "Medium",
  "accessibility": "Good",
  "summary": "Excellent location with high foot traffic and moderate competition. Good accessibility makes it ideal for restaurant business.",
  "poiCounts": {
    "restaurants": 25,
    "schools": 8,
    "transport": 12
  }
}
```

### 📄 License

ISC

### 🤝 Support

For issues or feature requests, please open an issue in the repository.

# Actor input Schema

## `locationUrls` (type: `array`):

List of Google Maps URLs containing coordinates to analyze. Supports formats: ?q=lat,lon / @lat,lon,zoom / ?ll=lat,lon

## `businessDescription` (type: `string`):

Type of business to analyze location suitability for (e.g., restaurant, gym, beauty salon, coworking space)

## `radiusMeters` (type: `integer`):

Search radius in meters around each location to analyze nearby points of interest. Range: 100-10000 meters

## `testMode` (type: `boolean`):

Run in test mode with mock data. No API calls will be made. Useful for testing without costs.

## Actor input object example

```json
{
  "locationUrls": [
    "https://maps.google.com/?q=12.9716,77.5946",
    "https://www.google.com/maps/@40.7128,-74.0060,15z"
  ],
  "businessDescription": "coffee shop",
  "radiusMeters": 1000,
  "testMode": false
}
```

# 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 = {
    "locationUrls": [
        "https://maps.google.com/?q=12.9716,77.5946",
        "https://www.google.com/maps/@40.7128,-74.0060,15z"
    ],
    "businessDescription": "restaurant"
};

// Run the Actor and wait for it to finish
const run = await client.actor("saadithya/ai-location-intelligence").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 = {
    "locationUrls": [
        "https://maps.google.com/?q=12.9716,77.5946",
        "https://www.google.com/maps/@40.7128,-74.0060,15z",
    ],
    "businessDescription": "restaurant",
}

# Run the Actor and wait for it to finish
run = client.actor("saadithya/ai-location-intelligence").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "locationUrls": [
    "https://maps.google.com/?q=12.9716,77.5946",
    "https://www.google.com/maps/@40.7128,-74.0060,15z"
  ],
  "businessDescription": "restaurant"
}' |
apify call saadithya/ai-location-intelligence --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=saadithya/ai-location-intelligence",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "AI location intelligence",
        "description": "Analyze multiple locations (via Google Maps URLs) for a given business type and generate a suitability score using OpenStreetMap (Overpass API) + OpenAI (GPT-4o)",
        "version": "0.0",
        "x-build-id": "BWVcnI7xOKGvrXKc0"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/saadithya~ai-location-intelligence/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-saadithya-ai-location-intelligence",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/saadithya~ai-location-intelligence/runs": {
            "post": {
                "operationId": "runs-sync-saadithya-ai-location-intelligence",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/saadithya~ai-location-intelligence/run-sync": {
            "post": {
                "operationId": "run-sync-saadithya-ai-location-intelligence",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "locationUrls",
                    "businessDescription"
                ],
                "properties": {
                    "locationUrls": {
                        "title": "Google Maps URLs",
                        "minItems": 1,
                        "maxItems": 50,
                        "type": "array",
                        "description": "List of Google Maps URLs containing coordinates to analyze. Supports formats: ?q=lat,lon / @lat,lon,zoom / ?ll=lat,lon",
                        "items": {
                            "type": "string"
                        }
                    },
                    "businessDescription": {
                        "title": "Business Type",
                        "minLength": 2,
                        "maxLength": 200,
                        "type": "string",
                        "description": "Type of business to analyze location suitability for (e.g., restaurant, gym, beauty salon, coworking space)"
                    },
                    "radiusMeters": {
                        "title": "Analysis Radius (meters)",
                        "minimum": 100,
                        "maximum": 10000,
                        "type": "integer",
                        "description": "Search radius in meters around each location to analyze nearby points of interest. Range: 100-10000 meters",
                        "default": 1000
                    },
                    "testMode": {
                        "title": "Test Mode",
                        "type": "boolean",
                        "description": "Run in test mode with mock data. No API calls will be made. Useful for testing without costs.",
                        "default": false
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
