MCP-Server

Morocco communes

io.github.zkousama/morocco-communes
Daten & Analytik Karten & Standort Öffentlich und erreichbar MCP 2025-11-25

Was dieses MCP kann

Provides Moroccan administrative geography, boundary lookups, nearby communes, census populations, housing, economic, and demographic indicators.

commune_at
Commune at a point
The commune whose boundary contains a point, with its names, type, parents and population, and in Casablanca, Rabat, Fès, Marrakech, Salé and Tanger the arrondissement too. Use it to turn coordinates, from a map or a device, into a commune. Sidi Mohamed Benmansour has no boundary, and neither do about 88 km² between Ifrane and Boulemane.
Nur Lesen Idempotent
Eingabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'required': ['lat', 'lng'], 'properties': {'lat': {'type': 'number', 'maximum': 90, 'minimum': -90, 'description': 'Latitude, in degrees.'}, 'lng': {'type': 'number', 'maximum': 180, 'minimum': -180, 'description': 'Longitude, in degrees.'}}}
Ausgabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'required': ['commune', 'arrondissement'], 'properties': {'commune': {'type': 'object', 'required': ['code', 'slug', 'name_fr', 'name_ar', 'type', 'region', 'province', 'cercle', 'population_2024', 'population_2014', 'change_pct', 'area_km2', 'density', 'centroid'], 'properties': {'code': {'type': 'string'}, 'slug': {'type': 'string'}, 'type': {'enum': ['urban', 'rural'], 'type': 'string'}, 'cercle': {'anyOf': [{'type': 'object', 'required': ['code', 'name'], 'properties': {'code': {'type': 'string'}, 'name': {'type': 'string'}}, 'additionalProperties': False}, {'type': 'null'}]}, 'region': {'type': 'object', 'required': ['code', 'name'], 'properties': {'code': {'type': 'string'}, 'name': {'type': 'string'}}, 'additionalProperties': False}, 'density': {'type': ['number', 'null']}, 'name_ar': {'type': 'string'}, 'name_fr': {'type': 'string'}, 'area_km2': {'type': ['number', 'null']}, 'centroid': {'anyOf': [{'type': 'object', 'required': ['lat', 'lng'], 'properties': {'lat': {'type': 'number'}, 'lng': {'type': 'number'}}, 'additionalProperties': False}, {'type': 'null'}]}, 'province': {'type': 'object', 'required': ['code', 'name'], 'properties': {'code': {'type': 'string'}, 'name': {'type': 'string'}}, 'additionalProperties': False}, 'change_pct': {'type': ['number', 'null']}, 'population_2014': {'type': ['number', 'null']}, 'population_2024': {'type': ['number', 'null']}}, 'additionalProperties': False}, 'arrondissement': {'anyOf': [{'type': 'object', 'required': ['code', 'name_fr', 'name_ar'], 'properties': {'code': {'type': 'string'}, 'name_ar': {'type': 'string'}, 'name_fr': {'type': 'string'}}, 'additionalProperties': False}, {'type': 'null'}]}}, 'additionalProperties': False}
communes_near
Communes near a point
Communes within a radius of a point, nearest first. Distance is measured to each commune's centroid, so the nearest commune isn't always the one that contains the point: commune_at gives that one.
Nur Lesen Idempotent
Eingabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'required': ['lat', 'lng'], 'properties': {'lat': {'type': 'number', 'maximum': 90, 'minimum': -90, 'description': 'Latitude, in degrees.'}, 'lng': {'type': 'number', 'maximum': 180, 'minimum': -180, 'description': 'Longitude, in degrees.'}, 'limit': {'type': 'integer', 'maximum': 50, 'minimum': 1, 'description': 'How many results. 10 when left out, at most 50.'}, 'radius_km': {'type': 'number', 'maximum': 100, 'description': 'Radius in km. 10 when left out, at most 100.', 'exclusiveMinimum': 0}}}
Ausgabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'required': ['results'], 'properties': {'results': {'type': 'array', 'items': {'type': 'object', 'required': ['code', 'name_fr', 'name_ar', 'slug', 'distance_km'], 'properties': {'code': {'type': 'string'}, 'slug': {'type': 'string'}, 'name_ar': {'type': 'string'}, 'name_fr': {'type': 'string'}, 'distance_km': {'type': 'number'}}, 'additionalProperties': False}}}, 'additionalProperties': False}
get_commune
Get one commune
One commune's names, type, région, province and cercle, 2024 and 2014 population, the change between them, a point inside it, the communes it borders and how much boundary it shares with each, and in the 6 cities divided into them, its arrondissements with their population. Identify it by HCP code (01.511.01.0), the code as digits, or a slug (tanger).
Nur Lesen Idempotent
Eingabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'required': ['id'], 'properties': {'id': {'type': 'string', 'minLength': 1, 'description': 'An HCP code, the code as digits, or a slug.'}}}
Ausgabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'required': ['commune', 'arrondissements', 'neighbours'], 'properties': {'commune': {'type': 'object', 'required': ['code', 'slug', 'name_fr', 'name_ar', 'type', 'region', 'province', 'cercle', 'population_2024', 'population_2014', 'change_pct', 'area_km2', 'density', 'centroid'], 'properties': {'code': {'type': 'string'}, 'slug': {'type': 'string'}, 'type': {'enum': ['urban', 'rural'], 'type': 'string'}, 'cercle': {'anyOf': [{'type': 'object', 'required': ['code', 'name'], 'properties': {'code': {'type': 'string'}, 'name': {'type': 'string'}}, 'additionalProperties': False}, {'type': 'null'}]}, 'region': {'type': 'object', 'required': ['code', 'name'], 'properties': {'code': {'type': 'string'}, 'name': {'type': 'string'}}, 'additionalProperties': False}, 'density': {'type': ['number', 'null']}, 'name_ar': {'type': 'string'}, 'name_fr': {'type': 'string'}, 'area_km2': {'type': ['number', 'null']}, 'centroid': {'anyOf': [{'type': 'object', 'required': ['lat', 'lng'], 'properties': {'lat': {'type': 'number'}, 'lng': {'type': 'number'}}, 'additionalProperties': False}, {'type': 'null'}]}, 'province': {'type': 'object', 'required': ['code', 'name'], 'properties': {'code': {'type': 'string'}, 'name': {'type': 'string'}}, 'additionalProperties': False}, 'change_pct': {'type': ['number', 'null']}, 'population_2014': {'type': ['number', 'null']}, 'population_2024': {'type': ['number', 'null']}}, 'additionalProperties': False}, 'neighbours': {'type': 'array', 'items': {'type': 'object', 'required': ['code', 'name_fr', 'km'], 'properties': {'km': {'type': 'number'}, 'code': {'type': 'string'}, 'name_fr': {'type': 'string'}}, 'additionalProperties': False}, 'description': 'The communes this one borders, longest shared boundary first. Measured on the OpenStreetMap boundaries, so it is under ODbL.'}, 'arrondissements': {'type': 'array', 'items': {'type': 'object', 'required': ['code', 'name_fr', 'name_ar', 'population_2024'], 'properties': {'code': {'type': 'string'}, 'name_ar': {'type': 'string'}, 'name_fr': {'type': 'string'}, 'population_2024': {'type': ['number', 'null']}}, 'additionalProperties': False}, 'description': "Casablanca, Rabat, Fès, Marrakech, Salé and Tanger's arrondissements, most populous first; empty elsewhere."}}, 'additionalProperties': False}
get_economy
Economic establishments
HCP's 2024 count of economic establishments for Morocco or any région, province or préfecture, cercle, commune or arrondissement: how many establishments were mapped, how many are public services, how many are associations in premises of their own, how many are businesses, and how many permanent jobs those businesses hold. The businesses are split three ways, each covering all of them: by sector (industry, construction, commerce, services), by how many people work there (1, 2-3, 4-9, 10-49, 50 and over), and by when they were founded (before 1956 through 2020 and later). The weekly souks in use are counted beside them and are not part of the total. Reading them: every figure is a count, taken during the census by field teams who mapped each establishment. Farming is out, the workbook counts every sector but agriculture, and the jobs are the permanent ones. Ranking and comparing: to order communes by one of these, call list_communes with sort set to its path, such as economy.establishments.jobs, or by one of the 3 it works out from them: economy.per1000.establishments, economy.per1000.jobs, economy.perBusiness.jobs. To compare the régions, the provinces or the arrondissements, give level without a unit and get them all in one call. Casablanca and the 5 other cities divided into arrondissements are counted by arrondissement, so their figures are the sum of those, marked basis: arrondissement_sum. Say so when you report one.
Nur Lesen Idempotent
Eingabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'properties': {'unit': {'type': 'string', 'minLength': 1, 'description': 'A région, province or préfecture, cercle, commune or arrondissement, by code or slug. Morocco as a whole when left out.'}, 'level': {'enum': ['commune', 'arrondissement', 'province', 'region', 'cercle'], 'type': 'string', 'description': "With a unit, the level it's at, where a name is shared: Tiznit is a commune and a province, and a name alone means the commune. Without a unit, region, province or arrondissement gives every one of that level in one call."}, 'topics': {'type': 'array', 'items': {'enum': ['establishments', 'sector', 'size', 'founded'], 'type': 'string'}, 'description': 'Only these topics. Every topic when left out.'}}}
Ausgabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'required': ['results'], 'properties': {'results': {'type': 'array', 'items': {'type': 'object', 'required': ['unit', 'figures'], 'properties': {'unit': {'type': 'object', 'required': ['code', 'level', 'name_fr', 'name_ar'], 'properties': {'code': {'type': ['string', 'null']}, 'level': {'type': 'string'}, 'name_ar': {'type': ['string', 'null']}, 'name_fr': {'type': 'string'}}, 'additionalProperties': False}, 'basis': {'type': 'string', 'const': 'arrondissement_sum', 'description': 'Present on the 6 cities the census counts by arrondissement: these figures are the sum of their arrondissements, not a count HCP publishes for the city.'}, 'figures': {'type': 'object', 'description': 'By topic, then by key. Counts of establishments, of permanent jobs, or of weekly souks.', 'propertyNames': {'type': 'string'}, 'additionalProperties': {'type': 'object', 'propertyNames': {'type': 'string'}, 'additionalProperties': {'type': ['number', 'null']}}}}, 'additionalProperties': False}}}, 'additionalProperties': False}
get_housing
Urban housing stock
HCP's 2024 count of urban dwellings for Morocco or any unit that has an urban area: how many there are, how many are occupied, vacant or second homes, what kind they are (villa, apartment, traditional or modern Moroccan house, slum, rural-type), how old they are, what their walls and roofs are made of, how many are on the public electricity, water and sewerage networks, and HCP's housing shortfall. Every figure but the count is a percentage of that unit's urban dwellings. This counts dwellings, not households: a vacant flat is here and in nobody's census record, and get_indicators describes the dwelling each household lives in, for the whole country rather than the towns. A unit with no urban area has nothing here. For the households with running water or electricity in any commune, rural ones included, use get_indicators' amenities topic, and its wastewater topic for a public sewer; list_communes can sort by either, as in amenities.runningWater.
Nur Lesen Idempotent
Eingabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'properties': {'unit': {'type': 'string', 'minLength': 1, 'description': 'A unit by code or slug. Morocco as a whole when left out.'}, 'level': {'enum': ['commune', 'arrondissement', 'province', 'region', 'cercle'], 'type': 'string', 'description': "With a unit, the level it's at. Without one, region, province or arrondissement gives every one of that level."}, 'topics': {'type': 'array', 'items': {'enum': ['dwellings', 'occupancy', 'type', 'age', 'ageByType', 'walls', 'roofs', 'networks'], 'type': 'string'}, 'description': 'Only these topics. Every topic when left out.'}}}
Ausgabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'required': ['results'], 'properties': {'results': {'type': 'array', 'items': {'type': 'object', 'required': ['unit', 'figures'], 'properties': {'unit': {'type': 'object', 'required': ['code', 'level', 'name_fr', 'name_ar'], 'properties': {'code': {'type': ['string', 'null']}, 'level': {'type': 'string'}, 'name_ar': {'type': ['string', 'null']}, 'name_fr': {'type': 'string'}}, 'additionalProperties': False}, 'figures': {'type': 'object', 'description': 'By topic, then by key.', 'propertyNames': {'type': 'string'}, 'additionalProperties': {'type': 'object', 'propertyNames': {'type': 'string'}, 'additionalProperties': {'type': ['number', 'null']}}}}, 'additionalProperties': False}}}, 'additionalProperties': False}
get_indicators
Census indicators
HCP's census figures for Morocco or any région, province or préfecture, cercle, commune or arrondissement: age, marital status, fertility, disability, schooling, illiteracy, the languages people read and write and the local languages they use, education, work, employment status and how people get to work, and for households their size, dwelling, occupancy, amenities, wastewater, waste and cooking fuel. Reading them: shares and rates are percentages from 0 to 100. Null means HCP publishes no figure there. Most come from the long questionnaire, which went to a random 20% of households in communes of 2,000 households or more, so there they're estimates. Ranking and comparing: to order communes by one figure, call list_communes with sort set to its path, rather than this once per commune. To compare the régions, the provinces or the arrondissements, give level without a unit and get them all in one call. The 2014 census is here too, under census. Age, education, local languages, illiteracy, fertility, disability, work, the ways of getting to work, dwellings, amenities, wastewater and waste ask what 2024 asks and can be read against it. Where people work and how children get to school are 2014 only. Five topics changed and can't be subtracted: marital status covered everyone rather than people aged 15 and over, schooling ages 7 to 12 rather than 6 to 11, reading and writing was asked as combinations of languages rather than one at a time, a household counted under every cooking fuel it used, and the employment shares took in unemployed people who had worked before. A unit the 2014 census didn't count has null there, Casablanca and the 5 other cities with arrondissements among them, since 2014 published those by arrondissement.
Nur Lesen Idempotent
Eingabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'properties': {'sex': {'enum': ['all', 'male', 'female', 'each'], 'type': 'string', 'description': 'Everyone (all), men, women, or each of the three. all when left out. Household figures have no sex.'}, 'area': {'enum': ['total', 'urban', 'rural', 'each'], 'type': 'string', 'description': 'The whole unit (total), its urban or rural part, or each of the three. total when left out.'}, 'unit': {'type': 'string', 'minLength': 1, 'description': 'A région, province or préfecture, cercle, commune or arrondissement, by code or slug. Morocco as a whole when left out.'}, 'level': {'enum': ['commune', 'arrondissement', 'province', 'region', 'cercle'], 'type': 'string', 'description': "With a unit, the level it's at, where a name is shared: Tiznit is a commune and a province, and a name alone means the commune. Without a unit, region, province or arrondissement gives every one of that level in one call."}, 'census': {'enum': ['2014', '2024', 'both'], 'type': 'string', 'description': 'Which census. 2024 when left out. both gives the two together, to see what changed.'}, 'topics': {'type': 'array', 'items': {'enum': ['population', 'sex', 'age', 'maritalStatus', 'fertility', 'disability', 'schooling', 'illiteracy', 'languagesReadAndWritten', 'education', 'localLanguages', 'labour', 'employmentStatus', 'commute', 'households', 'dwellingType', 'occupancy', 'dwellingAge', 'amenities', 'wastewater', 'householdWaste', 'cookingFuel'], 'type': 'string'}, 'description': 'Only these topics. Every topic when left out. Two are easy to confuse: labour holds the labour force, the activity rate and the unemployment rate, while employmentStatus is how the people in work are employed, as employees, self-employed or apprentices.'}}}
Ausgabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'required': ['results'], 'properties': {'results': {'type': 'array', 'items': {'type': 'object', 'required': ['unit', 'from_local_administration', 'figures'], 'properties': {'unit': {'type': 'object', 'required': ['code', 'level', 'name_fr', 'name_ar'], 'properties': {'code': {'type': ['string', 'null']}, 'level': {'type': 'string'}, 'name_ar': {'type': ['string', 'null']}, 'name_fr': {'type': 'string'}}, 'additionalProperties': False}, 'figures': {'type': 'object', 'description': "By census year, then by area: people by sex, then households, each by topic and key. Null for an area the unit doesn't have, and for a census that didn't count it.", 'propertyNames': {'type': 'string'}, 'additionalProperties': {'anyOf': [{'type': 'object', 'propertyNames': {'type': 'string'}, 'additionalProperties': {'anyOf': [{'type': 'object', 'propertyNames': {'type': 'string'}, 'additionalProperties': {}}, {'type': 'null'}]}}, {'type': 'null'}]}}, 'from_local_administration': {'type': 'boolean', 'description': "HCP collected this unit's figures from the local administration, as its population moves with the seasons; only the counts are published."}}, 'additionalProperties': False}}}, 'additionalProperties': False}
get_insights
Figures that stand out in a commune
For a commune, up to 3 of its 2024 census figures that stand out: among the highest or lowest communes, moved far more or less than other communes since 2014, or far from its province's figure. Each comes with its context as numbers, worked out from the census: the commune's other figures here, the communes it borders on the same figure (their median and the one furthest from it), and the same figure in 2014 beside Morocco's, where the two censuses can be compared. A commune with any figure the two censuses disagree on is left out, on its own page and as a neighbour. Figures they measure differently, shares by sex and likely errors in the data are left out too. An economy or housing figure on fewer than 100 businesses or urban dwellings is left out, since a handful of them can swing a share. A census figure in a commune of 2,000 households or more is marked sampled, since the long questionnaire went to a sample of households there. No language model writes or judges any of it. Only communes have these, and most have none.
Nur Lesen Idempotent
Eingabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'required': ['unit'], 'properties': {'unit': {'type': 'string', 'minLength': 1, 'description': 'A commune, by code or slug.'}, 'level': {'enum': ['commune', 'arrondissement', 'province', 'region', 'cercle'], 'type': 'string', 'description': 'The level, where a name is shared: Tiznit is a commune and a province, and a name alone means the commune.'}}}
Ausgabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'required': ['unit', 'findings'], 'properties': {'unit': {'type': 'object', 'required': ['code', 'level', 'name_fr', 'name_ar'], 'properties': {'code': {'type': 'string'}, 'level': {'type': 'string'}, 'name_ar': {'type': ['string', 'null']}, 'name_fr': {'type': 'string'}}, 'additionalProperties': False}, 'message': {'type': 'string', 'description': 'Present when no figures are published for this place.'}, 'findings': {'type': 'array', 'items': {'type': 'object', 'required': ['id', 'kind', 'measure', 'value', 'reference', 'direction', 'sampled', 'line', 'breakdown', 'context'], 'properties': {'id': {'type': 'string'}, 'kind': {'enum': ['extreme', 'change', 'gap'], 'type': 'string', 'description': "extreme: among the highest or lowest communes; change: moved far more or less than other communes since 2014; gap: far from its province's figure."}, 'line': {'type': 'object', 'required': ['en', 'fr'], 'properties': {'en': {'type': 'string'}, 'fr': {'type': 'string'}}, 'additionalProperties': False}, 'value': {'type': 'number', 'description': 'The 2024 figure, or for a change the points it moved since 2014.'}, 'context': {'type': 'object', 'required': ['others', 'neighbours', 'since2014'], 'properties': {'others': {'type': 'array', 'items': {'type': 'object', 'required': ['id', 'kind', 'measure'], 'properties': {'id': {'type': 'string'}, 'kind': {'type': 'string'}, 'measure': {'type': 'string'}}, 'additionalProperties': False}, 'description': "The commune's other figures here."}, 'since2014': {'anyOf': [{'type': 'object', 'required': ['then', 'now', 'morocco'], 'properties': {'now': {'type': 'number'}, 'then': {'type': 'number'}, 'morocco': {'type': 'object', 'required': ['then', 'now'], 'properties': {'now': {'type': 'number'}, 'then': {'type': 'number'}}, 'additionalProperties': False}}, 'additionalProperties': False}, {'type': 'null'}], 'description': "The figure in 2014 and 2024, here and across Morocco; null where the two censuses can't be compared."}, 'neighbours': {'anyOf': [{'type': 'object', 'required': ['bordering', 'compared', 'median', 'furthest'], 'properties': {'median': {'type': 'number'}, 'compared': {'type': 'number', 'description': 'How many of them have the figure to compare; the median is over these.'}, 'furthest': {'type': 'object', 'required': ['code', 'name', 'value'], 'properties': {'code': {'type': 'string'}, 'name': {'type': 'object', 'required': ['fr', 'ar'], 'properties': {'ar': {'type': ['string', 'null']}, 'fr': {'type': 'string'}}, 'additionalProperties': False}, 'value': {'type': 'number'}}, 'description': "The bordering commune whose figure is furthest from this one's.", 'additionalProperties': False}, 'bordering': {'type': 'number', 'description': 'How many communes it borders.'}}, 'additionalProperties': False}, {'type': 'null'}], 'description': 'The bordering communes on the same figure, or for a change on the same change; null when none can be compared.'}}, 'additionalProperties': False}, 'measure': {'type': 'string', 'description': "The figure's field, as get_indicators, get_economy and get_housing name it."}, 'sampled': {'type': 'boolean', 'description': 'True when the figure is a census figure in a commune of 2,000 households or more, where the long questionnaire went to a sample. False for an economy or housing figure, and for a smaller commune.'}, 'breakdown': {'anyOf': [{}, {'type': 'null'}], 'description': 'The parts the figure is made of, where the dataset has them.'}, 'direction': {'enum': ['high', 'low'], 'type': 'string'}, 'reference': {'type': 'number', 'description': "What it stands out from: the communes' mean, its province's figure, or 0 for a change."}}, 'additionalProperties': False}}}, 'additionalProperties': False}
get_unit
A région, province or cercle
One région, province, préfecture or cercle: its name in French and Arabic, its 2024 population and households, the units above it, how many units it holds, and the ones directly under it, named: a région's provinces, a province's cercles. This is the tool for a question about a unit above the commune, such as how many cercles a province has. For a commune or an arrondissement, call get_commune; to list a unit's communes, call list_communes with that unit.
Nur Lesen Idempotent
Eingabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'required': ['unit'], 'properties': {'unit': {'type': 'string', 'minLength': 1, 'description': 'A région, province, préfecture or cercle, by code or slug.'}, 'level': {'enum': ['region', 'province', 'cercle'], 'type': 'string', 'description': 'The level, where a name is shared: Tiznit is a commune and a province, and a name alone means the commune.'}}}
Ausgabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'required': ['unit', 'counts', 'children'], 'properties': {'unit': {'type': 'object', 'required': ['code', 'level', 'name_fr', 'name_ar', 'population_2024', 'households_2024', 'region', 'province'], 'properties': {'code': {'type': 'string'}, 'level': {'type': 'string'}, 'region': {'anyOf': [{'type': 'object', 'required': ['code', 'name'], 'properties': {'code': {'type': 'string'}, 'name': {'type': 'string'}}, 'additionalProperties': False}, {'type': 'null'}]}, 'name_ar': {'type': 'string'}, 'name_fr': {'type': 'string'}, 'province': {'anyOf': [{'type': 'object', 'required': ['code', 'name'], 'properties': {'code': {'type': 'string'}, 'name': {'type': 'string'}}, 'additionalProperties': False}, {'type': 'null'}]}, 'households_2024': {'type': ['number', 'null']}, 'population_2024': {'type': ['number', 'null']}}, 'additionalProperties': False}, 'counts': {'type': 'object', 'description': 'How many units of each level this one holds.', 'propertyNames': {'type': 'string'}, 'additionalProperties': {'type': 'number'}}, 'children': {'type': 'array', 'items': {'type': 'object', 'required': ['code', 'name_fr', 'level', 'population_2024'], 'properties': {'code': {'type': 'string'}, 'level': {'type': 'string'}, 'name_fr': {'type': 'string'}, 'population_2024': {'type': ['number', 'null']}}, 'additionalProperties': False}, 'description': 'The units directly under it. Empty for a cercle, whose communes come from list_communes.'}}, 'additionalProperties': False}
list_communes
List communes
Which commune has the most or the least of something is one call here: sort by that figure, and every commune in the filter comes back in order with its value, with no need to look them up one by one. Communes filtered by région, province or préfecture, cercle, type or population, 50 to a page, in code order or sorted by name, population, change since 2014, density, area, any census indicator or any establishment count. Filters combine; each unit can be given by code or slug. With no filter it lists every commune, so sort: "-population" alone gives the largest in the country.
Nur Lesen Idempotent
Eingabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'properties': {'page': {'type': 'integer', 'maximum': 10000, 'minimum': 1, 'description': 'Page number, from 1.'}, 'sort': {'type': 'string', 'description': 'A field to order by: code, name, population, change, density, area, or a census indicator by its path, such as labour.unemploymentRate or amenities.runningWater, as get_indicators names them. Put 2014. before the path for the 2014 figure, or change. for how far it moved since, as in change.illiteracy.rate10Plus. An establishment count goes under economy., as in economy.establishments.jobs or economy.sector.commerce, as get_economy names them. A count on its own ranks the biggest places first, so 3 figures worked out from 2 counts rank by size of place rather than size: economy.per1000.establishments, economy.per1000.jobs and economy.perBusiness.jobs. A leading minus puts the largest first. Code order when left out.'}, 'type': {'enum': ['urban', 'rural'], 'type': 'string', 'description': 'Urban or rural communes only.'}, 'cercle': {'type': 'string', 'description': 'A cercle, by code or slug.'}, 'region': {'type': 'string', 'description': 'A région, by code or slug.'}, 'province': {'type': 'string', 'description': 'A province or préfecture, by code or slug.'}, 'max_population': {'type': 'integer', 'maximum': 10000000, 'minimum': 0, 'description': 'Only communes with at most this many people in 2024.'}, 'min_population': {'type': 'integer', 'maximum': 10000000, 'minimum': 0, 'description': 'Only communes with at least this many people in 2024.'}}}
Ausgabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'required': ['communes', 'page', 'total_pages', 'total'], 'properties': {'page': {'type': 'number'}, 'total': {'type': 'number'}, 'communes': {'type': 'array', 'items': {'type': 'object', 'required': ['code', 'slug', 'name_fr', 'name_ar', 'type', 'region', 'province', 'cercle', 'population_2024', 'population_2014', 'change_pct', 'area_km2', 'density', 'centroid'], 'properties': {'code': {'type': 'string'}, 'slug': {'type': 'string'}, 'type': {'enum': ['urban', 'rural'], 'type': 'string'}, 'cercle': {'anyOf': [{'type': 'object', 'required': ['code', 'name'], 'properties': {'code': {'type': 'string'}, 'name': {'type': 'string'}}, 'additionalProperties': False}, {'type': 'null'}]}, 'region': {'type': 'object', 'required': ['code', 'name'], 'properties': {'code': {'type': 'string'}, 'name': {'type': 'string'}}, 'additionalProperties': False}, 'density': {'type': ['number', 'null']}, 'name_ar': {'type': 'string'}, 'name_fr': {'type': 'string'}, 'area_km2': {'type': ['number', 'null']}, 'centroid': {'anyOf': [{'type': 'object', 'required': ['lat', 'lng'], 'properties': {'lat': {'type': 'number'}, 'lng': {'type': 'number'}}, 'additionalProperties': False}, {'type': 'null'}]}, 'province': {'type': 'object', 'required': ['code', 'name'], 'properties': {'code': {'type': 'string'}, 'name': {'type': 'string'}}, 'additionalProperties': False}, 'indicator': {'type': 'object', 'required': ['path', 'value'], 'properties': {'path': {'type': 'string'}, 'basis': {'type': 'string', 'const': 'arrondissement_sum', 'description': "The value is the sum of this city's arrondissements, which is how the census counts it."}, 'value': {'type': ['number', 'null']}, 'derived': {'type': 'string', 'description': "The division this figure came from, when it isn't a published one."}}, 'description': "When sorted by a figure, the commune's value for it.", 'additionalProperties': False}, 'change_pct': {'type': ['number', 'null']}, 'population_2014': {'type': ['number', 'null']}, 'population_2024': {'type': ['number', 'null']}}, 'additionalProperties': False}}, 'total_pages': {'type': 'number'}}, 'additionalProperties': False}
search
Search Moroccan administrative units
Find régions, provinces and préfectures, cercles, communes and arrondissements of Morocco by name. Takes French or Arabic, a slug, or another name a place is known by: Fez finds Fès, Mogador finds Essaouira. Returns codes; pass a commune's code to get_commune for its population and parents.
Nur Lesen Idempotent
Eingabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'required': ['query'], 'properties': {'limit': {'type': 'integer', 'maximum': 50, 'minimum': 1, 'description': 'How many results. 10 when left out, at most 50.'}, 'query': {'type': 'string', 'maxLength': 100, 'minLength': 1, 'description': "The name to look for, in French, Arabic or as a slug, or a unit's code."}, 'levels': {'type': 'array', 'items': {'enum': ['commune', 'arrondissement', 'province', 'region', 'cercle'], 'type': 'string'}, 'description': 'Only these levels. Every level when left out.'}}}
Ausgabeschema
{'type': 'object', '$schema': 'http://json-schema.org/draft-07/schema#', 'required': ['results'], 'properties': {'results': {'type': 'array', 'items': {'type': 'object', 'required': ['code', 'level', 'name_fr', 'name_ar', 'slug', 'matched'], 'properties': {'code': {'type': 'string'}, 'slug': {'type': 'string'}, 'level': {'enum': ['commune', 'arrondissement', 'province', 'region', 'cercle'], 'type': 'string'}, 'matched': {'enum': ['code', 'exact', 'alias', 'prefix', 'spelling', 'trigram'], 'type': 'string'}, 'name_ar': {'type': 'string'}, 'name_fr': {'type': 'string'}}, 'additionalProperties': False}}}, 'additionalProperties': False}
Hinzugefügt
get_insights
1. October 2026 02:42
Geändert
get_housing
29. September 2026 02:50
Geändert
get_indicators
29. September 2026 02:50
Geändert
list_communes
29. September 2026 02:50
Hinzugefügt
get_housing
23. September 2026 02:40
Hinzugefügt
get_economy
23. September 2026 02:40
Hinzugefügt
get_indicators
23. September 2026 02:40
Hinzugefügt
get_unit
23. September 2026 02:40
Hinzugefügt
list_communes
23. September 2026 02:40
Hinzugefügt
commune_at
23. September 2026 02:40
Hinzugefügt
communes_near
23. September 2026 02:40
Hinzugefügt
get_commune
23. September 2026 02:40
Hinzugefügt
search
23. September 2026 02:40