Events Query with Linked Data

Unofficial Proposal Draft,

More details about this document
This version:
https://cxres.github.io/eq-ld/protocol
Issue Tracking:
GitHub
Editor:
Rahul Gupta
Authors:
Rahul Gupta
Version:
0.1.0

Abstract

Events Query with Linked Data (EQ-LD) defines representation and semantics when using linked data to request and transmit notifications with the Events Query protocol.

Status of this document

This section describes the status of this document at the time of its publication.

The information in this draft document is still subject to change. It may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

You are invited to contribute any feedback, comments, or questions you might have.

1. Introduction

This section is non-normative.

Events Query [EVENTS-QUERY] is a minimal event notifications protocol built on top of HTTP. Events Query with Linked Data (EQ-LD) defines representation and semantics for using linked data to request and transmit event notifications directly from HTTP resources with the Events Query protocol.

1.1. Audience

This section is non-normative.

This specification is for:

1.2. Namespaces

This specification uses the following RDF vocabularies and corresponding namespace prefix bindings:

Prefixes and Namespaces
Prefix Namespace Description
eq-ld http://cxres.github.io/eq-ld/ns/eq.ttl# Events Query with Linked Data
as https://www.w3.org/ns/activitystreams# [ACTIVITYSTREAMS-VOCABULARY]
http http://www.w3.org/2011/http# [HTTP-in-RDF10]
xs http://www.w3.org/2001/XMLSchema# [XMLSCHEMA11-1]

1.3. Conformance

1.3.1. Document Conventions

All of the text of this specification is normative except assertions, diagrams, examples, notes and sections explicitly marked as non-normative as described in [RFC2119].

The key words "MUST", "MUST NOT", "SHOULD", "SHOULD NOT" and "MAY" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.

The above-mentioned keywords are used exclusively in the normative parts of this document and appear only in all capitals.

1.3.2. Specification Category

The Events Query with Linked Data identifies the following Specification Categories [SPEC-VARIABILITY] to distinguish the types of conformance:

1.3.3. Classes of Products

The Events Query with Linked Data identifies the following Classes of Products [SPEC-VARIABILITY] for conforming implementations. These products are referenced throughout this specification.

Server

A server that builds on HTTP server [RFC9110] and [RFC9112] by defining methods,media types and behaviour of resources.

Client

A client that builds on a HTTP client [RFC9110], [RFC9112] and [FETCH] by defining behaviour in terms of fetching across the platform.

1.3.4. Interoperability

Interoperability occurs between Client—Server as defined by Events Query with Linked Data.

Client—Server Interoperability

Interoperability of implementations for clients and servers is tested by evaluating an implementation’s ability to transmit and receive event notifications that conform to Events Query with Linked Data.

2. Discovery

A client can discover support for event notifications using Events Query with Linked Data by examining if a server is able to accept a query request on a resource using a suitable RDF serialization with content consistent with the Request Format.

A server that provides event notifications using Events Query with Linked Data on a resource MUST advertize application/ld+json [JSON-LD11] as an acceptable representation for a request with the QUERY method ([HTTP-QUERY]), using the Accept-Query ([HTTP-QUERY] § 3) header field of a response. A server MUST further set the value of the profile parameter of the application/ld+json media type to indicate a preferred JSON-LD context http://www.w3.org/ns/json-ld#context with http://cxres.github.io/eq-ld/ns/context.jsonld as the URI.

Discovery Request and Response
Request
HEAD /missing/John_Doe HTTP/1.1Host: example.org
Response
HTTP/1.1 200 OKAccept-Query: application/ld+json;  profile="http://www.w3.org/ns/json-ld#context http://cxres.github.io/eq-ld/ns/context.jsonld"

3. Request

3.1. Data Model

A request for event notifications using the Events Query with Linked Data builds on the abstract data model defined by the HTTP Events Query protocol [EVENTS-QUERY].

3.2. Vocabulary

The request data is expressed with the HTTP Vocabulary in RDF 1.0 [HTTP-in-RDF10] and the Events Query with Linked Data vocabulary.

Events Query with Linked Data defines the following RDF properties that a client MAY use in a request:

