Skip to content

Commit

Permalink
Merge pull request #235 from noi-techpark/issue-231-tourism-api-url
Browse files Browse the repository at this point in the history
Issue 231 tourism api url
  • Loading branch information
RudiThoeni committed Aug 12, 2021
2 parents a121f8f + 00e777a commit 2af3dfc
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 50 deletions.
7 changes: 7 additions & 0 deletions source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,10 @@ documentation.

New filters for the tourism domain: rawfilter, rawsort, and
removenullvalues.


.. change::
:tags: Change
:tickets: 231

The URL of the Tourism API has been updated
5 changes: 4 additions & 1 deletion source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@
.. role:: strike
""" + open("replace.rst").read()

#facility to shorten/change external links to datasets - useful if hosting changes
# facility to shorten/change external links - useful if hosting changes
#
# IMPORTANT! not all links can be shortened (i.e., when they are
# within example GET calls), so make sure to fix those as well.

extlinks = { 'sasabus': ('http://sasabus.org/%s', None),
'stinfo':
Expand Down
7 changes: 3 additions & 4 deletions source/howto/tourism/browse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ of the page allow to open various resources about the Tourism domain.
<http://tourism.opendatahub.bz.it/swagger/ui/index>`_ of the
datasets, the quickest place from where to access the datasets and
learn how to programmatically retrieve the data
* The `Open Data Hub API <http://tourism.opendatahub.bz.it/api>`_, a
browsable, hyperlinked interface over the data in the Tourism
domain.

* The :apit:`Open Data Hub API </>`, a browsable, hyperlinked
interface over the data in the Tourism domain.

.. note:: Depending on the browser used to access the APIs, an
extension might by needed for the JSON to be properly displayed
and browsed. For example, on Chrome you should install
Expand Down
2 changes: 1 addition & 1 deletion source/howto/tourism/getstarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ add an authentication header to each call. For example, using curl:
~# curl -X GET --header 'Accept: application/json' \
--header 'Authorization: Bearer vLwemAqrLKVKXsvgvEQgtkeanbMq7Xcs' \
'http\://tourism.opendatahub.bz.it/api/Gastronomy'
'https://tourism.api.opendatahub.bz.it/v1/Gastronomy'
.. note:: The string of the token is shortened for the sake of
clarity.
Expand Down
66 changes: 31 additions & 35 deletions source/howto/tourism/tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,25 @@ be retrieved. This page is divided into two parts: The first one shows
examples with code (usually the API call), the second is organised
like a FAQ section.


Example Calls
~~~~~~~~~~~~~

.. _tour-ex1:

.. rubric:: EX1. Why does this query return no result?

.. code::
http://tourism.opendatahub.bz.it/api/Gastronomy?pagesize=3&categorycodefilter=0&locfilter=reg268

:apit:`Gastronomy?pagesize=3&categorycodefilter=0&locfilter=reg268`

Because there is no value :strong:`reg268` for `locfilter`. You can
return valid IDs to be used as locfilter using this call:

.. code::
http://tourism.opendatahub.bz.it/api/RegionReduced?language=it
:apit:`RegionReduced?language=it`

An example result for this call is:

.. code:: json
{
"Id": "D2633A26C24E11D18F1B006097B8970B",
"Name": "Alta Badia"
Expand Down Expand Up @@ -64,54 +60,54 @@ identifier, followed immediately by a location Identifier.
Location identifier are the following four:

* :strong:`reg`: Region (Italian Regione)
* :strong:`tvs`: Turistic association (German Tourismusverein)
* :strong:`tvs`: Turistic association (German Tourismusverein)
* :strong:`mun`: Municipality, i.e., town or city (Italian Municipalità)
* :strong:`fra`: Suburb or district (Italian frazione)

IDs for each location can be gathered either from the swagger
interface or using an API calls:

* :strong:`reg`::
* :strong:`reg`:

http://tourism.opendatahub.bz.it/swagger/ui/index#!/Common/Common_GetRegionsReduced
http://tourism.opendatahub.bz.it/api/RegionReduced?language=it
http://tourism.opendatahub.bz.it/swagger/ui/index#!/Common/Common_GetRegionsReduced
:apit:`RegionReduced?language=it`

* :strong:`tvs`::
* :strong:`tvs`:

http://tourism.opendatahub.bz.it/swagger/ui/index#!/Common/Common_GetTourismvereinReduced
http://tourism.opendatahub.bz.it/api/TourismAssociationReduced?language=iturismusverein)
* :strong:`mun`::
:apit:`TourismAssociationReduced?language=iturismusverein)`

* :strong:`mun`:

http://tourism.opendatahub.bz.it/swagger/ui/index#!/Common/Common_GetMunicipalityReduced
http://tourism.opendatahub.bz.it/api/MunicipalityReduced?language=it
* :strong:`fra`::
:apit:`MunicipalityReduced?language=it`

* :strong:`fra`:

http://tourism.opendatahub.bz.it/swagger/ui/index#!/Common/Common_GetDistrictReduced
http://tourism.opendatahub.bz.it/api/DistrictReduced?language=it
:apit:`DistrictReduced?language=it`

For example, to retrieve all Gastronomy in the suburb of Lana, first
retrieve its ID, which is:

.. code:: json
{
"Id": "79CBD79551C911D18F1400A02427D15E",
"Name": "Lana"
"Name": "Lana"
}
Then pass the string :strong:`fra79CBD79551C911D18F1400A02427D15E` as
`locfilter`::
`locfilter`:

http://tourism.opendatahub.bz.it/api/Gastronomy?locfilter=fra79CBD79551C911D18F1400A02427D15E
:apit:`Gastronomy?locfilter=fra79CBD79551C911D18F1400A02427D15E`

*****

.. _tour-ex3:

.. rubric:: EX3. The `categorycodefilter` parameter.

|q| `categorycodefilter` seems similar to the `locfilter`
parameter found in :ref:`this trick <tour-ex2>`, but this does not
accept string?
Expand All @@ -132,17 +128,17 @@ strings, in :ref:`bitmask-value <bitmask-value>`. The code of each
category is a power of 2, so to search in multiple categories, simply
:strong:`add` the respective codes and pass them as value of the
parameter. For example, to search for Restaurants (1) and Pizzerias
(32), pass :strong:`33` to `categorycodefilter`::
(32), pass :strong:`33` to `categorycodefilter`:

http://tourism.opendatahub.bz.it/api/Gastronomy?categorycodefilter=33
:apit:`Gastronomy?categorycodefilter=33`

Tips and Tricks
~~~~~~~~~~~~~~~

.. _tour-tt1:

.. rubric:: TT1. Categorycodefilter in the Accomodation dataset.

|q| In the Accommodation dataset there's no `categorycodefilter`
filter, like in the Gastronomy dataset. Is there some equivalent
filter?
Expand All @@ -154,10 +150,10 @@ filter?
.. _tour-tt2:

.. rubric:: TT2. `odhactive` and filters starting with `odh`.

|q| What is the purpose of the `odhactive` filter? And what do all the
filters prefixed with :strong:`odh` stand for?

.. _odhtags:

|a| In the datasets, there are filters like `active` and `odhactive`,
Expand Down Expand Up @@ -204,7 +200,7 @@ will see something like:
"Seed": "43",
"Items": [
{
The remainder of the :strong:`Response Body` contains the first 15
sorted items. If you now want to retrieve page 2, page 56, or any
other, use :strong:`43` as :monospace:`seed` and write :strong:`2`,
Expand Down
2 changes: 1 addition & 1 deletion source/includes/CLI.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ used:

.. code-block:: bash
~$ curl -X GET "http://tourism.opendatahub.bz.it/api/ODHActivityPoi?pagenumber=1&pagesize=10&type=63&subtype=null&poitype=null&idlist=null&locfilter=null&langfilter=null&areafilter=null&highlight=null&source=null&odhtagfilter=null&odhactive=null&active=null&seed=null&latitude=null&longitude=null&radius=null" -H "accept: application/json"
~$ curl -X GET "https://tourism.api.opendatahub.bz.it/v1/ODHActivityPoi?pagenumber=1&pagesize=10&type=63&subtype=null&poitype=null&idlist=null&locfilter=null&langfilter=null&areafilter=null&highlight=null&source=null&odhtagfilter=null&odhactive=null&active=null&seed=null&latitude=null&longitude=null&radius=null" -H "accept: application/json"
Your best opportunity to learn about the correct syntax and parameters
Expand Down
14 changes: 6 additions & 8 deletions source/tourism-tech.rst
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ example of previous section and use the `ODHActivityPOI` dataset. The
following query will retrieve all the data in the dataset that have
some information stored in English::

http://tourism.opendatahub.bz.it/api/ODHActivityPoi?language=en
https://tourism.api.opendatahub.bz.it/v1/ODHActivityPoi?language=en

Most of the data in the Open Data Hub datasets are available in three
languages, English, German, and Italian, for which :literal:`en`,
Expand Down Expand Up @@ -259,33 +259,31 @@ retrieve and save data in CSV format:

* when using a browser, append the keyword :literal:`&format=csv` to any
query and you will be prompted to provide a name to the file that
will contain the required data. Examples::
will contain the required data. Example:

http://tourism.opendatahub.bz.it/api/Activity?fields=Id,Detail.en.Title,ContactInfos.en.CompanyName&pagesize=500
:apit:`Activity?fields=Id,Detail.en.Title,ContactInfos.en.CompanyName&pagesize=500`

This query shows its JSON output on the screen. To save it, right
click on the page and select `Save as`. ::


http://tourism.opendatahub.bz.it/api/Activity?fields=Id,Detail.de.Title,ContactInfos.de.CompanyName&pagesize=500&format=csv
:apit:`Activity?fields=Id,Detail.de.Title,ContactInfos.de.CompanyName&pagesize=500&format=csv`

Nothing is shown on screen, but a dialog window opens that allows you
to select a name for the file and the directory where to save it.


* When using a CLI command to query the Tourism endpoint, replace the
header that you send with the :command:`curl` command:

.. code:: bash
~$ curl -X GET "http://tourism.opendatahub.bz.it/api/Activity?fields=Id,Detail.en.Title,ContactInfos.en.CompanyName&pagesize=500" -H "accept: application/json"
~$ curl -X GET "https://tourism.api.opendatahub.bz.it/v1/Activity?fields=Id,Detail.en.Title,ContactInfos.en.CompanyName&pagesize=500" -H "accept: application/json"
The output of this query will be in JSON format.

.. code:: bash
~$ curl -X GET "http://tourism.opendatahub.bz.it/api/Activity?fields=Id,Detail.en.Title,ContactInfos.en.CompanyName&pagesize=500" -H "accept: text/csv"
~$ curl -X GET "https://tourism.api.opendatahub.bz.it/v1/Activity?fields=Id,Detail.en.Title,ContactInfos.en.CompanyName&pagesize=500" -H "accept: text/csv"
The output of this query will be in CSV format.
Expand Down

0 comments on commit 2af3dfc

Please sign in to comment.