Morocco communes

Morocco's régions, provinces and communes: HCP codes, names, census population and boundaries

Should I use this

Quality & Safety

A
Description quality
82%
Schema completeness
96%
Naming quality
96%
Poisoning risk
100%
Permission match
100%
Protocol compliance
100%

Findings (2)

  • LOWTool 'get_commune' description lacks action verbin get_commune
  • LOWTool 'commune_at' description lacks action verbin commune_at

Based on automated analysis of tool definitions and protocol compliance.

Context Cost

~6,005Tokens (tool definitions)
~5.8 KBTypical response size
Significant attention impact (4.69% of 128k context)

This is the approximate number of tokens consumed each time the server's tools are loaded into a model's context. Higher counts reduce the attention available for other tasks.

Install

One-Click Install

Add this to your `claude_desktop_config.json` file:

{
  "mcpServers": {
    "morocco-communes": {
      "url": "https://communes.pages.dev/mcp"
    }
  }
}

Remote endpoints

https://communes.pages.dev/mcpstreamable-http

What it can do

Tool inventory

Tools (9)

🟢 Read-only🟡 Write🔴 Delete⚪ Unknown
🟢search(query, levels, limit)

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.

Input Schema

{
  "type": "object",
  "properties": {
    "query": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100,
      "description": "The name to look for, in French, Arabic or as a slug, or a unit's code."
    },
    "levels": {
      "description": "Only these levels. Every level when left out.",
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "commune",
          "arrondissement",
          "province",
          "region",
          "cercle"
        ]
      }
    },
    "limit": {
      "description": "How many results. 10 when left out, at most 50.",
      "type": "integer",
      "minimum": 1,
      "maximum": 50
    }
  },
  "required": [
    "query"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#"
}

Output Schema

{
  "type": "object",
  "properties": {
    "results": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "level": {
            "type": "string",
            "enum": [
              "commune",
              "arrondissement",
              "province",
              "region",
              "cercle"
            ]
          },
          "name_fr": {
            "type": "string"
          },
          "name_ar": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "matched": {
            "type": "string",
            "enum": [
              "code",
              "exact",
              "alias",
              "prefix",
              "spelling",
              "trigram"
            ]
          }
        },
        "required": [
          "code",
          "level",
          "name_fr",
          "name_ar",
          "slug",
          "matched"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "results"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": false
}
🟢get_commune(id)

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).

Input Schema

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "minLength": 1,
      "description": "An HCP code, the code as digits, or a slug."
    }
  },
  "required": [
    "id"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#"
}

Output Schema

{
  "type": "object",
  "properties": {
    "commune": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "slug": {
          "type": "string"
        },
        "name_fr": {
          "type": "string"
        },
        "name_ar": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "urban",
            "rural"
          ]
        },
        "region": {
          "type": "object",
          "properties": {
            "code": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "required": [
            "code",
            "name"
          ],
          "additionalProperties": false
        },
        "province": {
          "type": "object",
          "properties": {
            "code": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "required": [
            "code",
            "name"
          ],
          "additionalProperties": false
        },
        "cercle": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "code",
                "name"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "population_2024": {
          "type": [
            "number",
            "null"
          ]
        },
        "population_2014": {
          "type": [
            "number",
            "null"
          ]
        },
        "change_pct": {
          "type": [
            "number",
            "null"
          ]
        },
        "area_km2": {
          "type": [
            "number",
            "null"
          ]
        },
        "density": {
          "type": [
            "number",
            "null"
          ]
        },
        "centroid": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "lat": {
                  "type": "number"
                },
                "lng": {
                  "type": "number"
                }
              },
              "required": [
                "lat",
                "lng"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "code",
        "slug",
        "name_fr",
        "name_ar",
        "type",
        "region",
        "province",
        "cercle",
        "population_2024",
        "population_2014",
        "change_pct",
        "area_km2",
        "density",
        "centroid"
      ],
      "additionalProperties": false
    },
    "arrondissements": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "name_fr": {
            "type": "string"
          },
          "name_ar": {
            "type": "string"
          },
          "population_2024": {
            "type": [
              "number",
              "null"
            ]
          }
        },
        "required": [
          "code",
          "name_fr",
          "name_ar",
          "population_2024"
        ],
        "additionalProperties": false
      },
      "description": "Casablanca, Rabat, Fès, Marrakech, Salé and Tanger's arrondissements, most populous first; empty elsewhere."
    },
    "neighbours": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "name_fr": {
            "type": "string"
          },
          "km": {
            "type": "number"
          }
        },
        "required": [
          "code",
          "name_fr",
          "km"
        ],
        "additionalProperties": false
      },
      "description": "The communes this one borders, longest shared boundary first. Measured on the OpenStreetMap boundaries, so it is under ODbL."
    }
  },
  "required": [
    "commune",
    "arrondissements",
    "neighbours"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": false
}
🟢communes_near(lat, lng, radius_km, limit)

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.