eq-ld:events <http:headers>
Header fields to negotiate event notifications in an Events Query.
eq-ld:state <http:headers>
Header fields to negotiate the representation of resource state in an Events Query.

3.3. Extended Content

A server MAY admit an extended request based on an augmented JSON-LD Context [JSON-LD11] definition.

Implementation Guidance
Servers are encouraged to be aware that anything can be included in an Events Query request. Servers are advised to take suitable precautions when processing request queries.

3.4. Format

A server implementing Events Query with Linked Data MUST accept a request using the QUERY method ([HTTP-QUERY] § 2) when the content-type of the request is application/ld+json [JSON-LD11], and includes http://cxres.github.io/eq-ld/ns/context.jsonld as a URI for the JSON-LD context.

A server MAY support additional RDF representations for an Events Query.

Request for Event Notifications
QUERY /missing/John_Doe HTTP/1.1Host: example.orgContent-Type: application/ld+json{  "@context": "http://cxres.github.io/eq-ld/ns/context.jsonld",  "eq-ld:events":[    {      "@type":"http:RequestHeader",      "http:hdrName":"http-headers:accept",      "http:headerElements":[        {          "@type":"http:HeaderElement",          "http:elementName":"application/ld+json"        }      ]    }  ]}

4. Notification

4.1. Data Model

An Events Query with Linked Data notification message specializes the Activity object defined by Activity Streams 2.0 [ACTIVITYSTREAMS-CORE].

4.2. Vocabulary

The core notification data is expressed with the Activity Streams vocabulary [ACTIVITYSTREAMS-VOCABULARY].

An event notification transmitted using the Events Query with Linked Data protocol MUST have the following properties:

as:type <as:Activity>
the type of activity that triggered the notification.
as:published <xs:dateTime>
the date and time of the notification.

4.3. Activity Mapping

A server sending an event notification with the Events Query with Linked Data protocol as a result of some activity on a resource MUST set the type property as the type of activity that triggered the notification as specified by the Activity Streams vocabulary [ACTIVITYSTREAMS-VOCABULARY].

4.4. Extended Content

A server MAY augment the JSON-LD Context [JSON-LD11] definition and extend the content of an event notification.

NOTE: See examples of using multiple vocabularies in the Activity Streams [ACTIVITYSTREAMS-CORE] specification.

Implementation Guidance
Clients are encouraged to be aware that anything can be included in an event notification. Clients are advised to take suitable precautions when ascertaining the veracity of the contents.

4.5. Format

A server implementing Events Query with Linked Data on a resource MUST be able to transmit event notifications using the application/ld+json [JSON-LD11] media-type.

A server MAY additionally support other RDF serializations to transmit event notifications.

An Event Notifications
HTTP/1.1 200 OKContent-Type: application/ld+jsonContent-Length: 180{  "@context": "https://www.w3.org/ns/activitystreams",  "published": "2024-11-10T11:12:13Z",  "type": "Update",  "object": "https://example.org/missing/John_Doe"}

Considerations

This section is non-normative.

References within this specification point to documents with a Living Standard or Draft status, meaning their contents can still change over time. It is advised to monitor these documents, as such changes might have implications.

Security Considerations

This section is non-normative.

Since Events Query with Linked Data uses Events Query to transmit notifications, it follows that the Events Query with Linked Data inherits security considerations from Events Query, as discussed in [EVENTS-QUERY] § Security Considerations.

Servers are strongly discouraged from exposing information beyond the minimum amount necessary in a notification. Clients are strongly discouraged from exposing information beyond the minimum amount necessary to receive notifications from particular resources.

Clients are discouraged from sending requests for notifications to untrusted servers, including localhost or any other loopback IP address, in order to avoid making arbitrary requests.

Example

This section is non-normative.

The following uses the example of a resource with a missing persons' report to illustrate the request and response for representation and event notifications using Events Query with Linked Data.

Events Query with Linked Data: A Complete Example

The client specifies headers in both the eq-ld:state and eq-ld:events property of the Events Query request:

