• Aucun résultat trouvé

Bridging Web APIs and Linked Data with SPARQL Micro-Services

N/A
N/A
Protected

Academic year: 2021

Partager "Bridging Web APIs and Linked Data with SPARQL Micro-Services"

Copied!
5
0
0

Texte intégral

(1)

HAL Id: hal-01783936

https://hal.archives-ouvertes.fr/hal-01783936

Submitted on 2 May 2018

HAL is a multi-disciplinary open access

archive for the deposit and dissemination of

sci-entific research documents, whether they are

pub-lished or not. The documents may come from

teaching and research institutions in France or

abroad, or from public or private research centers.

L’archive ouverte pluridisciplinaire HAL, est

destinée au dépôt et à la diffusion de documents

scientifiques de niveau recherche, publiés ou non,

émanant des établissements d’enseignement et de

recherche français ou étrangers, des laboratoires

publics ou privés.

Distributed under a Creative Commons Attribution| 4.0 International License

Bridging Web APIs and Linked Data with SPARQL

Micro-Services

Franck Michel, Catherine Faron Zucker, Fabien Gandon

To cite this version:

Franck Michel, Catherine Faron Zucker, Fabien Gandon. Bridging Web APIs and Linked Data with

SPARQL Micro-Services. Extended Semantic Web Conference (ESWC), Jun 2018, Portoroz, Slovenia.

pp.187-191, �10.1007/978-3-319-98192-5_35�. �hal-01783936�

(2)

SPARQL Micro-Services

Franck Michel, Catherine Faron-Zucker, and Fabien Gandon

Universit´e Cˆote d’Azur, Inria, CNRS, I3S (UMR 7271), France franck.michel@cnrs.fr, faron@i3s.unice.fr, fabien.gandon@inria.fr

Abstract. Web APIs are a prominent source of machine-readable in-formation that remains insufficiently connected to the Web of Data. To enable automatic combination of Linked Data (LD) interfaces and Web APIs, we present the SPARQL Micro-Service architecture. A SPARQL micro-service is a lightweight SPARQL endpoint that provides access to a small, resource-centric, virtual graph, while dynamically assigning stable, dereferenceable URIs to Web API resources that do not have URIs in the first place. We believe that the emergence of an ecosystem of SPARQL micro-services could enable LD-based applications to glean pieces of data from a wealth of distributed, scalable and reliable services from independent providers. We describe an experimentation where we dynamically augment biodiversity-related LD resources with data from Flickr, MusicBrainz and the Macauley scientific media library.

Keywords: Web API, SPARQL, micro-service, Linked Data, JSON-LD

1

Introduction

Web APIs are commonly used to enable HTTP-based, machine-processable ac-cess to all sorts of data. Similarly, Linked Data (LD) seek the publication of machine-readable data on the Web while connecting related resources accross datasets. Several approaches have been proposed to bridge these two worlds, based on bespoke wrappers, SPARQL extensions or RESTful APIs. Until now however, several challenges hinder the definition of standard approaches to en-able automatic reconciliation of LD and Web APIs. Firstly, Web APIs usually rely on proprietary vocabularies documented in Web pages meant for devel-opers but hardly machine-readable. Secondly, on-the-fly SPARQL querying of non-RDF data sources proves to be difficult, as attested by the many works on SPARQL-based access to legacy databases.

The SPARQL Micro-Service architecture aims to address this issue. The term micro-service refers to an increasingly popular architectural style where an application consists of a collection of lightweight, loosely-coupled, fine-grained services that are deployed independently [2]. They improve applications mod-ularity thereby speeding up the development, testing and deployment process. Leveraging these principles may help in the design of modular LD-based ap-plications structured as a collection of services such as RDF stores, SPARQL

(3)

2

endpoints, SPARQL micro-services or other services based on LD REST APIs for instance. A SPARQL micro-service is a lightweight method to query a Web API using SPARQL. It provides access to a small RDF graph describing the tar-geted resources from the data available at the API, while dynamically assigning dereferenceable URIs to Web API resources that do not have URIs beforehand.

2

SPARQL Micro-Services Principles

A SPARQL micro-service Sµis a wrapper of a Web API service Sw. It complies with the SPARQL Query Language and protocol, and accepts a set Argw of arguments that are specific to Sw. These arguments are passed to Sµas param-eters on the HTTP query string, e.g. “http://hostname/sparql?param=value”. Sµ evaluates a SPARQL query Q against an RDF graph that it builds at run-time as follows: it invokes the Web API service Sw with the arguments in Argw, translates the response into RDF triples (in an implementation-dependent man-ner), evaluates Q against these triples and returns the result to the client.

