Disqus

Disqus

Social

Communicate with Disqus data. The internet's favorite comment plug-in makes it easy for publishers to bring their content to life, fuel colorful discussions, efficiently moderate comments, and build engaged communities. Convert casual readers into regular contributors. Disqus helps publishers capture readers and keep them coming back for more with robust sign-in options, cross-site notifications and more. Audience Analytics provide actionable audience insights, helping publishers to understand their audience, monitor engagement, and optimize content strategy. Turn engagement into revenue with new inventory through Disqus and highly configurable ad serving from top demand partners on your site.

Visit API

📚 Documentation & Examples

Everything you need to integrate with Disqus

🚀 Quick Start Examples

Disqus Javascript Examplejavascript
// Disqus API Example
const response = await fetch('https://disqus.com/api/docs/auth/', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/json'
    }
});

const data = await response.json();
console.log(data);

Introduction to Disqus API

Disqus API provides programmatic access to the Disqus comments platform. The authentication process is required to access the API and generate an access token which can be used to make requests to the API.

In this article, we will cover the authentication process and provide examples of using Disqus API using JavaScript.

Authentication

To use the Disqus API, you need to authenticate yourself by obtaining an access token. To get the access token, follow these steps:

  1. Create a Disqus account if you don't have one already.
  2. Log in to your Disqus account.
  3. Go to the applications page.
  4. Click on the "Create New Application" button.
  5. Fill in the form with the necessary information (e.g., the name of your application, the category, the description, etc.).
  6. Click the "Create Application" button.
  7. Click on the "Details" link to view the details of the application.
  8. The "Public Key" and "Secret Key" will be listed on that page. You will need to use these keys to generate a token.

Here is an example of how to generate an access token using JavaScript:

var public_key = 'your_public_key';
var secret_key = 'your_secret_key';

var url = 'https://disqus.com/api/oauth/2.0/access_token/';

var xhr = new XMLHttpRequest();
xhr.open('POST', url);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function() {
  if (xhr.status === 200) {
    var response = JSON.parse(xhr.responseText);
    var access_token = response.access_token;
    console.log('Access Token:', access_token);
  } else {
    console.log('Error:', xhr.statusText);
  }
};
xhr.send('grant_type=client_credentials&client_id=' + public_key + '&client_secret=' + secret_key);

Disqus API Examples

Once you have generated an access token, you can start using the Disqus API. Here are some examples:

List Forums

var access_token = 'your_access_token';

var url = 'https://disqus.com/api/3.0/forums/list.json?access_token=' + access_token;

var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onload = function() {
  if (xhr.status === 200) {
    var response = JSON.parse(xhr.responseText);
    console.log('Forums:', response.response);
  } else {
    console.log('Error:', xhr.statusText);
  }
};
xhr.send();

Update Forum

var access_token = 'your_access_token';
var forum_id = 'your_forum_id';
var forum_name = 'new_forum_name';

var url = 'https://disqus.com/api/3.0/forums/update.json?access_token=' + access_token +
          '&forum=' + forum_id + '&name=' + forum_name;

var xhr = new XMLHttpRequest();
xhr.open('POST', url);
xhr.onload = function() {
  if (xhr.status === 200) {
    var response = JSON.parse(xhr.responseText);
    console.log('Forum Updated:', response.response);
  } else {
    console.log('Error:', xhr.statusText);
  }
};
xhr.send();

Create Category

var access_token = 'your_access_token';
var forum_id = 'your_forum_id';
var category_name = 'new_category';

var url = 'https://disqus.com/api/3.0/categories/create.json?access_token=' + access_token +
          '&forum=' + forum_id + '&title=' + category_name;

var xhr = new XMLHttpRequest();
xhr.open('POST', url);
xhr.onload = function() {
  if (xhr.status === 200) {
    var response = JSON.parse(xhr.responseText);
    console.log('Category Created:', response.response);
  } else {
    console.log('Error:', xhr.statusText);
  }
};
xhr.send();

Conclusion

In this article, we have covered the authentication process and provided examples of using Disqus API using JavaScript. By using the Disqus API, you can programmatically access the Disqus comments platform and perform various tasks such as creating forums, updating forums, and creating categories.

📊 30-Day Uptime History

Daily uptime tracking showing online vs offline minutes

May 27May 29May 31Jun 2Jun 4Jun 6Jun 8Jun 10Jun 12Jun 14Jun 16Jun 18Jun 20Jun 22Jun 2504008001440Minutes
Online
Offline

Related APIs in Social