Input Schema

{
  "type": "object",
  "properties": {
    "lat": {
      "type": "number",
      "minimum": -90,
      "maximum": 90,
      "description": "Latitude, in degrees."
    },
    "lng": {
      "type": "number",
      "minimum": -180,
      "maximum": 180,
      "description": "Longitude, in degrees."
    },
    "radius_km": {
      "description": "Radius in km. 10 when left out, at most 100.",
      "type": "number",
      "exclusiveMinimum": 0,
      "maximum": 100
    },
    "limit": {
      "description": "How many results. 10 when left out, at most 50.",
      "type": "integer",
      "minimum": 1,
      "maximum": 50
    }
  },
  "required": [
    "lat",
    "lng"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#"
}

Output Schema

{
  "type": "object",
  "properties": {
    "results": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "name_fr": {
            "type": "string"
          },
          "name_ar": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "distance_km": {
            "type": "number"
          }
        },
        "required": [
          "code",
          "name_fr",
          "name_ar",
          "slug",
          "distance_km"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "results"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": false
}
🟢commune_at(lat, lng)

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.

Input Schema

{
  "type": "object",
  "properties": {
    "lat": {
      "type": "number",
      "minimum": -90,
      "maximum": 90,
      "description": "Latitude, in degrees."
    },
    "lng": {
      "type": "number",
      "minimum": -180,
      "maximum": 180,
      "description": "Longitude, in degrees."
    }
  },
  "required": [
    "lat",
    "lng"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#"
}

Output Schema

{
  "type": "object",
  "properties": {
    "commune": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "slug": {
          "type": "string"
        },
        "name_fr": {
          "type": "string"
        },
        "name_ar": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "urban",
            "rural"
          ]
        },
        "region": {
          "type": "object",
          "properties": {
            "code": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "required": [
            "code",
            "name"
          ],
          "additionalProperties": false
        },
        "province": {
          "type": "object",
          "properties": {
            "code": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "required": [
            "code",
            "name"
          ],
          "additionalProperties": false
        },
        "cercle": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "code",
                "name"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "population_2024": {
          "type": [
            "number",
            "null"
          ]
        },
        "population_2014": {
          "type": [
            "number",
            "null"
          ]
        },
        "change_pct": {
          "type": [
            "number",
            "null"
          ]
        },
        "area_km2": {
          "type": [
            "number",
            "null"
          ]
        },
        "density": {
          "type": [
            "number",
            "null"
          ]
        },
        "centroid": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "lat": {
                  "type": "number"
                },
                "lng": {
                  "type": "number"
                }
              },
              "required": [
                "lat",
                "lng"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "code",
        "slug",
        "name_fr",
        "name_ar",
        "type",
        "region",
        "province",
        "cercle",
        "population_2024",
        "population_2014",
        "change_pct",
        "area_km2",
        "density",
        "centroid"
      ],
      "additionalProperties": false
    },
    "arrondissement": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "code": {
              "type": "string"
            },
            "name_fr": {
              "type": "string"
            },
            "name_ar": {
              "type": "string"
            }
          },
          "required": [
            "code",
            "name_fr",
            "name_ar"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "commune",
    "arrondissement"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": false
}
🟢list_communes(region, province, cercle, type, sort, ...)

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.

Input Schema

{
  "type": "object",
  "properties": {
    "region": {
      "description": "A région, by code or slug.",
      "type": "string"
    },
    "province": {
      "description": "A province or préfecture, by code or slug.",
      "type": "string"
    },
    "cercle": {
      "description": "A cercle, by code or slug.",
      "type": "string"
    },
    "type": {
      "description": "Urban or rural communes only.",
      "type": "string",
      "enum": [
        "urban",
        "rural"
      ]
    },
    "sort": {
      "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": "string"
    },
    "min_population": {
      "description": "Only communes with at least this many people in 2024.",
      "type": "integer",
      "minimum": 0,
      "maximum": 10000000
    },
    "max_population": {
      "description": "Only communes with at most this many people in 2024.",
      "type": "integer",
      "minimum": 0,
      "maximum": 10000000
    },
    "page": {
      "description": "Page number, from 1.",
      "type": "integer",
      "minimum": 1,
      "maximum": 10000
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#"
}

Output Schema

{
  "type": "object",
  "properties": {
    "communes": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "name_fr": {
            "type": "string"
          },
          "name_ar": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "urban",
              "rural"
            ]
          },
          "region": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "name"
            ],
            "additionalProperties": false
          },
          "province": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "name"
            ],
            "additionalProperties": false
          },
          "cercle": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "code",
                  "name"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "population_2024": {
            "type": [
              "number",
              "null"
            ]
          },
          "population_2014": {
            "type": [
              "number",
              "null"
            ]
          },
          "change_pct": {
            "type": [
              "number",
              "null"
            ]
          },
          "area_km2": {
            "type": [
              "number",
              "null"
            ]
          },
          "density": {
            "type": [
              "number",
              "null"
            ]
          },
          "centroid": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "lat": {
                    "type": "number"
                  },
                  "lng": {
                    "type": "number"
                  }
                },
                "required": [
                  "lat",
                  "lng"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "indicator": {
            "description": "When sorted by a figure, the commune's value for it.",
            "type": "object",
            "properties": {
              "path": {
                "type": "string"
              },
              "value": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "derived": {
                "description": "The division this figure came from, when it isn't a published one.",
                "type": "string"
              },
              "basis": {
                "description": "The value is the sum of this city's arrondissements, which is how the census counts it.",
                "type": "string",
                "const": "arrondissement_sum"
              }
            },
            "required": [
              "path",
              "value"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "code",
          "slug",
          "name_fr",
          "name_ar",
          "type",
          "region",
          "province",
          "cercle",
          "population_2024",
          "population_2014",
          "change_pct",
          "area_km2",
          "density",
          "centroid"
        ],
        "additionalProperties": false
      }
    },
    "page": {
      "type": "number"
    },
    "total_pages": {
      "type": "number"
    },
    "total": {
      "type": "number"
    }
  },
  "required": [
    "communes",
    "page",
    "total_pages",
    "total"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": false
}
🟢get_unit(unit, level)

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.

Input Schema

{
  "type": "object",
  "properties": {
    "unit": {
      "type": "string",
      "minLength": 1,
      "description": "A région, province, préfecture or cercle, by code or slug."
    },
    "level": {
      "description": "The level, where a name is shared: Tiznit is a commune and a province, and a name alone means the commune.",
      "type": "string",
      "enum": [
        "region",
        "province",
        "cercle"
      ]
    }
  },
  "required": [
    "unit"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#"
}

Output Schema

{
  "type": "object",
  "properties": {
    "unit": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "level": {
          "type": "string"
        },
        "name_fr": {
          "type": "string"
        },
        "name_ar": {
          "type": "string"
        },
        "population_2024": {
          "type": [
            "number",
            "null"
          ]
        },
        "households_2024": {
          "type": [
            "number",
            "null"
          ]
        },
        "region": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "code",
                "name"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "province": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "code",
                "name"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "code",
        "level",
        "name_fr",
        "name_ar",
        "population_2024",
        "households_2024",
        "region",
        "province"
      ],
      "additionalProperties": false
    },
    "counts": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "type": "number"
      },
      "description": "How many units of each level this one holds."
    },
    "children": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "name_fr": {
            "type": "string"
          },
          "level": {
            "type": "string"
          },
          "population_2024": {
            "type": [
              "number",
              "null"
            ]
          }
        },
        "required": [
          "code",
          "name_fr",
          "level",
          "population_2024"
        ],
        "additionalProperties": false
      },
      "description": "The units directly under it. Empty for a cercle, whose communes come from list_communes."
    }
  },
  "required": [
    "unit",
    "counts",
    "children"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": false
}
🟢get_indicators(unit, level, topics, area, sex, ...)

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. 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.

Input Schema

