README
Disqus Server Client - Strongly Typed
Strongly typed client that helps your server to connect to the Disqus API.
Features
The Disqus API - although not very documented - is very easy to implement. This implementation has a view advantages:
- Implemented using TypeScript, so we have types and you have auto-complete
- Uses Axios which gives use
Promises
, so you can useasync
andawait
- Uses Node Cache to cache some endpoints, so your performance is better.
- All end points were generated from the Disqus API docs, so you don't have to look them up.
- Forward compatible. If Disqus creates new end points, you can still use them by calling the
post
,get
or therequest
method.
Drawbacks from this method:
- Not all end points are documented.
- Not all end points have examples, so we could not generate all return typed.
API
Let's show some code.
New up a client:
// Node.js
const { Disqus } = require("disqus-server-client")
// Or TypeScript:
import { Disqus } from 'disqus-server-client'
const config = {
accessToken: "...",
apiKey: "...",
apiSecret: "..."
}
const disqus = new Disqus(config)
Getting the posts:
const r = await disqus.post.list({ forum: "keestalkstech" })
const posts = r.response.map(post => ({
msg: post.msg,
by: post.author.name || post.author.username,
thread: post.thread
}))
console.log(posts);
Getting the details of a thread:
const id = "...";
const r = await disqus.threads.details({ thread: id })
const thread = {
title: r.response.title,
url: r.response.link,
};
console.log(title);
Maintenance
This project is maintained by Kees C. Bakker.