Options
All
  • Public
  • Public/Protected
  • All
Menu

snoots

Snoots @ v1.0.0-dev.3

Welcome to the snoots documentation!

Helpful links:


Getting Started

User Bots

To get started making a bot with snoots:

  1. Create an application
  2. Come up with a user agent. See here for more info.
  3. Create a new Client instance.
    const client = new Client({
      userAgent: "<the user agent>",
      creds: {
        clientId: "<the client id>",
        clientSecret: "<the client secret>",
      },
      auth: {
        username: "<the reddit account username>",
        password: "<the reddit account password>",
      },
    });
    
  4. Use the api! If you need some help, check out the examples.

Crawler / Scraper

If you just want to retreive information from the Reddit api without controlling a user account you can do that!

  1. Create an application1
  2. Come up with a user agent. See here for more info
  3. Create a new Client instance.
    const client = new Client({
      userAgent: "<the user agent>",
      creds: {
        clientId: "<the client id>",
        clientSecret: "<the client secret>",
      },
    });
    
  4. Use the api! If you need some help, check out the examples.

1 If you really don't want to make an application you can skip this step and leave off the creds parameter, but note that performing requests without an application means you have a much lower ratelimit.

Examples

Print a comment tree to stdout.

async function printChain(c: Comment, indent: string = "") {
  const body = c.body.replace(/\n/g, "\n" + indent);
  console.log(`${indent}(${c.id}) ${c.author}: ${body}`);
  await c.replies.each(r => printChain(r, indent + "  "));
}

(async () => {
  const comment = await client.comments.fetch("gqe92yr");
  await printChain(comment);
})();

More examples will come as snoots evolves!

Generated using TypeDoc