In order to have the data in the local data repository, you can do it in two ways: by downloading it directly (go to the resource) or by integrating it against the repository.
In order to obtain the data of a specific dataset from the open data repository, integrating against the repository, you must follow the steps below:
Step 1: Get the name of the .csv document associated with the dataset about which we want to get the data:
Click on the link "Available in open data" (in the image we see highlighted in yellow the file name)
Step 2: Obtain the identifier (resource_id) of the dataset: by calling the package_show method, to which you will pass as a parameter the name of the .csv document where the data is, which you 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 following 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,“ update_date ”:“ 2016-12-20T07: 29: 33.654Z ”,“ datastore_active ”: true,“ id ”:“ ab53cbf3- a439-4f59-a2f5-658bee1994e5 ”,“ size ”: null,“ filter_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 ”:“ General body data ”,“ created ”:“ 2015-10-22T18: 20: 18.279968 ”,“ url ”: http: // opendata. 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”: “Institutional and organizational information”, “description”: “Political organization, staff, entities and other bodies”, “image_display_url”: “ http://dadesobertes.seu-e.cat//uploads/group/bank “,“ Title ”:“ Institutional and organizational information ”,“ id ”:“ e15b2ad1-4bb5-4ff0-9ab9-6e73b809bcf8 ”,“ name ”:“ 1-institutional-and-organizational-information ”}],“ license_id ” : “Notspecified”, “relationships_as_subject”: [], “organization”: {“description”: “”, “created”: “2015-11-11T16: 44: 11.030775”, “title”: “Administration Consortium00f3 Open of Catalonia ”, “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-general-data-us”, “hint”: false, “url”: “Government Department00f3 (Municipal)”, “notes”: “”, “owner_org”: a26ffc54-d8b9-4d4a- bcad-e5cb5f00b518 ”,“ extras ”: [],“ title ”:“ General data of the entity ”,“ revision_id ”:“ 00b43887-1e4c-4364-b096-d382df10b549 ”}}
Step 3: Call the datastore_search method, passing the identifier obtained in point 2 as a parameter.
Example call: http://dadesobertes.seu-e.cat/api/action/datastore_search?resource_id=ab53cbf3-a439-4f59-a2f5-658bee1994e5
If you want to filter the data to get only one entity, you must add as a parameter the code_ine10 of the entity in question, with the format & filters = {“CODI_ENS”% 3A ”<CODI_INE_10_ENS>”} .
So the call to obtain the data of the City Council of Manlleu (INE code = 811200000) referring to the dataset General data of the entity would be the following:
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”: “MUNICIPALITY”}, {“type”: “text”, “id”: “TELu00c8FON”}, {“type”: “text”, “id”: “FAX ”}, {“ Type ”:“ text ”,“ id ”:“ CIF ”}, {“ type ”:“ text ”,“ id ”:“ COUNTY ”}, {“ 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 ”:“ CODITYPE ”}, {“ type ”:“ text ”,“ id ”:“ SURFACE ”}, {“ type ”:“ text ”,“ id ”:“ ARTICLE ”} , {“Type”: “text”, “id”: “NOMTIPUS”}, {“type”: “numeric”, “id”: “CODIPOSTAL”}, {“type”: “text”, “id”: “SECRETARY”}, {“type”: “text”, “id”: “SCHEDULE”}, {“type”: “text”, “id”: “DISSOLVED”}, {“type”: “text”, “Id”: “SIGLACOM”}, {“type”: “numeric” , “Id”: “HEIGHT”}, {“type”: “text”, “id”: “HD”}, {“type”: “text”, “id”: “CAPITAL_NAME”}, {“type” : “Text”, “id”: “E_MAIL”}, {“type”: “text”, “id”: “WEB”}, {“type”: “text”, “id”: “PARTY_JUDICIAL”}, {“Type”: “text”, “id”: “ELECTORAL_PARTY”}, {“type”: “text”, “id”: “GENTILICI”}, {“type”: “text”, “id”: “ LOCALITAT_CP ”}, {“ type ”:“ text ”,“ id ”:“ DELEGACIO_GOVERN ”}, {“ type ”:“ text ”,“ id ”:“ MUNICAT ”}, {“ type ”:“ text ”,“ id ”:“ SCOPE ”}, {“ 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”: [{“SCOPE”: “Central Counties”, “CIF”: “P0811100G”, “SITUA_GEO_MUNICIPI”: “ http://hipermapa.ptop.gencat.cat/hipermapa/hipermapa2_cat.asp?NOM_FLASH = aea_high.swf & QUERY_LAYER = Towns & QUERY = CODI_INE | LIKE | 08112 & F IT = 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 True & FILTER = True “,“ SECRETARIAT ”:“ ”,“ NOM_COMPLERT ”:“ Ajuntament de Manlleu ”,“ SUPERFICIE ”:“ 17,29 ”,“ HD ”:“ H ”,“ ADREu00c7A ”:“ Pl. Fra Bernadu00ed, 6 ”,“ CENSUS ”:“ 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 ”,“ HOURS ”:“ From Monday to Friday from 8.30 am to 2 pm. ”}], “_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 ”:“ 81 }, “Total”: 1}}
Note: The filter for us is usually done by the CODE_ENS field, but there are datasets such as the "dependent organism" field in which there are two fields: CODE_ENS_PARE and CODE_ENS_FILL.
The correct API call for this case would be:
To find out which field to use to filter for us in a particular dataset, you need to call another API method:
http://dadesobertes.seu-e.cat / api / action / package_show? id = iio-ii-organismes-dependents
The "filter_ens" property indicates the field to be used to filter by us, CODE_ENS_PARE in this case, if the property is not indicated it is necessary to filter by the field CODE_ENS.