SnooShift
JavaScript wrapper library for Pushshift with Snoowrap support.
Install
npm i -S snooshift
import { SnooShift } from "snooshift";
const snoo = new SnooShift();
const searchParams = {
author: "eben0",
};
snoo.searchComments(searchParams).then((comments) => {
console.log(comments);
});
snoo.getComment("gof4uys").then((comment) => {
console.log(comment);
});
Searching Submissions
const searchParams = {
author: "eben0",
};
snoo.searchSubmissions(searchParams).then((comments) => {
console.log(comments);
});
Get Single Submission
snoo.searchSubmissions("lrufxe").then((submission) => {
console.log(submission);
});
Interacting with Reddit
You can reply, upvote and interact with reddit using Snoowrap
object.
You must set up your reddit api credentials to do so.
import { SnooShift } from "snooshift";
const credentials = {
userAgent: "put your user-agent string here",
clientId: "put your client id here",
clientSecret: "put your client secret here",
refreshToken: "put your refresh token here",
};
const snoo = new SnooShift(credentials);
snoo.getComment("gof4uys").then((comment) => {
comment.reply("My awesome reply").then(value);
comment.upvote().then(value);
comment.delete().then(value);
});
Querying Elasticsearch
You can directly query the elasticsearch server if you are familiar with syntax.
import { SnooShift } from "snooshift";
const snoo = new SnooShift();
const query = {
query: {
term: { author: "eben0" },
},
sort: {
created_utc: "desc",
}
};
snoo.elasticComments(query).then((result) => {
console.log(result.hits.hits[0]._source);
});
snoo.elasticSubmissions(query).then((result) => {
console.log(result.hits.hits[0]._source);
});