Hey folks! Today I'm proud to announce the official utopian.io api npm package:
utopian-api <<
This package is intended to make it easier to interact with the utopian.io api. As for now you can:
get a list of all moderators and sponsors
check if a username is an enabled, not banned moderator on the utopian platform
get utopian posts, filtering and paging is available. See below for an example
get pending posts count
get total posts count
get pending posts by moderator
get pending posts by moderator and category
get all pending posts
Installation
If you already created a package.json file simply run npm i utopian-api --saveto install this package. Otherwise run npm init and follow the instructions on the screen. After completing the package.json generatiopn install the package as mentioned earlier.
Examples
Get all moderators and log their names:
let utopian = require('utopian-api');
utopian.getModerators().then((moderators) => {
for (i = 0; i < moderators.results.length; i++) {
console.log(moderators.results[i].account)
}
});
Get all sponsors and log their names:
let utopian = require('utopian-api');
utopian.getSponsors().then((sponsors) => {
for (i = 0; i < sponsors.results.length; i++) {
console.log(sponsors.results[i].account)
}
});
Check wether a user is a utopian.io mod:
let utopian = require('./api');
utopian.getModerator("wehmoen").then((result) => {
console.log(result);
}); // returns [{_id: '5a4bf....}]
utopian.getModerator("ned").then((result) => {
console.log(result);
}); //returns []
Get posts for the development category:
let utopian = require('utopian-api');
utopian.getPosts({
sortBy: 'created',
type: 'development'
}).then((posts) => {
console.log(posts.results); //get the first 50 posts
});
utopian.getPosts({
sortBy: 'created',
type: 'development',
skip: 50
}).then((posts) => {
console.log(posts.results); //get the next 50 posts
});
Limit the number of results:
let utopian = require('utopian-api');
utopian.getPosts({
sortBy: 'created',
type: 'development',
limit: 5
}).then((posts) => {
console.log(posts.results); //get the first 5 posts
});
Get pending posts count:
let utopian = require('utopian-api');
utopian.getPendingPostsCount().then((count) => {
console.log("There are " + count + " pending posts.");
})
Get total posts count:
let utopian = require('utopian-api');
utopian.getTotalPostsCount().then((count) => {
console.log("There are " + count + " posts on utopian.io. AMAZING!");
})
Contribution
I would really appreciate it if we could work on this package together. To start coding create a fork of our github repository. After you made some changes feel free to create a pull request. An utopian developer will review your changes and hopefully merge them to improve this package.
Implementation
An example of implentation can be found in my github repository for utopian.reviews. I use the npm package to determine wether the user just logged in with steem connect is an utopian mod or not.
Posted on Utopian.io - Rewarding Open Source Contributors
Posted on Utopian.io - Rewarding Open Source Contributors
Your contribution cannot be approved because it does not follow the Utopian Rules, and is considered as plagiarism. Plagiarism is not allowed on Utopian, and posts that engage in plagiarism will be flagged and hidden forever.
Original post
You can contact us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
sorry i will not do it again
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
sorry i will not do it again
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit