MoroccoAPIDocumentation
API reference

Choose a resource. Set the parameters. Try it.

No API keyJSON responsesOpen CORS

Get a consulate

GET/api/v2/consulates/{id}

Good to know. Directory captured on 31 October 2026: 56 consulates in 15 countries. Contacts are not verified in real time; redistribution permission has not been obtained.

Parameters

01
stringRequired · Path

MoroccoAPI identifier, taken from the list.

Pattern^[a-z]{2}-[a-z0-9]+(?:-[a-z0-9]+)*$
Read the response

data: The requested results, as an object or an array.

meta: Dataset sources, license and dates. null means unknown or unavailable.

API v2 is the canonical path. Older /api/v1 paths remain compatibility aliases for the currently published behavior, including pagination; no removal date is scheduled.

Response fields 15

[] means each item in a list. null means unknown or unavailable, never zero. The guide language does not translate source values.

dataobject

Requested result: a single object or a list.

data.idstring

Identifier of this item in the dataset; not necessarily an official code.

data.nameobject

Resource name, grouped by language where applicable.

data.name.frstring

French value; null when no translation is provided.

data.countryobject

Host country of the consulate.

data.country.codestring

Two-letter ISO host-country code.

data.country.namestring

French name of the host country.

data.citystring

City stated by the source; not necessarily an administrative code.

data.addressstring | null

Postal address as published.

data.phonesobject[]

Institutional telephone values retained from the source.

data.phones[].rawstring

Source value after removing identified mobile segments; may remain ambiguous.

data.phones[].e164string | null

Host-country international phone number; null when ambiguous or invalid. Does not prove reachability.

data.websitestring | null

Website link supplied by the source; null when absent or excluded during review.

data.source_namesstring[]

Associated source panel titles, including merged duplicates.

data.quality_flagsstring[]

Known issues: duplicate, incomplete contact, ambiguous phone or excluded link.

Data structure
{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "data",
    "meta"
  ],
  "properties": {
    "data": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "name",
        "country",
        "city",
        "address",
        "phones",
        "website",
        "source_names",
        "quality_flags"
      ],
      "properties": {
        "id": {
          "type": "string",
          "maxLength": 100,
          "pattern": "^[a-z]{2}-[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "name": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "fr"
          ],
          "properties": {
            "fr": {
              "type": "string",
              "minLength": 1
            }
          }
        },
        "country": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "code",
            "name"
          ],
          "properties": {
            "code": {
              "type": "string",
              "pattern": "^[A-Z]{2}$"
            },
            "name": {
              "type": "string",
              "minLength": 1
            }
          }
        },
        "city": {
          "type": "string",
          "minLength": 1
        },
        "address": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "string",
              "nullable": true,
              "enum": [
                null
              ]
            }
          ]
        },
        "phones": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "raw",
              "e164"
            ],
            "properties": {
              "raw": {
                "type": "string",
                "minLength": 1
              },
              "e164": {
                "anyOf": [
                  {
                    "type": "string",
                    "pattern": "^\\+[1-9][0-9]{6,14}$"
                  },
                  {
                    "type": "string",
                    "nullable": true,
                    "enum": [
                      null
                    ]
                  }
                ]
              }
            }
          }
        },
        "website": {
          "anyOf": [
            {
              "type": "string",
              "format": "uri",
              "pattern": "^https?://"
            },
            {
              "type": "string",
              "nullable": true,
              "enum": [
                null
              ]
            }
          ]
        },
        "source_names": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "quality_flags": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "meta": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "dataset",
        "total",
        "license",
        "terms_url",
        "redistribution_status",
        "retrieved_at",
        "source_updated_at",
        "transformation_version",
        "coverage",
        "sources"
      ],
      "properties": {
        "dataset": {
          "enum": [
            "moroccan-consulates"
          ]
        },
        "total": {
          "type": "integer",
          "minimum": 0
        },
        "license": {
          "type": "string",
          "nullable": true,
          "enum": [
            null
          ]
        },
        "terms_url": {
          "type": "string",
          "format": "uri"
        },
        "redistribution_status": {
          "enum": [
            "permission-not-obtained"
          ]
        },
        "retrieved_at": {
          "type": "string",
          "format": "date"
        },
        "source_updated_at": {
          "type": "string",
          "nullable": true,
          "enum": [
            null
          ]
        },
        "transformation_version": {
          "type": "string",
          "minLength": 1
        },
        "coverage": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "records",
            "countries",
            "complete",
            "real_time",
            "limitations"
          ],
          "properties": {
            "records": {
              "type": "integer",
              "minimum": 1
            },
            "countries": {
              "type": "integer",
              "minimum": 1
            },
            "complete": {
              "enum": [
                false
              ]
            },
            "real_time": {
              "enum": [
                false
              ]
            },
            "limitations": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              }
            }
          }
        },
        "sources": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "dataset",
              "producer",
              "source_url"
            ],
            "properties": {
              "dataset": {
                "type": "string",
                "minLength": 1
              },
              "producer": {
                "type": "string",
                "minLength": 1
              },
              "source_url": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}
Sources and pagination 19
metaobject

Result context: sources, dates, license and pagination where applicable.

meta.datasetstring

Name of the dataset for this result or source.

Accepted values: "moroccan-consulates"

meta.totalinteger

Number of matching records before pagination; not the size of this page.

meta.licensenull

null: no open license identified for this directory.

Accepted values: null

meta.terms_urlstring

Terms of use published by the source website.

meta.redistribution_statusstring

permission-not-obtained: no written redistribution permission obtained.

Accepted values: "permission-not-obtained"

meta.retrieved_atstring

Date the project retrieved the source file; not the observation date.

meta.source_updated_atnull

Last update reported by the source; not the retrieval date.

Accepted values: null

meta.transformation_versionstring

Version of the dataset conversion rules; separate from the API version.

meta.coverageobject

Geographic and time coverage actually available.

meta.coverage.recordsinteger

Number of consulates in the entire snapshot before filtering.

meta.coverage.countriesinteger

Number of countries represented in the entire snapshot.

meta.coverage.completeboolean

false: exhaustive coverage of the consular network is not verified.

Accepted values: false

meta.coverage.real_timeboolean

false means observations are historical, without live updates.

Accepted values: false

meta.coverage.limitationsstring[]

Known source or coverage limitations; read before using the data.

meta.sourcesobject[]

Sources used for this result, with their publishers and licenses.

meta.sources[].datasetstring

Name of the dataset for this result or source.

meta.sources[].producerstring

Organization publishing the original data.

meta.sources[].source_urlstring

Source publication or dataset landing page.

Errors
  • 400: Invalid or missing parameter.
  • 404: Resource not found.

Errors return error.code, error.message and error.request_id.

errorobject

Details of a failed request; replaces data and meta.

error.codestring

Stable error code, such as RESOURCE_NOT_FOUND; use it in application logic.

error.messagestring

Human-readable error explanation; use code for application logic.

error.request_idstring

Identifier for this request, useful when reporting a problem.

Your request

GET · JSON

Base URL

Response

The live response will appear here.

Language changes the guide, not JSON keys or source values.