The semantics of a SPARQL micro-service differs from that of a standard SPARQL endpoint insofar as the SPARQL protocol treats a service URL as a black box, i.e. it does not interpret URL parameters. By contrast, a SPARQL micro-service is a configurable SPARQL endpoint whose arguments delineate the virtual graph being queried. Thence, each pair (Sµ, Argw) is a standard SPARQL endpoint. Arguably, other options may be adopted to pass the arguments to Sµ, that we discuss in details in [1].

Furthermore, bridging Web APIs and LD requires to create stable, deref-erenceable URIs for Web API resources that are generally identified by mere proprietary identifiers. This is implemented quite easily with SPARQL micro-services: once a stable URI scheme is decided, a Web server is set up to handle look-ups for URIs matching that scheme: for each look-up, it invokes a suitable SPARQL micro-service along with an appropriate CONSTRUCT or DESCRIBE query form. Hence, by smartly designing services, we can come up with a con-sistent ecosystem where some micro-services respond to SPARQL queries while translating Web API identifiers into URIs that, in turn, are made dereferenceable by other micro-services.

3

Implementation and Experimentation

To evaluate this architecture, we have developed a prototype implementation1 depicted in Figure 1, that handles JSON-based Web APIs. It maps a Web API re-sponse to RDF triples in two steps. First, the rere-sponse is translated to JSON-LD by applying a JSON-LD profile. The resulting graph G is stored in an in-memory triple store. Then, for mapping cases that JSON-LD cannot describe (involving e.g. string manipulations), a SPARQL INSERT query augments G with triples based on well-adopted or domain vocabularies. Lastly, Sµ evaluates the client’s

1

(4)

Fig. 1. Example SPARQL micro-service implementation for JSON-based Web APIs.

p r e f i xp r e f i xp r e f i x r d f s : < h t t p :// www . w3 . org / 2 0 0 0 / 0 1 / rdf - s c h e m a # > p r e f i xp r e f i xp r e f i x owl : < h t t p :// www . w3 . org / 2 0 0 2 / 0 7 / owl # >

p r e f i xp r e f i xp r e f i x f o a f : < h t t p :// x m l n s . com / f o a f /0.1/ > p r e f i xp r e f i xp r e f i x s c h e m a : < h t t p :// s c h e m a . org / > C O N S T R U C TC O N S T R U C TC O N S T R U C T { ? s p e c i e s s c h e m a : s u b j e c t O f ? p h o t o ; f o a f : d e p i c t i o n ? img ; # f r o m F l i c k r s c h e m a : c o n t e n t U r l ? a u d i o U r l ; # f r o m the M a c a u l a y L i b r a r y s c h e m a : s u b j e c t O f ? p a g e . # f r o m M u s i c B r a i n z } W H E R EW H E R EW H E R E { S E R V I C E S E R V I C E S E R V I C E < h t t p s :// t a x r e f . m n h n . fr / sparql > { ? s p e c i e s a owl : C l a s s ; r d f s : l a b e l " D e l p h i n u s d e l p h i s ". } S E R V I C E S E R V I C E S E R V I C E < h t t p s :// e x a m p l e . org / sparql - ms / f l i c k r / g e t P h o t o s B y G r o u p B y T a g ? g r o u p _ i d = 8 0 6 9 2 7 @ N 2 0 & t a g s = t a x o n o m y : b i n o m i a l = D e l p h i n u s + delphis > { ? p h o t o f o a f : d e p i c t i o n ? img . } S E R V I C E S E R V I C E S E R V I C E < h t t p s :// e x a m p l e . org / sparql - ms / m a c a u l a y l i b r a r y / g e t A u d i o B y T a x o n ? n a m e = D e l p h i n u s + delphis > { [] s c h e m a : c o n t e n t U r l ? a u d i o U r l . } S E R V I C E S E R V I C E S E R V I C E < h t t p s :// e x a m p l e . org / sparql - ms / m u s i c b r a i n z / g e t S o n g B y N a m e ? n a m e = D e l p h i n u s + delphis > { [] s c h e m a : s a m e A s ? p a g e . } }

Listing 1.1. Querying SPARQL micro-services to enrich a LD resource with data from Flickr, the Macaulay Library and MusicBrainz.

