I'm working on putting the communication with the Stack Exchange websockets inside a .NET library so as a way of sharing the research, here are the layouts of the JSON responses.
Note that they don't always work on all sites. For example 1
(Stack Overflow) does not respond to questions-active
but 155
(all sites) does.
Last note: the data
field is always in a string representation as has been noted above. Don't forget to pull it through your JSON parser again (in the samples below I replaced \"
with "
so it would be more readable).
155-questions-active
{
"action" : "155-questions-active",
"data" : "{
"siteBaseHostAddress" : "biology.stackexchange.com",
"id" : 17647,
"titleEncodedFancy" : "Meaning of “auto” in trans autophosphorylation?",
"bodySummary" : "why this process called Auto? <body> ...",
"tags" : ["cell-signaling"],
"lastActivityDate" : 1401048843,
"url" : "http://biology.stackexchange.com/questions/17647/meaning-of-auto-in-trans-autophosphorylation",
"ownerUrl" : "http://biology.stackexchange.com/users/6524/n00b",
"ownerDisplayName" : "N00B",
"apiSiteParameter" : "biology\
"}"
}
<siteId>-questions-active
<siteId>-questions-newest
<siteId>-questions-newest-tag-<tag>
Note that tag
has to be lowercase to work. This response is very ugly: it is littered with HTML inside the body
field so the use of it is very limited. The response is the same for all three endpoints (although, once more, some sites like Stack Overflow only work with the latter of the three).
{
"action" : "1-questions-newest-tag-java",
"data" : "{
"id" : "23859640",
"body" : "<div class=\\"question-summary\\" id=\\"question-summary-23859640\\">\\r\\n <snipped a whole lot of html tags>",
"tags" : ["java","jfreechart"],
"siteid" : 1,
"fetch" : false
}"
}
<siteId>-question-<questionId>
This one will return several different JSON's, depending on the activity that occurs at question in question.
I have not been able to observe all events yet but so far I believe no events are raised for these actions:
- Closing the question
- Deleting a comment
- Editing a comment
- Deleting an answer
- Voting to close
- Voting to delete (educated guess)
- Upvoting a comment
- Flagging (educated guess)
Post edit
{
"action" : "1-question-23851409",
"data" :"{
"a" : "post-edit",
"id" : 23851409,
"acctid" : 2095246
}"
}
Comment add
{
"action" : "1-question-23851409",
"data" : "{
"a" : "comment-add",
"id" : 23851409,
"commentid" : 36706586,
"acctid" : 4507832
}"
}
Score change
Note: the score
is the netto result score (so not just -1
and +1
).
{
"action" : "1-question-23851323",
"data" : "{
"a" : "score",
"id" : 23851382,
"score" : 1
}"
}
Answer add
{
"action" : "1-question-23851323",
"data" : "{
"a" : "answer-add",
"id" : 23851323,
"answerid" : 23851831,
"acctid" : 1319955
}"
}
Answer accept
{
"action" : "1-question-23855163",
"data" : "{
"a" : "accept",
"id" : 23855163,
"answerid" : 23855182,
"acctid" : 4520031
}"
}
Answer unaccept
{
"action" : "1-question-23855163",
"data" : "{
"a" : "unaccept",
"id" : 23855163,
"answerid" : 23855182,
"acctid" : 4520031
}"
}
<siteId>-review-dashboard-update
{
"action" : "1-review-dashboard-update",
"data" : "{
"i" : 5,
"u" : 3305005,
"html" : "<a href=\\"/users/3305005/dr-jukka\\"> snipped tags"
}"
}
Review types:
1 - Suggested edits
2 - Close votes
3 - Low Quality posts
4 - First posts
5 - Late answers
6 - Reopen