Skip to content
David Leoni edited this page Nov 7, 2015 · 5 revisions

These are just some random notes about CKAN access.

Since CKAN api can be messy at times, we set up a comparison table of fields names as they appear in the API and as they are displayed in dati.trentino.it

[Datasets](CKAN API#datasets)

[Ressources](CKAN API#resources)


Datasets

package_search returns dataset information plus also resources info.

Search by tag "strati prioritari" (NOTE it searches by exact match!!:

http://dati.trentino.it/api/3/action/dataset_search?fq=tags:%22strati%20prioritari%22

Search by group gestione-del-territorio with wildcard (note wildcard CAN'T be at the beginning!):

http://dati.trentino.it/api/3/action/dataset_search?fq=groups:gestione-del*

Search groups welfare OR "gestione-del-territorio". Notice the parenthesis, without it returns everything!

http://dati.trentino.it/api/3/action/dataset_search?fq=(groups:welfare%20OR%20groups:%22gestione-del-territorio%22)

See this page for further info on Solr syntax.

Applying both 'secondo' generic text search and looking for 'Bacini' in maintainer field:

Note there are no Italian fields as they are all present in extras. Extras here have the expected key/value fields PLUS other useless fields such as such as id, package_id, revision_id...

http://dati.trentino.it/api/3/action/dataset_search?q=secondo&fq=maintainer:Bacini

{help: "bla bla...",
 success: true, 
 result: { "count" : 1,
          "facets" : {  },
          "results" : [ 
              { "author" : "Provincia Autonoma di Trento - Servizio Bacini Montani",
                "author_email" : "bacinimontani@provincia.tn.it",
                "creator_user_id" : null,
                "extras" : [ { "id" : "5530ec91-450c-46c2-a2fb-09a9505f1e85",
                      "key" : "Aggiornamento",
                      "package_id" : "2ea3731d7c0855474782fe7bd69d33a0e9e043db",
                      "revision_id" : "e89ce1ef-65d9-417c-b1a7-d3c4d71a0f49",
                      "revision_timestamp" : "2013-03-11T16:56:11.646795",
                      "state" : "active",
                      "value" : "Non programmato"
                    }, ...
                  ],
                "groups" : [ { "approval_status" : "approved",
                      "capacity" : "public",
                      "created" : "2013-11-15T12:01:17.613095",
                      "description" : "viabilità, idrografia, aree protette, toponomastica, orografia, uso del suolo, ecc.",
                      "id" : "6356f4ed-0ca5-42a7-b7e1-9de31cdee5b4",
                      "image_url" : "",
                      "is_organization" : false,
                      "name" : "gestione-del-territorio",
                      "revision_id" : "d8f1afc1-d3ca-4c8a-a38b-41b5f3eb6c44",
                      "state" : "active",
                      "title" : "Gestione del territorio",
                      "type" : "group"
                    } ],
                "id" : "2ea3731d7c0855474782fe7bd69d33a0e9e043db",
                "isopen" : true,
                "license_id" : "cc-zero",
                "license_title" : "Creative Commons CCZero",
                "license_url" : "http://creativecommons.org/publicdomain/zero/1.0/deed.it",
                "maintainer" : "Provincia Autonoma di Trento - Servizio Bacini Montani",
                "maintainer_email" : "dip.risorseforestali@provincia.tn.it",
                "metadata_created" : "2013-03-11T16:56:11.646795",
                "metadata_modified" : "2013-11-11T04:02:03.940511",
                "name" : "bacini-idrografici-di-secondo-livello",
                "notes" : "Lo strato informativo rappresenta le aree corrispondenti ai bacini idrografici di 2° livello",
                "num_resources" : 4,
                "num_tags" : 4,
                "organization" : { "approval_status" : "approved",
                    "created" : "2012-09-11T02:13:18.116711",
                    "description" : "SIAT. Entità territoriali geo-referenziate, con associate informazioni sulle relative proprietà. \r\n",
                    "id" : "b112ed55-01b7-4ca4-8385-f66d6168efcc",
                    "image_url" : "",
                    "is_organization" : true,
                    "name" : "pat-sistema-informativo-ambiente-e-territorio",
                    "revision_id" : "735769d1-add5-4bb6-9d09-95317d3c2835",
                    "revision_timestamp" : "2013-11-28T15:00:36.239474",
                    "state" : "active",
                    "title" : "PAT Sistema Informativo Ambiente e Territorio",
                    "type" : "organization"
                  },
                "owner_org" : "b112ed55-01b7-4ca4-8385-f66d6168efcc",
                "private" : false,
                "relationships_as_object" : [  ],
                "relationships_as_subject" : [  ],
                "resources" : [ { "cache_last_updated" : null,
                      "cache_url" : null,
                      "created" : "2013-05-09T14:26:50.836311",
                      "description" : "Lo strato informativo rappresenta le aree corrispondenti ai bacini idrografici di 2° livello",
                      "format" : "XML",
                      "hash" : "",
                      "id" : "dcbc02bc-57e8-4eeb-84ce-cbca42ccbf14",
                      "last_modified" : "2013-05-09T15:17:12.421471",
                      "mimetype" : "application/xml",
                      "mimetype_inner" : null,
                      "name" : "Metadati in formato XML",
                      "position" : 0,
                      "resource_group_id" : "d27fdc4a-c718-41bd-b8c8-b5babade465d",
                      "resource_type" : "api",
                      "revision_id" : "4eedf26d-c3f5-42b5-b3b9-2f4147c4834b",
                      "revision_timestamp" : "2013-05-09T13:17:12.457056",
                      "size" : "17517",
                      "state" : "active",
                      "tracking_summary" : { "recent" : 0,
                          "total" : 0
                        },
                      "url" : "http://www.territorio.provincia.tn.it/geodati/874_Bacini_idrografici_di_secondo_livello_12_12_2011.xml",
                      "url_type" : null,
                      "webstore_last_updated" : null,
                      "webstore_url" : null
                    },
                    { "cache_last_updated" : null,
                      "cache_url" : null,
                      "created" : "2013-05-09T14:26:50.836327",
                      "description" : "Lo strato informativo rappresenta le aree corrispondenti ai bacini idrografici di 2° livello",
                      "format" : "RDF",
                      "hash" : "",
                      "id" : "6f5339de-952e-4db2-b124-463c4af2eb6a",
                      "last_modified" : "2013-05-09T15:17:11.859811",
                      "mimetype" : "application/rdf+xml",
                      "mimetype_inner" : null,
                      "name" : "Dati in formato RDF",
                      "position" : 1,
                      "resource_group_id" : "d27fdc4a-c718-41bd-b8c8-b5babade465d",
                      "resource_type" : "api",
                      "revision_id" : "b2386a87-4c70-4a71-b891-f269ce8266b4",
                      "revision_timestamp" : "2013-05-09T13:17:11.907599",
                      "size" : "9616562",
                      "state" : "active",
                      "tracking_summary" : { "recent" : 0,
                          "total" : 0
                        },
                      "url" : "http://www.territorio.provincia.tn.it/geodati/874_Bacini_idrografici_di_secondo_livello_12_12_2011.rdf",
                      "url_type" : null,
                      "webstore_last_updated" : null,
                      "webstore_url" : null
                    },
                    { "cache_last_updated" : null,
                      "cache_url" : null,
                      "created" : "2013-05-09T14:26:50.836331",
                      "description" : "Lo strato informativo rappresenta le aree corrispondenti ai bacini idrografici di 2° livello",
                      "format" : "shp",
                      "hash" : "60505d102f93908a500cb92bb815344cf342e004",
                      "id" : "d626d329-f2f7-4cac-b664-029bb6ce9b93",
                      "last_modified" : "2013-05-09T15:17:13.153901",
                      "mimetype" : "application/zip",
                      "mimetype_inner" : "application/shp",
                      "name" : "Dati in formato Shapefile",
                      "position" : 2,
                      "resource_group_id" : "d27fdc4a-c718-41bd-b8c8-b5babade465d",
                      "resource_type" : "file",
                      "revision_id" : "6a314211-2a4e-4413-a977-2f7773039b62",
                      "revision_timestamp" : "2013-05-09T13:17:13.170122",
                      "size" : "4530932",
                      "state" : "active",
                      "tracking_summary" : { "recent" : 0,
                          "total" : 0
                        },
                      "url" : "http://dati.trentino.it/storage/f/2013-05-09T142649/874_Bacini_idrografici_di_secondo_livello_12_12_2011_HpiP4R.zip",
                      "url_type" : null,
                      "webstore_last_updated" : null,
                      "webstore_url" : null
                    },
                    { "cache_last_updated" : null,
                      "cache_url" : null,
                      "created" : "2013-05-09T14:26:50.836335",
                      "description" : "Lo strato informativo rappresenta le aree corrispondenti ai bacini idrografici di 2° livello",
                      "format" : "CSV",
                      "hash" : "f4ffdea832ba6d92ca158b7d0e246fb7cbec528d",
                      "id" : "3f9dd8bc-b5b2-4120-9874-fc75e35d7479",
                      "last_modified" : "2013-05-09T15:17:13.901818",
                      "mimetype" : "text/csv",
                      "mimetype_inner" : null,
                      "name" : "idrbac3.csv",
                      "position" : 3,
                      "resource_group_id" : "d27fdc4a-c718-41bd-b8c8-b5babade465d",
                      "resource_type" : "file",
                      "revision_id" : "1dbc3664-dd03-46c1-a8d2-ece2bb019b80",
                      "revision_timestamp" : "2013-11-11T04:02:03.940511",
                      "size" : "16513941",
                      "state" : "active",
                      "tracking_summary" : { "recent" : 0,
                          "total" : 0
                        },
                      "url" : "http://dati.trentino.it/storage/f/2013-05-09T142649/idrbac3.csv",
                      "url_type" : null,
                      "webstore_last_updated" : "2013-11-11T05:02:03.924453",
                      "webstore_url" : "active"
                    }
                  ],
                "revision_id" : "9c40ef03-529a-40d4-97a5-df102e6118a5",
                "revision_timestamp" : "2013-03-13T16:25:51.186810",
                "state" : "active",
                "tags" : [ { "display_name" : "Gestione del territorio",
                      "id" : "aad2c317-3a88-4a33-8bdf-b0ca2360e0d9",
                      "name" : "Gestione del territorio",
                      "revision_timestamp" : "2013-03-13T16:25:51.186810",
                      "state" : "active",
                      "vocabulary_id" : "69ccccd2-bb79-44c3-ba59-abecffdee729"
                    },
                    { "display_name" : "bacini",
                      "id" : "e9b94d29-d4e6-46fb-abc5-d08e056f7d1b",
                      "name" : "bacini",
                      "revision_timestamp" : "2013-03-11T16:56:11.646795",
                      "state" : "active",
                      "vocabulary_id" : null
                    },
                    { "display_name" : "idrografia",
                      "id" : "7cfde3ab-90f2-4893-84ff-3601ddd0317b",
                      "name" : "idrografia",
                      "revision_timestamp" : "2013-03-11T16:56:11.646795",
                      "state" : "active",
                      "vocabulary_id" : null
                    },
                    { "display_name" : "livello",
                      "id" : "f6b97094-d29d-4664-b2c4-b25ea2c11509",
                      "name" : "livello",
                      "revision_timestamp" : "2013-03-11T16:56:11.646795",
                      "state" : "active",
                      "vocabulary_id" : null
                    }
                  ],
                "title" : "Bacini idrografici di secondo livello",
                "tracking_summary" : { "recent" : 0,
                    "total" : 0
                  },
                "type" : "dataset",
                "url" : "http://www.territorio.provincia.tn.it/",
                "version" : null
              } ],
          "search_facets" : {  },
          "sort" : "score desc, metadata_modified desc"
        }

Resources

This works for resources, but apparently I cannot directly filter info of their datasets - wish I could do a join....

Note: this was done using a POST, for many APIs you can also use a GET.


curl http://dati.trentino.it/api/3/search/resource -d '{"format":"xml", "description":"meteo"}'

{"count": 44, "results": ["1ffc83a8-bedb-4fa6-8d56-483e599cbf76", "0bbde12d-348d-43ea-8a30-078d59df5188", "ad5f9738-c63c-4efc-a375-8347e5d480c8", "7469a2af-6603-4228-98fd-9d7b09bfa1e8", "91fcf750-a024-4f95-a62b-111662075831", "7f7b3117-1583-44ad-ba12-de051866e011", "cb615ca5-2314-486a-ac2c-1fa21552cc5d", "353169ed-4c97-4bd2-9713-b1bd37e3ceed", "bdfbbacf-b6a1-4bec-a577-ee4cd08938dc", "d0c6eeb5-2945-479b-83c2-dcd9cdc889ab", "d7cdd2f4-5115-4e6d-a80c-2fdc16c4eb39", "f713d89a-880a-4db0-b9b5-d11e8d8915bc", "d32b9084-482f-4979-a9dd-69a910d3e908", "6b1f58cb-2684-4457-8113-123ff4f552c0", "fa950d55-f57c-4732-9acc-a60c53533cd0", "f835ba99-5237-42ff-a0a6-7f43cfe5b3ff", "5673876a-890d-48d5-b25b-9c9af5b00947", "5618cc5c-93bc-4089-a6d1-e919283187ad", "adfe4e6c-7166-4564-a7d0-acc0fa617523", "3d057024-c50d-4025-a7be-8f7752666342"]}


Clone this wiki locally