In order to have the data from the local data repository, you can do it in two ways: by downloading it directly (go to the resource) or by integrating against the repository.
In order to obtain the data of a particular dataset from the open data repository, integrating against the repository, the following steps must be followed:
Step 1: Get the name of the .csv document associated with the dataset on which we want to get the data:
Click the link "Available in open data" (in the image we see the name of the file highlighted in yellow)
Step 2: Obtain the identifier (resource_id) of the dataset: through a call to the package_show method, to which you will pass as a parameter the name of the .csv document where the data is, which you have just obtained in the previous step.
An example of a call: http://dadesobertes.seu-e.cat/api/action/package_show?id=iio-ii-dades-generals-ens
And here is the result you get (highlighting in yellow the name of the resource we will need to make the next call):
{“help”: “ http://dadesobertes.seu-e.cat/api/3/action/help_show?name=package_show “, “success”: true, “result”: {“license_title”: “License not specified”, “maintainer”: “”, “relationships_as_object”: [], “private”: false, “maintainer_email”: “”, “num_tags”: 0, “id”: “e6d3ad49-e651-4e14-9a12-6b9a8f29ac61”, “metadata_created”: “2015-10-22T16:19:54.362868”, “metadata_modified”: “2016-12-20T07:29:33.707001”, “author”: “”, “author_email”: “”, “state”: “active”, “version”: “”, “creator_user_id”: “0bcf446a-cdb5-454f-832d-bdbfa330e6bb”, “type”: “dataset”, “resources”: [{“cache_last_updated”: null, “package_id”: “e6d3ad49-e651-4e14-9a12-6b9a8f29ac61”, “webstore_last_updated”: null, “data_actualitzacio”: “2016-12-20T07:29:33.654Z”, “datastore_active”: true, “id”: “ab53cbf3-a439-4f59-a2f5-658bee1994e5”, “size”: null, “filtre_ens”: “”, “state”: “active”, “hash”: “”, “description”: “”, “format”: “CSV”, “tracking_summary”: {“total”: 0, “recent”: 0}, “last_modified”: null, “url_type”: null, “mimetype”: null, “cache_url”: null, “name”: “Dades generals de l'ens”, “created”: “2015-10-22T18:20:18.279968”, “url”: “ http://dadesobertes.seu-e.cat/csv/iio-ii-dades-generals-ens.csv “, “webstore_url”: null, “mimetype_inner”: null, “position”: 0, “revision_id”: “2dc741dc-c98d-45b7-adbd-282e7eb4a638”, “resource_type”: null}], “num_resources”: 1, “tags”: [], “tracking_summary”: {“total”: 0, “recent”: 0}, “groups”: [{“display_name”: ” Informaciu00f3 institucional i organitzativa”, “description”: “Organitzaciu00f3 polu00edtica, personal, entitats i altres organismes”, “image_display_url”: “ http://dadesobertes.seu-e.cat//uploads/group/bank “, “title”: ” Informaciu00f3 institucional i organitzativa”, “id”: “e15b2ad1-4bb5-4ff0-9ab9-6e73b809bcf8”, “name”: “1-informacio-institucional-i-organitzativa”}], “license_id”: “notspecified”, “relationships_as_subject”: [], “organization”: {“description”: “”, “created”: “2015-11-11T16:44:11.030775”, “title”: “Consorci d'Administraciu00f3 Oberta de Catalunya”, “name”: “aoc”, “is_organization”: true, “state”: “active”, “image_url”: “ http://dadesobertes.dev.seu-e.cat/header-logo.png “, “revision_id”: “c9ebb9de-cae4-4282-864f-24ead9d254f1”, “type”: “organization”, “id”: “a26ffc54-d8b9-4d4a-bcad-e5cb5f00b518”, “approval_status”: “approved”}, “name”: “iio-ii-dades-generals-ens”, “isopen”: false, “url”: “Departament de Governaciu00f3 (Municat)”, “notes”: “”, “owner_org”: “a26ffc54-d8b9-4d4a-bcad-e5cb5f00b518”, “extras”: [], “title”: “Dades generals de l'ens”, “revision_id”: “00b43887-1e4c-4364-b096-d382df10b549”}}
Step 3: Call the datastore_search method, passing as a parameter the identifier obtained in point 2.
Call example: http://dadesobertes.seu-e.cat/api/action/datastore_search?resource_id=ab53cbf3-a439-4f59-a2f5-658bee1994e5
In case you want to filter the data to obtain only those of an entity, you must add as a parameter the code_ine10 of the entity in question, with the format &filters={“CODE_ENS”%3A”<CODE_INE_10_ENS>”} .
So the call to obtain the data from the Manlleu City Council (INE code = 811200000) referring to the General Data dataset of the entity would be as follows:
The result you will get will be the following:
{“help”: “ http://dadesobertes.seu-e.cat/api/3/action/help_show?name=datastore_search “, “success”: true, “result”: {“resource_id”: “ab53cbf3-a439-4f59-a2f5-658bee1994e5”, “fields”: [{“type”: “int4”, “id”: “_id”}, {“type”: “text”, “id”: “ADREu00c7A”}, {“type”: “text”, “id”: “MUNICIPI”}, {“type”: “text”, “id”: “TELu00c8FON”}, {“type”: “text”, “id”: “FAX”}, {“type”: “text”, “id”: “CIF”}, {“type”: “text”, “id”: “COMARCA”}, {“type”: “numeric”, “id”: “CODCOMARCA”}, {“type”: “text”, “id”: “PROVINCIA”}, {“type”: “numeric”, “id”: “CODIPROV”}, {“type”: “text”, “id”: “CAPICOM”}, {“type”: “numeric”, “id”: “ANY_CENS”}, {“type”: “numeric”, “id”: “CENS”}, {“type”: “numeric”, “id”: “CODITIPUS”}, {“type”: “text”, “id”: “SUPERFICIE”}, {“type”: “text”, “id”: “ARTICLE”}, {“type”: “text”, “id”: “NOMTIPUS”}, {“type”: “numeric”, “id”: “CODIPOSTAL”}, {“type”: “text”, “id”: “SECRETARI”}, {“type”: “text”, “id”: “HORARI”}, {“type”: “text”, “id”: “DISSOLT”}, {“type”: “text”, “id”: “SIGLACOM”}, {“type”: “numeric”, “id”: “ALTURA”}, {“type”: “text”, “id”: “HD”}, {“type”: “text”, “id”: “NOM_CAPITAL”}, {“type”: “text”, “id”: “E_MAIL”}, {“type”: “text”, “id”: “WEB”}, {“type”: “text”, “id”: “PARTIT_JUDICIAL”}, {“type”: “text”, “id”: “PARTIT_ELECTORAL”}, {“type”: “text”, “id”: “GENTILICI”}, {“type”: “text”, “id”: “LOCALITAT_CP”}, {“type”: “text”, “id”: “DELEGACIO_GOVERN”}, {“type”: “text”, “id”: “MUNICAT”}, {“type”: “text”, “id”: “AMBIT”}, {“type”: “text”, “id”: “SITUA_GEO_MUNICIPI”}, {“type”: “text”, “id”: “SITUA_GEO_COMARCA”}, {“type”: “text”, “id”: “PLANOL_CARRERS”}, {“type”: “text”, “id”: “SALUTACIO”}, {“type”: “timestamp”, “id”: “DATA_ACTUALITZACIO”}, {“type”: “numeric”, “id”: “CODI_ENS”}, {“type”: “text”, “id”: “ORDENACIO_ALFABETICA”}, {“type”: “text”, “id”: “NOM_COMPLERT”}], “records”: [{“AMBIT”: “Comarques Centrals”, “CIF”: “P0811100G”, “SITUA_GEO_MUNICIPI”: “ http://hipermapa.ptop.gencat.cat/hipermapa/hipermapa2_cat.asp?NOM_FLASH=aea_high.swf&QUERY_LAYER=Municipis&QUERY=CODI_INE|LIKE|08112&FIT=True “, “NOMTIPUS”: “Municipis”, “SITUA_GEO_COMARCA”: “ http://hipermapa.ptop.gencat.cat/hipermapa/hipermapa2_cat.asp?NOM_FLASH=aea_high.swf&QUERY_LAYER=Comarques&QUERY=COMARCA|LIKE|24&FIT=True&FILTER=True “, “SECRETARI”: “”, “NOM_COMPLERT”: “Ajuntament de Manlleu”, “SUPERFICIE”: “17,29”, “HD”: “H”, “ADREu00c7A”: “Pl. Fra Bernadu00ed, 6”, “CENS”: “20228”, “ORDENACIO_ALFABETICA”: “Manlleu”, “CODCOMARCA”: “8102490004”, “PARTIT_JUDICIAL”: “Vic”, “CODITIPUS”: “2”, “PARTIT_ELECTORAL”: “Vic”, “COMARCA”: “Osona”, “ARTICLE”: ” “, “ANY_CENS”: “2015”, “ALTURA”: “461”, “CODIPOSTAL”: “8560”, “WEB”: “ http://www.manlleu.cat “, “CODI_ENS”: “811200000”, “PROVINCIA”: “Barcelona”, “E_MAIL”: “ ajuntament@manlleu.cat “, “FAX”: “93-8507970”, “MUNICAT”: “ http://aplicacions.municat.gencat.cat/index.php?page=consulta&mostraEns=0811200000 “, “DISSOLT”: “N”, “CAPICOM”: “N”, “NOM_CAPITAL”: “Manlleu”, “PLANOL_CARRERS”: “http://mercuri.icc.cat/website/mob_nf/mob1/mob2/inici2.htm?&mun=081120“, “TELu00c8FON”: “93-8506666”, “MUNICIPI”: “Manlleu”, “DELEGACIO_GOVERN”: “Catalunya Central”, “SALUTACIO”: “Benvolgut alcalde”, “GENTILICI”: “manlleuencs”, “DATA_ACTUALITZACIO”: “2016-12-15T00:00:00”, “LOCALITAT_CP”: “Manlleu”, “CODIPROV”: “8000840003”, “_id”: 444, “SIGLACOM”: “OS”, “HORARI”: “De dilluns a divendres de 8.30ha 14 h.”}], “_links”: {“start”: “/api/action/datastore_search?filters=%7B%22CODI_ENS%22%3A%22811200000%22%7D&resource_id=ab53cbf3-a439-4f59-a2f5-658bee1994e5”, “next”: “/api/action/datastore_search?offset=100&filters=%7B%22CODI_ENS%22%3A%22811200000%22%7D&resource_id=ab53cbf3-a439-4f59-a2f5-658bee1994e5”}, “filters”: {“CODI_ENS”: “811200000”}, “total”: 1}}
Note: usually the filter for us is done by the CODI_ENS field, but there are datasets such as for example "of dependent organisms" in which there are two fields: CODI_ENS_PARE and CODI_ENS_FILL.
The correct API call for this case would be:
To know the field that should be used to filter for us in a specific dataset, you need to make a previous call to another method of the API:
http://dadesobertes.seu-e.cat /api/action/package_show?id=iio-ii-organismes-dependents
In the "ens_filter" property, the field that must be used to filter by ens is indicated, CODI_ENS_PARE in this case, if the property is not indicated, it is necessary to filter by the CODI_ENS field.