SPARQL query against G and returns the response following a regular content negotiation.

Listing 1.1 exemplifies the use of SPARQL micro-services in a biodiversity-related use case. The query retrieves the URI of a resource representing the common dolphin (species Delphinus delphis) from a taxonomic register. Then, it invokes SPARQL micro-services to retrieve additional data from three Web APIs: photos from the Flickr photography social network2, audio recordings from the Macaulay Library3 and music tunes from MusicBrainz4. Figure 2 portrays a snippet of the response to this query in the Turtle syntax, along with photos, audio recordings pictures and a MusicBrainz Web page.

2 https://www.flickr.org/ 3

https://www.macaulaylibrary.org/

4

(5)

4

Fig. 2. Snippet of the response to query Q (Listing 1.1) along with snapshots of the images, audio recordings and Web page whose URLs are part of the response.

4

Future Works

For an ecosystem of SPARQL micro-services to emerge from independent service providers, two crucial issues shall be tackled. Firstly, to enable services discov-ery, SPARQL micro-services should provide self-describing metadata such as the query string parameters or the types of triples generated. In this respect, the smartAPI metadata specification may be leveraged [4]. Secondly, it should be possible to retrieve fragments by smaller pieces using a paging mechanism. To tackle those issues, Triple Patterns Fragments (TPF) expose a self-describing, uniform interface consisting of metadata and hypermedia controls [3]. A perspec-tive would be to extend this approach to the case of SPARQL micro-services, stemming some sort of Graph Pattern Fragment interface, i.e. a generalized TPF interface able to process regular graph patterns instead of only triple patterns, but still complying with the TPF metadata and hypermedia controls specifi-cation. Let us finally mention that we have focused specifically on consuming Web APIs data with SPARQL, although the principles presented in this work could apply to other types of APIs. Furthermore, many APIs empower users not only to read but more importantly to interact with data. Hence, an interesting perspective would be to think of SPARQL micro-services as a way to support distributed SPARQL Update over Web APIs, thus eventually contributing to build an actual read-write Web of Data.

References

1. F. Michel, C. Faron-Zucker, and F. Gandon. SPARQL micro-services: Lightweight integration of web APIs and linked data. In Proc. of LDOW 2018, 2018.

2. S. Newman. Building Microservices. O’Reilly Media, 2015.

3. R. Verborgh, M. Vander Sande, O. Hartig, J. Van Herwegen, L. De Vocht, B. De Meester, G. Haesendonck, and P. Colpaert. Triple Pattern Fragments: a Low-cost Knowledge Graph Interface for the Web. J. Web Semantics, 37–38:184– 206, 2016.

4. A. Zaveri, S. Dastgheib, T. Whetzel, R. Verborgh, P. Avillach, G. Korodi, R. Terryn, K. Jagodnik, P. Assis, C. Wu, and M. Dumontier. smartAPI: Towards a more intelligent network of Web APIs. In Proc. of 14th ESWC, pages 154–169, 2017.

Figure

Fig. 1. Example SPARQL micro-service implementation for JSON-based Web APIs.
Fig. 2. Snippet of the response to query Q (Listing 1.1) along with snapshots of the images, audio recordings and Web page whose URLs are part of the response.

Références

Documents relatifs

Firstly, to enable services discovery, SPARQL micro-services should provide machine-processable self-describing metadata such as the expected arguments, the way they are passed to

We propose an extension of SPARQL that allows us to connect to Web APIs, extending query answers with data obtained from a Web Service, in real time and without any setup.. With

BASIL (Builging Apis SImpLy) is a cloud platform that allows data consumers to tailor their own Web APIs by specifying queries on SPARQL endpoints.. Tailored Web APIs and related

However, the majority of SPARQL implemen- tations require the data to be available in advance, i.e., to exist in main memory or in a RDF repository (accessible through a SPARQL

In most queries the time for first answer is increased because the number of times the original query is executed (#EQ) in parallel SemLAV is less than in SemLAV; furthermore,

J’ai erré un peu dans les grands boulevards de la capitale, avant de m’installer, comme des centaines d’autres moustachus, sur la terrasse d’un petit bistro

Indeed, our experience with the framework showed that the approach it proposes, regard- less of a particular implementation or programming language, can lead to better RESTful design

D’autres études indiquent que chez les patients atteints de maladies hématologiques souffrant de CMV, l'échec de l'éradication de la virémie après un