Salta el contingut

Catalog API

Catalog API Documentation

Tables

The catalog is built from various tables. The catalog categories are defined in the table giscube_category, and the contents with data tables (e.g., layerserver_geojsonlayer, qgisserver_project, etc.) are related to the categories through a Foreign Key.

API URL

Endpoint geoportal/category/catalog/
Example https://xxxxxxx.xxxxxxx.xxx/apps/giscube-admin/geoportal/category/catalog/

The Endpoint returns a list with all the categories. Each category has an id, a name, a color (which can be null), and a parent (which can be null). If the category has a parent, it means it is a subcategory of that parent. For example, in the following table, ‘Serveis i equipaments’ is the parent category, and ‘Administració pública’ is a subcategory of it. In the catalog, ‘Administració pública’ is inside ‘Serveis i equipaments’.

id name color parent
39 Serveis i equipaments #1D6996 null
40 Administració pública null 39

We can relate new categories with subcategories, creating “subsubcategories.” This allows us to create a tree with “infinite” children.

If any category has data linked from another table (e.g., layerserver_geojsonlayer), it will be reflected with the content property. content is an array containing the data from each linked table. In the following example, there is a category “Serveis i equipaments,” another category “Administració Pública” that has the former as its parent category. On the other hand, the record “Administració autonòmica” from the layerserver_geojsonlayer table is linked to the “Administració Pública” category and appears in the content property.

{
    "id": 39,
    "name": "Serveis i equipaments",
    "color": "#1D6996",
    "parent": null
},
{
    "id": 40,
    "name": "Administració Pública",
    "color": null,
    "parent": 39,
    "content": [
        {
            "group": true,
            "title": "Administració Autonòmica",
            "legend": "",
            "catalog": ["Serveis i equipaments","Administració Pública"],
            "options": {},
            "private": false,
            "children": [
                {
                    "url": "https://xxxxxxx.xxxxxxx.xxx/apps/giscube-admin/layerserver/geojsonlayers/administracio-autonomica-publica",
                    "type": "GeoJSON",
                    "group": false,
                    "title": "Capa GeoJSON",
                    "projection": "4326"
                }
            ],
            "keywords": "Administració Autonòmica, generalitat, jutjats, treball",
            "metadata": {...},
            "giscube_id": "20.174",
            "category_id": 40,
            "description": "",
            "has_children": true
        },
        {...}
    ]
},
{...}

Authentication

Authentication is required to access this API. In other words, a token must be sent to the server.

This can be done in two ways:

  • access_token parameter in a GET request
Parameter access_token
Example https://xxxxxxx.xxxxxxx.xxx/apps/giscube-admin/geoportal/category/catalog/?access_token=JIFbeOLxkW87wvu3a5at9164IGv7w7
  • HTTP Header
Parameter Authorization
Example Authorization=Bearer JIFbeOLxkW87wvu3a5at9164IGv7w7

The catalog API is public, but there are records in the tables linked to the categories that are not public. If not authenticated, we will get all the categories, and the values of the public tables will appear in the content property as seen before. If a table is private, the category will still appear, but not its content. If we are authenticated, we will get all the results.

For example, if the record “Administració autonòmica” is private, we will get the following:

Not authenticated:

{
    "id": 39,
    "name": "Serveis i equipaments",
    "color": "#1D6996",
    "parent": null
},
{
    "id": 40,
    "name": "Administració Pública",
    "color": null,
    "parent": 39
},
{...}

Authenticated:

{
    "id": 39,
    "name": "Serveis i equipaments",
    "color": "#1D6996",
    "parent": null
},
{
    "id": 40,
    "name": "Administració Pública",
    "color": null,
    "parent": 39
    "content": [
        {
            "group": true,
            "title": "Administració Autonòmica",
            "legend": "",
            "catalog": ["Serveis i equipaments","Administració Pública"],
            "options": {},
            "private": false,
            "children": [{...}],
            "keywords": "Administració Autonòmica, generalitat, jutjats, treball",
            "metadata": {...},
            "giscube_id": "20.174",
            "category_id": 40,
            "description": "",
            "has_children": true
        },
        {...}
    ]
},
{...}

API Parameters

The catalog API is essentially an API for the categories from which the catalog is built. We can obtain all the categories without the content from the endpoint geoportal/category/.

Endpoint geoportal/category/
Example https://xxxxxxx.xxxxxxx.xxx/apps/giscube-admin/geoportal/category/

We can also obtain categories with the content by performing a search with the id of the category through another endpoint.

Search by id
Endpoint geoportal/catalog/
Parameter category_id
Description Search by matching the id field
Example https://xxxxxxx.xxxxxxx.xxx/apps/giscube-admin/geoportal/catalog/?category_id=40