Turtle

Turtle is an RDF serialization format. In this book i'll always show events in the Turtle (often abbreviated as "ttl") format, because it's very easy to read.

Hello Nostr

In pure JSON, a "Hello Nostr" text note looks like this:

{
  "content": "Hello Nostr",
  "created_at": 1743619857,
  "id": "20df611b4b232d890f874555a20ba89eef6ab744e60a62f6be1566a426d65f73",
  "kind": 1,
  "pubkey": "aaaa5db09dc270c7a7368825e6ac5ab55d169c1fea8b2ff9fa6d0c826e5d5d12",
  "sig": "860557ca6532d34bc683c0d1b15006af3d325f401f56f058c7c53864628192d1f9474a78022655be5353a8e76090b7c60f0d5cf0a86666c79e7b8af2ab798db3",
  "tags": []
}

In ttl, it looks like this:

<urn:nostr-event:20df611b4b232d890f874555a20ba89eef6ab744e60a62f6be1566a426d65f73> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/nostr#Event> ;
  <https://w3id.org/nostr#created_at> "1743619857"^^<http://www.w3.org/2001/XMLSchema#integer> ;
  <https://w3id.org/nostr#id> "20df611b4b232d890f874555a20ba89eef6ab744e60a62f6be1566a426d65f73" ;
  <https://w3id.org/nostr#nip21> <nostr:npub14249mvyacfcv0fek3qj7dtz6k4w3d8qla29jl706d5xgymjat5fqac46s2> ;
  <https://w3id.org/nostr#content> "Hello Nostr" ;
  <https://w3id.org/nostr#kind> "1"^^<http://www.w3.org/2001/XMLSchema#integer> ;
  <https://w3id.org/nostr#pubkey> "aaaa5db09dc270c7a7368825e6ac5ab55d169c1fea8b2ff9fa6d0c826e5d5d12" ;
  <https://w3id.org/nostr#sig> "860557ca6532d34bc683c0d1b15006af3d325f401f56f058c7c53864628192d1f9474a78022655be5353a8e76090b7c60f0d5cf0a86666c79e7b8af2ab798db3"

This is a list of triples. A triple is made of a subject, a predicate, and an object. The subject and the predicate are always what we call URIs (Uniform Resource Identifier), while the object can be an URI or an RDF Literal value (integers, floats, strings, URLs, booleans, ...). From these triples, we learn that:

  1. The urn:nostr-event:... URI is a URN identifying our event. Note that it uses the URN Namespace Identifier (NID) nostr-event (nostralink declares and uses a few NIDs, including nostr-event, nostr-tag, etc ...), while the URN's NSS (a value unique within the namespace) is the event's ID.
  2. The event creation's Epoch timestamp is an integer, with a value of 1743619857.
  3. Its ID is 20df611b4b232d890f874555a20ba89eef6ab744e60a62f6be1566a426d65f73.
  4. The NIP21 address of its author, which is an npub URL, is nostr:npub14249mvyacfcv0fek3qj7dtz6k4w3d8qla29jl706d5xgymjat5fqac46s2
  5. Its content is Hello Nostr.
  6. Its kind, an integer, equals to 1 (which is the event kind for text notes).
  7. The public key of its author is aaaa5db09dc270c7a7368825e6ac5ab55d169c1fea8b2ff9fa6d0c826e5d5d12.
  8. It has a signature

Notice that all predicate URIs in the events are relative to https://w3id.org/nostr#. This URI is the URI prefix representing the nostr schema.

Some metadata

Let's see another event kind: metadata. Metadata events actually carry a stringified JSON payload:

{
  "content": "{\"name\":\"nostra\",\"display_name\":\"Nostralink\",\"about\":\"Linked data for your nostr\",\"nip05\":\"nostra@nostrplebs.com\"}",
  "created_at": 1743637259,
  "id": "1860841a997a7e93bca4b782b0c158d4f3b8ced903be14e4047a4a4aacce4d88",
  "kind": 0,
  "pubkey": "1b7262dc2e0213fa6778777eb5588d063ecf8ce243566fb90991b9e6ec6db316",
  "sig": "cf78e5e157d51f83863442dd20c6f6ecf6d66779f85a49fd346ff5a9a90cf5339c8d31aa6b6c06f5fc54ab0ee85f06e98a88cce49c45a73fb8c5aeea2a99ca37",
  "tags": []
}

nostralink makes the content field be interpreted as JSON-LD. Here's what the metadata event looks like as RDF:

<urn:nostr-event:1860841a997a7e93bca4b782b0c158d4f3b8ced903be14e4047a4a4aacce4d88> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/nostr#Event> ;
  <https://w3id.org/nostr#created_at> "1743637259"^^<http://www.w3.org/2001/XMLSchema#integer> ;
  <https://w3id.org/nostr#id> "1860841a997a7e93bca4b782b0c158d4f3b8ced903be14e4047a4a4aacce4d88" ;
  <https://w3id.org/nostr#nip21> <nostr:npub1rdex9hpwqgfl5emcwalt2kydqclvlr8zgdtxlwgfjxu7dmrdkvtqytd45l> ;
  <https://w3id.org/nostr#content> <urn:nostr-content:f960cd453663c1deb68551d6180fe7c6a4a5ff727704e91ef715c48527a445e2> ;
  <https://w3id.org/nostr#kind> "0"^^<http://www.w3.org/2001/XMLSchema#integer> ;
  <https://w3id.org/nostr#pubkey> "1b7262dc2e0213fa6778777eb5588d063ecf8ce243566fb90991b9e6ec6db316" ;
  <https://w3id.org/nostr#sig> "cf78e5e157d51f83863442dd20c6f6ecf6d66779f85a49fd346ff5a9a90cf5339c8d31aa6b6c06f5fc54ab0ee85f06e98a88cce49c45a73fb8c5aeea2a99ca37" .
<urn:nostr-content:f960cd453663c1deb68551d6180fe7c6a4a5ff727704e91ef715c48527a445e2> <https://w3id.org/nostr#name> "nostra" ;
  <https://w3id.org/nostr#display_name> "Nostralink" ;
  <https://w3id.org/nostr#nip05> "nostra@nostrplebs.com" ;
  <https://w3id.org/nostr#about> "Linked data for your nostr" .

Here we see that:

  • The https://w3id.org/nostr#content predicate, for this event, points to a urn:nostr-content:... URI. This URI represents an object that contains the content attributes of the metadata event: name, display_name, etc ..

  • The nostr-content object contains triples for every field of the content object of the nostr event:

<urn:nostr-content:f960cd453663c1deb68551d6180fe7c6a4a5ff727704e91ef715c48527a445e2> <https://w3id.org/nostr#name> "nostra" ;
  <https://w3id.org/nostr#display_name> "Nostralink" ;
  <https://w3id.org/nostr#nip05> "nostra@nostrplebs.com" ;
  <https://w3id.org/nostr#about> "Linked data for your nostr" .

The metadata SparQL query allows you to retrieve metadata events and their properties.