{
  "type": "object",
  "properties": {
    "unit": {
      "description": "A région, province or préfecture, cercle, commune or arrondissement, by code or slug. Morocco as a whole when left out.",
      "type": "string",
      "minLength": 1
    },
    "level": {
      "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.",
      "type": "string",
      "enum": [
        "commune",
        "arrondissement",
        "province",
        "region",
        "cercle"
      ]
    },
    "topics": {
      "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.",
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "population",
          "sex",
          "age",
          "maritalStatus",
          "fertility",
          "disability",
          "schooling",
          "illiteracy",
          "languagesReadAndWritten",
          "education",
          "localLanguages",
          "labour",
          "employmentStatus",
          "commute",
          "households",
          "dwellingType",
          "occupancy",
          "dwellingAge",
          "amenities",
          "wastewater",
          "householdWaste",
          "cookingFuel"
        ]
      }
    },
    "area": {
      "description": "The whole unit (total), its urban or rural part, or each of the three. total when left out.",
      "type": "string",
      "enum": [
        "total",
        "urban",
        "rural",
        "each"
      ]
    },
    "sex": {
      "description": "Everyone (all), men, women, or each of the three. all when left out. Household figures have no sex.",
      "type": "string",
      "enum": [
        "all",
        "male",
        "female",
        "each"
      ]
    },
    "census": {
      "description": "Which census. 2024 when left out. both gives the two together, to see what changed.",
      "type": "string",
      "enum": [
        "2014",
        "2024",
        "both"
      ]
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#"
}

Output Schema

{
  "type": "object",
  "properties": {
    "results": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "unit": {
            "type": "object",
            "properties": {
              "code": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "level": {
                "type": "string"
              },
              "name_fr": {
                "type": "string"
              },
              "name_ar": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "code",
              "level",
              "name_fr",
              "name_ar"
            ],
            "additionalProperties": false
          },
          "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."
          },
          "figures": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "anyOf": [
                {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                {
                  "type": "null"
                }
              ]
            },
            "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."
          }
        },
        "required": [
          "unit",
          "from_local_administration",
          "figures"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "results"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": false
}
🟢get_economy(unit, level, topics)

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.

Input Schema

{
  "type": "object",
  "properties": {
    "unit": {
      "description": "A région, province or préfecture, cercle, commune or arrondissement, by code or slug. Morocco as a whole when left out.",
      "type": "string",
      "minLength": 1
    },
    "level": {
      "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.",
      "type": "string",
      "enum": [
        "commune",
        "arrondissement",
        "province",
        "region",
        "cercle"
      ]
    },
    "topics": {
      "description": "Only these topics. Every topic when left out.",
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "establishments",
          "sector",
          "size",
          "founded"
        ]
      }
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#"
}

Output Schema

{
  "type": "object",
  "properties": {
    "results": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "unit": {
            "type": "object",
            "properties": {
              "code": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "level": {
                "type": "string"
              },
              "name_fr": {
                "type": "string"
              },
              "name_ar": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "code",
              "level",
              "name_fr",
              "name_ar"
            ],
            "additionalProperties": false
          },
          "figures": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "description": "By topic, then by key. Counts of establishments, of permanent jobs, or of weekly souks."
          },
          "basis": {
            "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.",
            "type": "string",
            "const": "arrondissement_sum"
          }
        },
        "required": [
          "unit",
          "figures"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "results"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": false
}
🟢get_housing(unit, level, topics)

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.

Input Schema

{
  "type": "object",
  "properties": {
    "unit": {
      "description": "A unit by code or slug. Morocco as a whole when left out.",
      "type": "string",
      "minLength": 1
    },
    "level": {
      "description": "With a unit, the level it's at. Without one, region, province or arrondissement gives every one of that level.",
      "type": "string",
      "enum": [
        "commune",
        "arrondissement",
        "province",
        "region",
        "cercle"
      ]
    },
    "topics": {
      "description": "Only these topics. Every topic when left out.",
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "dwellings",
          "occupancy",
          "type",
          "age",
          "ageByType",
          "walls",
          "roofs",
          "networks"
        ]
      }
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#"
}

Output Schema

{
  "type": "object",
  "properties": {
    "results": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "unit": {
            "type": "object",
            "properties": {
              "code": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "level": {
                "type": "string"
              },
              "name_fr": {
                "type": "string"
              },
              "name_ar": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "code",
              "level",
              "name_fr",
              "name_ar"
            ],
            "additionalProperties": false
          },
          "figures": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "description": "By topic, then by key."
          }
        },
        "required": [
          "unit",
          "figures"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "results"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": false
}

Community

Rate this Server

Evidence

Recent observations

verifiedversion not recorded9 tools