This is the website of the Open Data Hub documentation, a collection of technical resources about the Open Data Hub project. The website serves as the main resource portal for everyone interested in accessing the data or deploying apps based on datasets & APIs provided by the Open Data Hub team.
The technical stuff is composed of:
- Catalogue of available datasets.
- How-tos, FAQs, and various tips and tricks for users.
- Links to the full API documentation.
- Resources for developers.
For non-technical information about the Open Data Hub project, please point your browser to https://opendatahub.bz.it/.
The Open Data Hub project envisions the development and set up of a portal whose primary purpose is to offer a single access point to all (Open) Data from the region of South Tyrol, Italy, that are relevant for the economy sector and its actors. This will also allow everybody to utilise these data in all digital communication channels and build application on top of the data offered, be them either a PoC to explore new means or new field in which to use Open Data Hub data, or novel and innovative services or software products built on top of the data.
All the data within the Open Data Hub will be easily accessible, preferring open interfaces and APIs which are built on existing standards like The Open Travel Alliance (OTA), The General Transit Feed Specification (GTFS), Alpinebits.
Depending on the development of the project and the interest of users, more standards and data formats might be supported in the future.
Open Data Hub Architecture¶
The architecture of the Open Data Hub is depicted in Figure 2, which shows its composing elements together with its main goal: To gather data from Data Sources and make them available to Data Consumers, which are usually third-party applications that use those data in any way that they deem useful, including (but not limited to) study the evolution of historical data, or carry out data analysis to produce statistical graphics.
At the core of the Open Data Hub lays bdp-core, a java application which contains all the business logic and handles all the connections with the underling database using the DAL. The BDP Core is composed by different modules: A Writer, that receives data from the Data Sources and stores them in the Database using the DAL and a Reader that extracts data form the databases and exposes them to Data Consumers using APIs on REST endpoints.
Communication with the Data Sources is guaranteed by the Data Collectors, which are Java applications built on top of the dc-interface that use a DTO for each different source to correctly import the data. Dual to the dc-interface, the ws-interface allows the export of DTOs to web services, that expose them to Data Consumers.
The bottom part of Figure 2 shows the data format used in the various steps of the data flow. Since the data are exposed in JSON, it is possible to develop applications in any language that uses them.
Records in the Data Sources can be stored in any format and are converted into JSON as DTOs. They are then transmitted to the Writer, who converts them and stores them in the Database using SQL. To expose data, the Reader queries the DB using SQL, transforms them in JSON’s DTOs to the Web Services who serve the JSON to the Data Consumers.
The Elements of the Open Data Hub in Details¶
As Figure 2 shows, the Open Data Hub is composed by a number of elements, described in the remainder of this section in the same order as they appear in the picture.
- Data Source
A Data Source is the origin of one ore more datasets, which usually belongs to a single domain. Data are usually automatically picked up by sensors and stored in some format, like for example CSV.
Each data source is provided by one Data Provider. Since a data provider may decide to not publish its data on the Open Data Hub anymore, or new data providers can join the Open Data Hub in the future, they are not an official part of the Open Data Hub. You can learn more on this, including the current list of data providers, in the dedicated section of the documentation.
- A dataset is a collection of records that originate from the same Data Source. Within the Open Data Hub, a same Data Source may provide more datasets, that include slight different data, but there is at least one dataset per domain. The underlying data format of a dataset never changes.
- Data Collectors
- Data collectors are a library of Java classes used to transform data coming from Data Sources into a format that can be understood, used, and stored by BDP Core. As a rule of thumb, each Data Collector is used for one Data Source or dataset and use DTOs to transfer them to the BDP Core. They are usually created by extending the dc-interface in the bpd-core repository.
- The Data Transfer Object are used to translate the data format from the various formats used by the Data Sources, to be read from the writer and to be exposed by the reader (see below). DTOs are written in JSON, and are composed of three Entities: Station, Data Type, and Record.
- With the Writer, we enter in the BDP Core. The Writer’s purpose is to receive DTOs from the Data Collectors and store them into the DB and therefore implements all methods to read the DTO’s JSON format and to write to the database using SQL.
- BDP Core
- The BDP Core lays at the very core of the Open Data Hub. Its main task is to keep the database updated, to be able to always serve up-to-date data. To do so, it relies on the Writer, to gather new or updated data from the data collectors and keeps a history of all data he ever received. It also relies on the Reader to expose data to the data consumers. Internal communication uses only SQL commands.
- The Data Abstraction Layer is used by both the Writer and the Reader to access the Database and exchange DTOs and relies on Java Hibernate. It contains classes that map the content of a DTO to corresponding database tables.
- Database (DB)
- The database represents the persistence layer and contains all the data sent by the Writer. Its configuration requires that two users be defined, one with full permissions granted -used by the writer, and one with read-only permissions, used by the Reader.
- The reader is the last component of the Core. It uses the DAL to retrieve DTOs from the DB and to transmit them to the web services.
- Web Services
- The Web Services, which extend the ws-interface in the BDP Core repository, receive data from the Reader and make them available to Data Consumers by exposing APIs and REST endpoints. They transform the DTO they get into JSON.
- Data Consumers
- Data consumers are (web-)applications that use the JSON produced by web services and manipulates them to produce a useful output for the final user.
Also part of the architecture, but not pictured in the diagram, is the
persistence.xml file, which contains the credentials and
postgres configuration used by both the Reader and Writer.
Available Domains and APIs¶
The domains intended as sources for data served by the Open Data Hub are depicted in Figure 1.
The API of a software contains the definition of methods and of their signatures, that can be invoked to retrieve data from the web services provided by the software itself. The signature of each method defines how to invoke the method (i.e., the name of the method), which parameters should be supplied (i.e., their names and types, if they are mandatory or not, and what the method returns (i.e., the type and format of the output produced by the method. By using an API, it is possible to receive data from the web service and process them.
Currently, the following APIs are available from the Open Data Hub:
- Mobility APIs
- SASAbus APIs
- Tourism APIs.
The first and second APIs provide datasets that belong to the Mobility Domain, while the third one to datasets in the Tourism Domain.
The Mobility APIs allow to access real-time data of the datasets concerning the e-mobility, including data about e-charging stations, availability of plugs to recharge e-cars, and so on.
The SASAbus APIs are part of the Mobility domain and allow to access various type of data about buses and station.
The Tourism API allows to access locations (of hotels, museums, events, and so on), points of interests, and a number of other information about the tourism in South Tyrol.
The authentication layer is currently intended for internal use only.
Authentication in Open Data Hub is mainly used when exposing data to the consumer, which means by the Reader and in every single web service accessing the Reader, to allow the access to closed data in each dataset only to those who are allowed to.
There are currently two different authentication methods available:
- The Token-based Authentication, defined in RFC 6750, requires that anyone who wants to access resources supply a valid username and password and becomes a Bearer Token that must be used to access the data. After the token expires, a new one must be obtained. This type of authentication is used for the datasets in the tourism domain.
- The OAuth2 Authentication follows the RFC 6749 and is used for all the datasets in the mobility domain.
For those not familiar with the OAuth2 mechanism, here is a quick description of the client-server interaction:
The client requests the permission to access restricted resources to the authorisation server.
The authorisation server replies with a refresh token and an access token. The access token contains an expire date.
The access token can now be used to access protected resources on the resource server. To be able to use the access token, add it as a Bearer token in the Authorization header of the HTTP call. Bearer is a means to use tokens in HTTP transactions. The complete specification can be found in RFC 6750.
If the access token has expired, you’ll get a HTTP
401 Unauthorizedresponse. In this case you need to request a new access-token, passing your refresh token in the Authorization header as Bearer token. As an example, in Open Data Hub datasets Bearer tokens can be inserted in a curl call like follows:
curl -X GET "$HTTP_URL_WITH_GET_PARAMETERS" -H "accept: */*" -H "Authorization: Bearer $TOKEN"
Here, $HTTP_URL_WITH_GET_PARAMETERS is the URL containing the API call and “$TOKEN” is the string of the token.
Accessing data in the Open Data Hub¶
There are different modalities to access data that are provided by the Open Data Hub, that are listed here. Currently, only data from the Mobility and Tourism domains can be accessed, both from the command line and using a browser. Various dedicated tutorials are available in the List of HOWTOs section; while in section How To Contribute you can find additional ways to interact with the data and the Open Data Hub team.
By using a browser it is possible to access data in different ways:
- Go to the Apps built from Open Data Hub datasets section of the documentation, particularly sub-sections Production Stage Apps and Beta Stage Apps, and choose one of the web sites and portals that are listed there. Each of them uses the data gathered from one or more Open Data Hub’s datasets to display a number of useful information. You can then see how data are exposed and browse them.
- In the same Apps built from Open Data Hub datasets section, you can also check the list of the Alpha Stage Apps and choose one of them that you think you can expand, then get in touch with the authors to suggest additional features or collaborate with them to discuss its further development to improve it.
- Access the ODH Tourism data browser and search for the Open Data available in the Tourism domain. You can simply use those data for your convenience, or you might even find a novel way to exploit those data and use them in an app or portal you are going to develop. A detailed howto is available: How to use the Open Data Hub’s Tourism Data Browser? to help you getting acquainted with the browser.
- Go to the Swagger interface of the datasets in the Tourism domain, located at http://tourism.opendatahub.bz.it/swagger/, to learn how the REST APIs are built and how you can script them to fetch data for your application. To get started, there is a dedicated howto: How to access Tourism Data? that will guide you in the first steps.
- Access the Swagger interface of the datasets in the Mobility domain. Check the link for each of them in section Datasets in the Mobility Domain. Like in the case of the tourism’ Swagger interface, you can learn REST API call for that domain and fetch data for your application. There is a dedicated howto to learn more how to interact with this interface: ref:mobility-data-howto
- Open the Analytics for Mobility web page, at https://analytics.mobility.bz.it/. This portal uses data in the mobility domain to display various information about the sensors, including their locations, what they measure, and actual data in near-real time. You can retrieve
Command line access proves useful for scripting and quick data manipulation, for example within applications that gather data and present them to end users. On the other hand, browser access is useful on different levels: for the casual user, to have a look at the type and quality of data provided, or even to use the REST API implemented by the Open Data Hub in order to get acquainted with the various methods to retrieve data.
Command line access to the data is usually carried out with the wget utility, used to retrieve information in a non-interactive way. To learn about the correct syntax and parameter to use, go to the swagger interface of the tourism or mobility  domains and execute a query: with the output, also the corresponding wget command used to retrieve the data will be shown.
|||Add the dataset name, see Datasets in the Mobility Domain.|