Skip to main content

ActivityPub Overview

ActivityPub is a W3C Recommendation that defines a protocol for decentralized social networking. It provides both a client-to-server (C2S) API and a server-to-server (S2S) federation protocol.

Specification

Two Protocols in One

ActivityPub defines two complementary protocols:

ActivityPubClient-to-Server (C2S)• User posts via app• Read inbox/outbox• Manage following• Like, share, replyServer-to-Server (S2S)• Server delivers to followers• Receive activities from others• Handle federation• Process remote activities

Client-to-Server (C2S)

The C2S protocol defines how clients (apps) interact with servers:

  • POST to Outbox: Submit activities the user wants to perform
  • GET from Inbox: Read activities sent to the user
  • GET from Collections: Read followers, following, likes
note

Most Fediverse software implements a custom REST API instead of C2S. The S2S protocol is universally implemented.

Server-to-Server (S2S)

The S2S protocol defines how servers federate:

  • POST to Inbox: Deliver activities to remote users
  • GET Actor: Fetch remote user profiles
  • GET Objects: Fetch remote content

Core Components

1. Actors

Every user or entity is represented as an Actor with:

{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Person",
"id": "https://example.com/users/alice",
"inbox": "https://example.com/users/alice/inbox",
"outbox": "https://example.com/users/alice/outbox",
"preferredUsername": "alice"
}

Learn more about Actors →

2. Activities

Actions are represented as Activity objects:

{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Create",
"actor": "https://example.com/users/alice",
"object": {
"type": "Note",
"content": "Hello, world!"
}
}

Learn more about Activities →

3. Objects

Content is represented as Objects:

{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Note",
"id": "https://example.com/notes/1",
"content": "Hello, world!",
"attributedTo": "https://example.com/users/alice"
}

Learn more about Objects →

4. Collections

Lists of items are represented as Collections:

{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "OrderedCollection",
"id": "https://example.com/users/alice/outbox",
"totalItems": 42,
"first": "https://example.com/users/alice/outbox?page=1"
}

Learn more about Collections →

Required Endpoints

For All Actors

EndpointMethodDescription
Actor URLGETReturns the actor's profile
InboxPOSTReceives activities from other servers
OutboxGETReturns activities by this actor

For C2S (Optional)

EndpointMethodDescription
OutboxPOSTClient submits new activities
InboxGETClient reads incoming activities

Content Negotiation

ActivityPub uses content negotiation. Clients should:

Request:

GET /users/alice HTTP/1.1
Accept: application/activity+json

Response:

HTTP/1.1 200 OK
Content-Type: application/activity+json

{ ... actor JSON ... }

Accepted media types:

  • application/activity+json
  • application/ld+json; profile="https://www.w3.org/ns/activitystreams"

Addressing

Activities specify recipients using:

PropertyPurpose
toPrimary recipients (visible)
ccSecondary recipients (visible)
btoPrivate primary recipients
bccPrivate secondary recipients
audienceAdditional context

Special addresses:

  • https://www.w3.org/ns/activitystreams#Public - Public visibility

Security

ActivityPub relies on:

  1. HTTPS - All URLs must use HTTPS
  2. HTTP Signatures - Verify request authenticity
  3. Linked Data Signatures - (Optional) Sign objects themselves

Learn more about Security →

Relationship to Other Specs

ActivityPub(Federation Protocol)ActivityStreams 2.0(Data Vocabulary)WebFinger(Discovery)HTTP Signatures(Authentication)JSON-LD(Linked Data)

Common Extensions

The Fediverse has developed de facto extensions:

ExtensionPurposeUsed By
sensitiveContent warningsMastodon
EmojiCustom emojiMastodon, Misskey
PropertyValueProfile fieldsMastodon
IdentityProofIdentity verificationKeyoxide
HashtagHashtag typeMost platforms

Implementation Status

PlatformC2SS2S
Mastodon
Pleroma
Pixelfed
Lemmy
PeerTube

Next Steps