# France Town Amenities: Shops, Doctors & Schools (INSEE BPE) (`datacraft-studio/france-town-amenities`) Actor

Official INSEE BPE open data: how many bakeries, supermarkets, pharmacies, GPs, dentists, schools, banks, restaurants and 200+ other facility types each French town, EPCI or department has, per 10,000 inhabitants. Find towns with no pharmacy or bakery. Pay per area.

- **URL**: https://apify.com/datacraft-studio/france-town-amenities.md
- **Developed by:** [Yahya Nouali](https://apify.com/datacraft-studio) (community)
- **Categories:** Real estate, Business
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$2.00 / 1,000 area delivereds

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

## France Town Amenities: Shops, Doctors & Schools (INSEE BPE)

How many **bakeries, supermarkets, pharmacies, GPs, dentists, schools, banks, restaurants, hairdressers, hotels** and 200+ other facility types does each French town have? This Actor returns the official **INSEE Permanent Facilities Base (BPE)** counts for any **town (commune), Paris/Lyon/Marseille district, intercommunality (EPCI), department, region, living area, urban area or employment area**, with the municipal population and densities **per 10,000 inhabitants**.

It also works as a **gap finder**: list the towns of more than 3,000 people with **no pharmacy**, no bakery or no GP, in one run.

### Who is it for?

- **Retail and franchise site selection**: find towns that lack a bakery, a supermarket, an optician, a gym…
- **Real estate investors and agents**: compare the services of towns before buying (schools, doctors, shops, transport).
- **Healthcare**: medical deserts (GPs, dentists, physiotherapists, pharmacies per 10k inhabitants).
- **Consultants, local authorities, data teams**: clean, official, ready-to-use territorial indicators.

### What you get (one row per area)

- Code, name, level, department, **municipal population** (INSEE reference population) and population year.
- **Total facilities**, facilities per 10k inhabitants, totals by domain (services, shops, education, health & social, transport, sports-leisure-culture, tourism) and by sub-domain.
- **40+ ready-made indicators**: bakeries, supermarkets, hypermarkets, convenience stores, groceries, butchers, pharmacies, GPs, dentists, nurses, physiotherapists, health centres, hospitals, emergency units, labs, childcare, primary/middle/high schools, post offices, banks, France Services, police/gendarmerie, restaurants, hairdressers, beauty salons, real estate agencies, driving schools, car repair, vets, fuel and EV charging stations, clothing stores, opticians, florists, train stations, hotels, campsites, cinemas, libraries, gyms, swimming pools, retirement homes.
- `per10kInhabitants` for the main indicators and `missingEssentials` (bakery, food shop, pharmacy, GP, primary school, post office, restaurant, hairdresser).
- `selectedFacilities`: your chosen types (codes like `B207`, sub-domains like `B2`, or French words like `boulangerie`) with count and density.
- `facilities`: the full list of facility types present with their official French label (optional).
- BPE reference date, source data date, source and licence.

### Input examples

Two towns with focus on bakeries and pharmacies:

```json
{ "codes": ["69123", "69266"], "facilityTypes": ["boulangerie", "pharmacie"], "maxItems": 10 }
```

Gap finder: towns of 3,000+ inhabitants without a pharmacy, in the whole of France:

```json
{ "missingFacilityTypes": ["pharmacie"], "minPopulation": 3000, "includeAllTypes": false }
```

All towns of the Rhône with the fewest GPs per 10k inhabitants:

```json
{ "departments": ["69"], "facilityTypes": ["D265"], "minPopulation": 2000, "sortBy": "selected_per10k_asc", "maxItems": 50 }
```

Intercommunalities by name: `{ "geoLevel": "EPCI", "townNames": ["Métropole de Lyon"] }`. Postal codes (towns): `{ "postalCodes": ["01000"] }`. Homonyms: `"Saint-Denis (93)"`.

### Pricing

**$0.002 per area delivered** ($2 per 1,000 towns). Filtered-out areas and the run summary row are free. A run for a few towns takes about 20-40 seconds.

### Data source and licence

- **Source : Insee, Base permanente des équipements (BPE)**, dataset *Dénombrement des équipements* (DS_BPE), counts on **1 January 2025** (geography of the INSEE file), dataset updated on 12 November 2026; populations: **Insee, populations de référence 2023** (DS_POPULATIONS_REFERENCE). Downloaded at each run from the official INSEE Melodi API (no key). The reference date and the source update date are returned in every row (`bpeReferenceDate`, `sourceDataDate`).
- Licence: **Licence Ouverte / Open Licence 2.0 (Etalab)**. The insee.fr legal notice allows free reuse **including for commercial purposes**, provided the source and date are cited and the meaning is not altered. This Actor does not alter the counts; densities are simple ratios computed by the Actor.
- Population is available for towns, districts, arrondissements, departments, regions and France (not for EPCI or study zones: `population` is then null).
- **No personal data**: only aggregated counts of facilities, no names or addresses.
- This Actor is not affiliated with or endorsed by INSEE.

### Notes

- A facility = a place providing a service (one GP practice, one bakery, one school…). See the INSEE documentation for definitions: https://www.insee.fr/fr/metadonnees/source/serie/s1161
- Towns with no facility at all are returned with zero counts (useful for gap finding).
- Facility type codes and labels are the official BPE 2025 ones (French labels).

# Changelog

This Actor's version history is a separate document: https://apify.com/datacraft-studio/france-town-amenities/changelog.md

# Actor input Schema

## `geoLevel` (type: `string`):

Level of the areas returned. COM = towns (communes), ARM = Paris/Lyon/Marseille districts, EPCI = intercommunalities, DEP = departments, REG = regions, BV2022 = living areas, AAV2020 = functional urban areas, UU2020 = urban units, ZE2020 = employment areas.

## `codes` (type: `array`):

Official INSEE codes at the chosen level, e.g. 69123 (Lyon) for towns, 200046977 for an EPCI, 69 for a department.

## `townNames` (type: `array`):

Exact names at the chosen level, e.g. Villeurbanne. Add the department in brackets to avoid homonyms: Saint-Denis (93).

## `postalCodes` (type: `array`):

5-digit postal codes (towns or districts only). Resolved with geo.api.gouv.fr.

## `departments` (type: `array`):

All towns (or districts) of these departments, e.g. 69, 2A, 974. Leave all area fields empty to scan the whole of France.

## `facilityTypes` (type: `array`):

BPE type codes (B207 bakery, D307 pharmacy, D265 GP...), sub-domains (B2 food shops) or French words (boulangerie, pharmacie, coiffure). Adds selectedFacilities counts and per-10k density, and allows sorting by them.

## `missingFacilityTypes` (type: `array`):

Return only areas where ALL of these facility types are absent, e.g. pharmacie. Combine with a minimum population to find towns without a pharmacy, bakery or GP.

## `minPopulation` (type: `integer`):

Keep only areas with at least this municipal population (towns, districts, departments, regions).

## `maxPopulation` (type: `integer`):

Keep only areas with at most this municipal population.

## `minTotalFacilities` (type: `integer`):

Keep only areas with at least this many facilities of all types.

## `includeAllTypes` (type: `boolean`):

Add the count of every facility type present (200+ types) in the facilities field.

## `sortBy` (type: `string`):

Order of the rows before the maxItems limit.

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

Maximum number of areas returned (each one is charged).

## Actor input object example

```json
{
  "geoLevel": "COM",
  "codes": [
    "69123",
    "69266"
  ],
  "facilityTypes": [
    "boulangerie",
    "pharmacie"
  ],
  "includeAllTypes": true,
  "sortBy": "population_desc",
  "maxItems": 10
}
```

# Actor output Schema

## `areas` (type: `string`):

One row per town or area with facility counts.

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

Reference date, counts, unknown inputs and source.

# 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 = {
    "codes": [
        "69123",
        "69266"
    ],
    "facilityTypes": [
        "boulangerie",
        "pharmacie"
    ],
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("datacraft-studio/france-town-amenities").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 = {
    "codes": [
        "69123",
        "69266",
    ],
    "facilityTypes": [
        "boulangerie",
        "pharmacie",
    ],
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("datacraft-studio/france-town-amenities").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 '{
  "codes": [
    "69123",
    "69266"
  ],
  "facilityTypes": [
    "boulangerie",
    "pharmacie"
  ],
  "maxItems": 10
}' |
apify call datacraft-studio/france-town-amenities --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,datacraft-studio/france-town-amenities"
        }
    }
}
```

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/LdxjYHpV5pOt634Qe/builds/JKlgmEdXPB8qFGTe5/openapi.json
