Page MenuHomePhabricator

Consume new Talk Page API
Closed, ResolvedPublic

Description

Endpoint calls are split up into sections according to feature functionality:

Read structured threads

GET https://{lang}.wikipedia.org/w/api.php?action=discussiontoolspageinfo&format=json&page={pageTitle}&prop=threaditemshtml&formatversion=2

{pageTitle}User_talk:TSevener_(WMF) or Talk:Cat, for example

Sandbox link: https://test.wikipedia.org/wiki/Special:ApiSandbox#action=discussiontoolspageinfo&format=json&prop=threaditemshtml&formatversion=2

Reference

See https://phabricator.wikimedia.org/T285971

Post new topic

POST https://{lang}.wikipedia.org/w/api.php?action=discussiontoolsedit&format=json&paction=addtopic&page={pageTitle}&token={authToken}&wikitext={topicBodyContent}&sectiontitle={topicTitle}&formatversion=2

{pageTitle}User_talk:TSevener_(WMF) or Talk:Cat, for example
{authToken} → Our network stack should populate this if you lean on the methods in the Fetcher superclass.
{topicBodyContent}Test new reply with ''wikitext''. ~~~~, for example.
{topicTitle}Testing topic title here, for example.

Note topicBodyContent and topicTitle should be url encoded. The methods in the Fetcher superclass should do this for you.

Sandbox link: https://test.wikipedia.org/wiki/Special:ApiSandbox#action=discussiontoolsedit&format=json&paction=addtopic&formatversion=2

Post inline reply

POST https://{lang}.wikipedia.org/w/api.php?action=discussiontoolsedit&format=json&paction=addcomment&page={pageTitle}&token={authToken}&commentid={commentId}&wikitext={replyText}&formatversion=2

{commentId} → This correlates to the "id" thread item value in the Read endpoint. For example, c-TSevener_(WMF)-2022-06-29T20:01:00.000Z-New_topic_title_via_API_again. Note that it only seems to work for "comment" thread item types - do not send it the ID of a "heading" type.
{replyText} → Reply text. Testing reply here ~~~~., for example.

Sandbox link: https://test.wikipedia.org/wiki/Special:ApiSandbox#action=discussiontoolsedit&format=json&paction=addcomment&formatversion=2

Subscribing to a talk page topic

POST(?) https://test.wikipedia.org/w/api.php?action=discussiontoolssubscribe&format=json&page={pageTitle}&token={authToken}&commentname={headerItemName}&subscribe=1&formatversion=2

{headerItemName} → This correlates to the "name" value in the Read endpoint for a header item type. For example, h-TSevener_(WMF)-2022-06-29T20:38:00.000Z.

Sandbox link: https://test.wikipedia.org/wiki/Special:ApiSandbox#action=discussiontoolssubscribe&format=json&subscribe=1&formatversion=2

Unsubscribing to a talk page topic

Just like subscribing, but remove subscribe=1 in the call entirely. This seems strange - we could also try subscribe=0 to be more explicit but unsure if that works.

Getting topic subscription status

GET https://{lang}.wikipedia.org/w/api.php?action=discussiontoolsgetsubscriptions&format=json&commentname={[headerItemName]}&formatversion=2

{[headerItemName]} → This correlates to the "name" value in the Read endpoint for a header item type, multiple names are delimited by |. For example, h-TSevener_(WMF)-2022-06-29T20:38:00.000Z|h-TSevener_(WMF)-2022-06-29T20:01:00.000Z. You will get a response containing the names you are subscribed to, like this:

{
    "subscriptions": {
        "h-TSevener_(WMF)-2022-06-29T20:38:00.000Z": 1
    }
}

Sandbox link: https://test.wikipedia.org/wiki/Special:ApiSandbox#action=discussiontoolsgetsubscriptions&format=json&formatversion=2

Event Timeline

Tsevener updated the task description. (Show Details)

Moving to Ready for PM Signoff - QA will test this functionality when the UI portion is done.