ActivityStreams context document

Where can I find the JSON-LD context document for ActivityStreams? So far I’ve just been able to find this one on GitHub, but I need a URL to link to under the @context field. It doesn’t seem to be available at ActivityStreams 2.0 Terms.

Also, I noticed that new users can only post two links per post here. I imagine it’s meant to reduce spam, but it means I couldn’t provide all the relevant links for my question.

The document URL I’m looking for is analogous to this one for credentials.

Would that be https://www.w3.org/ns/activitystreams.jsonld https://www.w3.org/ns/activitystreams?

EDIT: As @nightpool corrected below, the above .jsonld URI should not be used (hence it was changed according to the below quoted remark.

That’s it, thanks!

Apparently my post has to be at least 20 characters, so I couldn’t write just that. What’s with all these rules?

These rules are to encourage long form discussion. Short form can usually go with a :heart:. Cheers!

note that you shouldn’t include the .jsonld at the end when linking the context in an ActivityStreams document, see https://www.w3.org/TR/activitystreams-core/ for more details. the normative context url is https://www.w3.org/ns/activitystreams, as per the spec

2 Likes

Not something worth worrying about, but I would consider this an anti pattern at best, and a bug in the spec at worst

The .jsonld extension will normally give back the correct mime type

The context should give back JSON(-LD)

If it returns other things then they should all give back the same machine readable data, which they dont

But, not something worth making a fuss over …

This is all very confusing in the end.

1 Like

As a newcomer to these standards, I find this very confusing, and I’m still unsure how to use them correctly. I’m trying to use jsonld-signatures to sign an ActivityStreams document, but it only works if I add .jsonld to the @context URL.

Use this:

https://www.w3.org/ns/activitystreams

As I said, the jsonld-signatures library only works when I add .jsonld to the URL in the @context field. I’ve posted an issue to find out whether that’s intended behavior.

1 Like

The context gives back JSON-LD if you use the correct Accept: application/ld+json mime type. Providing different representations for the same resources is a fundamental part of HTTP (content-negotiation).

I would consider this a bug in the jsonld-signatures library, it seems like it’s either not using the correct Accept header or not interpreting the results correctly.

Here’s an example of making the request with the correct Accept header:

$ curl -H "Accept: application/ld+json" https://www.w3.org/ns/activitystreams
{
  "@context": {
    "@vocab": "_:",
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "as": "https://www.w3.org/ns/activitystreams#",
    "ldp": "http://www.w3.org/ns/ldp#",
    "vcard": "http://www.w3.org/2006/vcard/ns#",
    "id": "@id",
    "type": "@type",
    "Accept": "as:Accept",
    "Activity": "as:Activity",
    "IntransitiveActivity": "as:IntransitiveActivity",
    "Add": "as:Add",
    "Announce": "as:Announce",
    "Application": "as:Application",
    "Arrive": "as:Arrive",
    "Article": "as:Article",
    "Audio": "as:Audio",
    "Block": "as:Block",
    "Collection": "as:Collection",
    "CollectionPage": "as:CollectionPage",
    "Relationship": "as:Relationship",
    "Create": "as:Create",
    "Delete": "as:Delete",
    "Dislike": "as:Dislike",
    "Document": "as:Document",
    "Event": "as:Event",
    "Follow": "as:Follow",
    "Flag": "as:Flag",
    "Group": "as:Group",
    "Ignore": "as:Ignore",
    "Image": "as:Image",
    "Invite": "as:Invite",
    "Join": "as:Join",
    "Leave": "as:Leave",
    "Like": "as:Like",
    "Link": "as:Link",
    "Mention": "as:Mention",
    "Note": "as:Note",
    ....
3 Likes

The context gives back JSON-LD if you use the correct Accept: application/ld+json mime type. Providing different representations for the same resources is a fundamental part of HTTP (content-negotiation).

Agree! This is a minor point, but if you provide two representations and one gives machine readable data, the other one should too. Because a consuming app associates data with a URI, and not, a URI+mime type. So the HTML form is actually a bug, which could be fixed by adding JSON in a SCRIPT tag, which is the so-called “structured data island” approach popularized by schema.org

I dont think it’s something that anyone worries about. But machines can get confused from time to time, because of it.

If it causes errors and confusion, I think it’s certainly worth sorting out.

I was able to resolve the error by using the library correctly. It turns out I had added .jsonld to the URL in the document loader, and it works without that extension. Here is my working example of signing an ActivityStreams document for anyone who is interested.