Chapter 2. Activity Streams 2.0

Activity Streams 2.0 (AS2) is an essential ingredient of programming for the social web; it is the common data format that all social web applications and services use when communicating with one another. It defines structures that represent common web content types and the activities we perform on them.

This chapter covers how AS2 is structured, what types of data it can represent, and how the standard properties of those data types describe digital and real-world objects.

The First Steps

AS2 is based on JavaScript Object Notation (JSON), pronounced JAY-son or jay-SAWN, depending on who’s saying it and whether someone named Jason is in the room with them. JSON is the most popular data-interchange format on the internet as of this writing in mid-2024. Douglas Crockford defined it in 2002 as a subset of the programming language JavaScript, specifically selected to represent tree-like structured objects. JSON became a formal standard with the publication of request for comment (RFC) 8259 in 2017.

If you’re not familiar with JSON, here’s a crash course in the format. A JSON file, or document, usually looks something like this:

{
  "propertyA": "value1",
  "propertyB": 3,
  "propertyC": [4, 8, 15, 16, 23, 42],
  "propertyD": {
    "propertyE": "value2"
  }
}

The curly braces { and } delimit a JSON object—that is, a structure with named key-value pairs. Each property has a name, like propertyA, which has to be in double quotation marks. The property also has ...

Get ActivityPub now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.