QUERY /missing/John_Doe HTTP/1.1Host: example.orgContent-Type: application/ld+json{  "@context": "http://cxres.github.io/eq-ld/ns/context.jsonld",  "eq-ld:state":[    {      "@type":"http:RequestHeader",      "http:hdrName":"http-headers:accept",      "http:headerElements":[        {          "@type":"http:HeaderElement",          "http:elementName":"text/html"        }      ]    }  ],  "eq-ld:events":[    {      "@type":"http:RequestHeader",      "http:hdrName":"http-headers:accept",      "http:headerElements":[        {          "@type":"http:HeaderElement",          "http:elementName":"application/ld+json"        }      ]    }  ]}

The server immediately returns headers indicating that the response shall transmit a stream of event notifications:

HTTP/1.1 200 OKAccept-Query: application/ld+json;  profile="http://www.w3.org/ns/json-ld#context http://cxres.github.io/eq-ld/ns/context.jsonld"Content-Type: application/httpEvents: duration=1200Incremental: ?1

Following this, the server returns the missing persons' report as the representation of the resource:

HTTP/1.1 200 OKContent-Type: application/ld+jsonContent-Length: 139{  "@context": "https://json-ld.org/contexts/person.jsonld",  "@id": "http://dbpedia.org/resource/John_Doe",  "name": "John Doe"}

Subsequently, when status of the person is updated, the server transmits an event notification:

HTTP/1.1 200 OKContent-Type: application/ld+jsonContent-Length: 180{  "@context": "https://www.w3.org/ns/activitystreams",  "published": "2024-11-10T11:12:13Z",  "type": "Update",  "object": "https://example.org/missing/John_Doe"}

Finally, the person is found, so the resource is deleted, the server emits an event notification and the stream closes:

HTTP/1.1 200 OKContent-Type: application/ld+jsonContent-Length: 180{  "@context": "https://www.w3.org/ns/activitystreams",  "published": "2024-11-10T14:15:16Z",  "type": "Delete",  "object": "https://example.org/missing/John_Doe"}

References

Normative References

[ACTIVITYSTREAMS-CORE]
James Snell; Evan Prodromou. Activity Streams 2.0. URL: https://w3c.github.io/activitystreams/core/
[ACTIVITYSTREAMS-VOCABULARY]
James Snell; Evan Prodromou. Activity Vocabulary. URL: https://w3c.github.io/activitystreams/vocabulary/
[EVENTS-QUERY]
Rahul Gupta. HTTP Events Query. URL: https://cxres.github.io/events-query/draft-gupta-httpapi-events-query.html
[FETCH]
Anne van Kesteren. Fetch Standard. Living Standard. URL: https://fetch.spec.whatwg.org/
[HTTP-in-RDF10]
Johannes Koch; Carlos A. Velasco; Philip Ackermann. HTTP Vocabulary in RDF 1.0. 2 February 2017. NOTE. URL: https://www.w3.org/TR/HTTP-in-RDF10/
[HTTP-QUERY]
Julian Reschke; James M. Snell; Mike Bishop. The HTTP QUERY Method. Internet Draft. URL: https://httpwg.org/http-extensions/draft-ietf-httpbis-safe-method-w-body.html
[JSON-LD11]
Gregg Kellogg; Pierre-Antoine Champin; Dave Longley. JSON-LD 1.1. URL: https://w3c.github.io/json-ld-syntax/
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://datatracker.ietf.org/doc/html/rfc2119
[RFC8174]
B. Leiba. Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words. May 2017. Best Current Practice. URL: https://www.rfc-editor.org/rfc/rfc8174
[RFC9110]
R. Fielding, Ed.; M. Nottingham, Ed.; J. Reschke, Ed.. HTTP Semantics. June 2022. Internet Standard. URL: https://httpwg.org/specs/rfc9110.html
[RFC9112]
R. Fielding, Ed.; M. Nottingham, Ed.; J. Reschke, Ed.. HTTP/1.1. June 2022. Internet Standard. URL: https://httpwg.org/specs/rfc9112.html
[SPEC-VARIABILITY]
Dominique Hazaël-Massieux; Lynne Rosenthal. Variability in Specifications. 31 August 2005. NOTE. URL: https://www.w3.org/TR/spec-variability/
[XMLSCHEMA11-1]
Sandy Gao; et al. W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures. 5 April 2012. REC. URL: https://www.w3.org/TR/xmlschema11-1/