ActivityPub/Primer/Activity Streams 2.0

From W3C Wiki

ActivityPub uses Activity Streams 2.0 ("AS2") as its on-the-wire representation for social networking object.

The AS2 specification has two important parts:

- The core specification which describes the format, special processing rules, and features such as collections and natural-language values - The Activity Vocabulary, which defines a set of dozens of activity types representing activities that often happen in social networks, as well as object types, representing objects that are often found on social networks.

Some of the Activity Streams 2.0 activities have special side-effects in ActivityPub, for example, the Follow or Block activities. Others can be passed through the system verbatim, with little or no side-effects.

AS2 formatting requirements

The AS2 core spec uses JSON-LD, a serialization of RDF data in JSON, as the main encoding mechanism for social network data. Although it is possible to use the AS2 vocabulary with other serializations, like Turtle or RDF/XML, AS2 and ActivityPub require the use of JSON-LD.

Per the AS2 core spec,

The serialized JSON form of an Activity Streams 2.0 document MUST be consistent with what would be produced by the standard JSON-LD 1.0 Processing Algorithms and API [JSON-LD-API] Compaction Algorithm

This means at least the following requirements on ActivityPub objects:

  • UTF-8 character set.
  • No null values (despite the erroneous specification for using null values in the ActivityPub spec)
  • Properties and types in the default AS2 vocabulary must be represented without the full URL or prefix, that is, "Create" instead of "as:Create" or "https://www.w3.org/ns/activitystreams#Create".
  • The collection representing the public must be identified as "as:Public", and not "Public" or "https://www.w3.org/ns/activitystreams#Public".
  • Dates and times are usually represented as YYYY-MM-DDTHH:mm:ssZ, with some variations for timezones and leaving out seconds; see dates and times for optional variations.
  • AS2 documents have an AS2 Object as their root.
  • AS2 documents us the application/activity+json as their Internet media type. This is a shorter alternative of the equivalent application/ld+json; profile="https://www.w3.org/ns/activitystreams".