Per tal de disposar de les dades del repositori de dades locals, pots fer-ho de dos maneres: descarregant-les directament (anar al recurs) o bé, integrant-se contra el repositori.

Per poder obtenir les dades d’un dataset concret del repositori de dades obertes, integrant-se contra el repositori, cal seguir els següents passos:

Pas 1: Obtenir el nom del document .csv associat al dataset sobre el que volem obtenir les dades:

Clicar l’enllaç “Disponible a dades obertes” (a la imatge veiem destacat en groc el nom del fitxer)

faq_DO_1-1.png

 

 

 

 

 

 

 

 

Pas 2: Obtenir el identificador (resource_id) del dataset: mitjançant una crida al mètode package_show, al que passaràs com a paràmetre el nom del document .csv on estan les dades, que acabes d’obtenir en el pas anterior.

Un exemple de crida: http://dadesobertes.seu-e.cat/api/action/package_show?id=iio-ii-dades-generals-ens

I aquí el resultat que obtens (destacant en groc el nom del recurs que necessitarem per fer la següent crida):

 

{“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”}}

Pas 3: Fer una crida al mètode datastore_search, passant com a paràmetre el identificador obtingut al punt 2.

Exemple de crida: http://dadesobertes.seu-e.cat/api/action/datastore_search?resource_id=ab53cbf3-a439-4f59-a2f5-658bee1994e5

En cas que vulguis filtrar les dades per obtenir només les d’un ens, has d’afegir com a paràmetre el codi_ine10 de l’ens en qüestió, amb el format &filters={“CODI_ENS”%3A”<CODI_INE_10_ENS>”}.

De manera que la crida per obtenir les dades de l’Ajuntament de Manlleu (codi INE = 811200000) referents al dataset Dades general de l’ens seria la següent:

http://dadesobertes.seu-e.cat/api/action/datastore_search?resource_id=ab53cbf3-a439-4f59-a2f5-658bee1994e5&filters={%22CODI_ENS%22%3A%22811200000%22}

El resultat que obtindràs serà el següent:

{“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.30h a 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}}

 

 

Nota: habitualment el filtre per ens es fa pel camp CODI_ENS, però existen datasets com per exemple el “d’organismes dependents” en el que hi ha dos camps: CODI_ENS_PARE i CODI_ENS_FILL.

 

La crida correcta a l’API per aquest cas seria la següent:

http://dadesobertes.seu-e.cat/api/action/datastore_search?resource_id=a5773993-4992-4ec0-84e2-95d31ad8101c&filters={%22CODI_ENS_PARE%22:%221721680001%22}

 

Per saber el camp que s’ha d’utilitzar per a filtrar per ens en un dataset concret cal fer una crida previa a un altre mètode de l’API:

http://dadesobertes.seu-e.cat/api/action/package_show?id=iio-ii-organismes-dependents

 

A la propietat “filtre_ens” ve indicat el camp que s’ha d’utilitzar per filtrar per ens, CODI_ENS_PARE en aquest cas, si la propietat no ve indicada cal filtrar pel camp CODI_ENS.