Citizens' Engagement Platform API documentation

Explore the API interactively with GraphiQL

About the GraphQL API

Decidim comes with an API that follows the GraphQL specification. It has a comprehensive coverage of all the public content that can be found on the website.

Currently, it is read-only (except for posting comments) but intends to cover anything that is published on the regular website.

Typically (although some particular installations may change that) you will find 3 relevant folders:

Using the GraphQL API

The GraphQL format is a JSON formatted text that is specified in a query. Response is a JSON object as well. For details about specification check the official GraphQL site.

For additional examples of queries and mutations, check the additional GraphQL API documentation of Decidim.

Exercise caution when utilizing the output of this API, as it may include HTML that has not been escaped. Take particular care in handling this data, specially if you intend to render it on a webpage.

For instance, you can check the version of a Decidim installation by using curl in the terminal:

curl -sSH "Content-Type: application/json" \
-d '{"query": "{ decidim { version } }"}' \
https://www.decidim.barcelona/api/

Note that Content-Type needs to be specified.

The query can also be used in GraphiQL, in that case you can skip the "query" text:

{
  decidim {
    version
  }
}

Response (formatted) should look something like this:

{
  "data": {
    "decidim": {
      "version": "0.18.1"
    }
  }
}

For additional examples of queries and mutations, check the additional GraphQL API documentation of Decidim.