Postman Tutorial: Disqus REST API #3

Postman: Disqus API Case Study (3) – Create/Update/Remove Thread

In this article, we will continue to explore the Disqus REST API with Postman. This time focuses on studying the authenticated API POST services, such as create, update, and remove a discussion thread. The following exercises will require a Disqus API access token. If you don’t know how to get the access token using OAuth 2.0, please go back to read the article Disqus API Case Study (2).


Exercise 1- Create a new Disqus thread

threads/create

Documentation: https://disqus.com/api/docs/threads/create/

The threads/create endpoint is to add a new discussion thread to a specific forum. If your website installs with Disqus code or plug-in, once Disqus detects a new post, it will automatically create a discussion thread. So, where can it be used?

I think you can make use of it to migrate comments to Disqus. You may also use it to set up off-site discussions, which aid to branch off the subtopics from their main thread.

The threads/create endpoint requires the following parameters:

MethodPOST
URLhttps://disqus.com/api/3.0/threads/create.json
AuthorizationOAuth 2.0 (Request Headers)
Refer to Disqus API Case Study (2)
api_key{{api_key}}
The Public Key stored in your environment
forumA Disqus Shortname
titleThe name to describe the new Disqus thread

Make sure that you select the right environment to apply the environment variable. The request query should look like the screenshot below.

Postman: Disqus API Case Study (3) - Create/Update/Remove Thread 1

Response

JSON

Find and note down the thread id in the JSON-formatted API response. It will be used in the requests for thread update and removal. To confirm the new Disqus discussion, open the link URL in your browser and you should visit a Disqus webpage like the screenshot below.

Postman: Disqus API Case Study (3) - Create/Update/Remove Thread 2

[ Back to Top ]


Exercise 2- Updates information on a Disqus thread

threads/update

Documentation: https://disqus.com/api/docs/threads/update/

The threads/update API endpoint is one of the suggested methods to update discussion URLs by the Disqus Help Desk. It can be also employed to change a post’s title appearing in Disqus Recommendations.

For instance, we want to change the title and link of the thread created in Excercise 1. Set up the request using the data in the first five rows of the below table. Then, append the last three optional parameters to assign the new title and link URL to the specific thread.

MethodPOST
URLhttps://disqus.com/api/3.0/threads/update.json
AuthorizationOAuth 2.0 (Request Headers)
Refer to Disqus API Case Study (2)
api_key{{api_key}}
The Public Key stored in your environment
threadA Disqus Thread ID
title
optional
e.g. Hello World!!
Maximum length of 200
url
optional
e.g. https://disqus.com/home/discussion/craftweeks/hello_world-2/
An URL (defined by RFC 3986, Maximum length of 500)
slug
optional
e.g. hello_world-2
Alpha-numeric slug (Maximum length of 200)

Hint: To query the thread, we must know its ID. If you forget the value, please try to recall it by using the methods described in the article Disqus API case study (1).

Make sure that you select the right environment to apply the environment variable. The request query should look like the screenshot below.

Postman: Disqus API Case Study (3) - Create/Update/Remove Thread 3
Response
JSON

Wait for a while, reload the page in your browser. Disqus will indicate the original page doesn’t exist. Enter the new URL to the address bar, you should visit the discussion page with the updated title.

Postman: Disqus API Case Study (3) - Create/Update/Remove Thread 4

[ Back to Top ]


Exercise 3 – Delete a Disqus thread

threads/remove

Documentation: https://disqus.com/api/docs/threads/remove/

After exploring the above API services, you may want to delete the test thread. You can now set up a request to the threads/remove endpoint with the following parameters:

MethodPOST
URLhttps://disqus.com/api/3.0/threads/remove.json
AuthorizationOAuth 2.0 (Request Headers)
Refer to Disqus API Case Study (2)
api_key{{api_key}}
The Public Key stored in your environment
threadA Disqus Thread ID

Make sure that you select the right environment to apply the environment variable. The request query should look like the screenshot below.

Postman: Disqus API Case Study (3) - Create/Update/Remove Thread 5
Response
JSON

Wait for a while, reload the page in your browser. Disqus will indicate the page is no longer existing.

Postman: Disqus API Case Study (3) - Create/Update/Remove Thread 6

[ Back to Top ]


Verify your results using online Discussion Editor

Postman: Disqus API Case Study (3) - Create/Update/Remove Thread 7

The Discussions Editor allows you to 1-click update attributes of any discussion on your site. For example, you might update the title or link associated with a discussion after updating it on your site itself.

What attributes can be updated?

Currently the following discussion attributes are included for updating:

  • Title: appears publicly.
  • Link: appears publicly.
  • Author: does not appear publicly. Update this when you want a non-moderator on your Disqus forum to be considered the author for the discussion. This allows them to moderate comments on that discussion both via Disqus notification emails and inline in the commenting embed.
  • Category: does not appear publicly. Categories are primarily used with Disqus API for results filtering. Learn more about categories.
  • Open/closed status: open or close a discussion to new comments.

If you like this post, please share it with your Facebook and Twitter. You might also support me by donating via Ko-fi.

scroll to top