Activity Streams/Primer/Link type

From W3C Wiki

The Link type is described in detail in the Activity Streams 2.0 core document section 4.2.

Many properties in the Activity Vocabulary have a range of Object | Link.

The description in the AS2 core document covers binary file formats like images, for properties like url, icon or image.

However it's also used for other properties, such as actor or object. As the AS2 Vocabulary document says:

Many of the properties defined by the Activity Vocabulary allow values that are either instances of Object or Link. When a Link is used, it establishes a qualified relation connecting the subject (the containing object) to the resource identified by the href. 

In practice, using a Link for an AS2 property that does not refer to a binary file format (audio, image, video) has the significance that the description of the object is not available in AS2. For example, here is a description of an activity for creating a Tweet:

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Create",
  "to": [{
    "type": "Link",
    "href": "https://twitter.com/dril/verified_followers"
  }, "as:Public"],
  "actor": {
    "type": "Link",
    "href": "https://twitter.com/dril"
  },
  "object": {
    "type": "Link",
    "href": "https://twitter.com/dril/status/384408932061417472"
  }
}

Here, the actor , to and object type are Link objects, because as of this writing in 2024, Twitter does not provide AS2 representations of its users or Tweets.

This kind of usage of Link is not very compatible with ActivityPub, and won't be easily handled by many AP processors. The use of links in AS2 comes from AS1 and earlier, where this type of usage was more common.

Another way to represent this same information is to use AS2 Object types without an ID but with an URL property.

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Create",
  "to": [{
    "type": "Collection",
    "nameMap": { "en": "wint Verified Followers" },
    "url": "https://twitter.com/dril/verified_followers"
  }, "as:Public"],
  "actor": {
    "type": "Person",
    "name": "wint",
    "url": "https://twitter.com/dril"
  },
  "object": {
    "type": "Note",
    "content": "<p>Food $200</p>
<p>Data $150</p>
<p>Rent $800</p>
<p>Candles $3,600</p>
<p>Utility $150</p>
<p>someone who is good at the economy please help me budget this. my family is dying</p>"
    "url": "https://twitter.com/dril/status/384408932061417472"
  }
}

This has the benefit of adding types and specific data like name and content, with the downside of using Object types without an id.


Guidance for publishers

  • Include at least an href property for your Link item.
  • Use Link objects for properties that describe binary file formats, like image, icon.
  • Use Link objects for representing URLs like url, tag.
  • Avoid Link objects for "core" activity properties like actor, object, to, cc for use with ActivityPub, since many implementations will expect an AS2 Object with an id.

Guidance for consumers

  • If you see Link objects for "core" activity properties like actor, object, to, you can treat them as unique by href.
  • It may be possible to use custom or proprietary APIs or scraping to get additional information about the resource at the other end of the Link.

What does qualified mean?

The link is "qualified" either by the property that is used or the "rel" property of the Link.

From the qualified relation definition,

Creating a resource for the relationship allows much more flexibility in qualifying or describing the relationships between resources. Any number of additional properties may be used to annotate the relation. When the relationship is between two resources we refer to it as a qualified relation