Skip to content

debil03311/dangeru-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dangeru.js

An asynchronous JavaScript API wrapper for the danger/u/ textboard.

Example usage

Import the module

const dangeru = require("dangeru-js");

Get the available boards

NOTE: This data is scraped from the front page since the API doesn't provide the full board names

const boards = await dangeru.getBoards();
[
  {
    short: "a",
    long: "Anime & Manga"
  },
  ...boards
]

Get threads from the third page of the Technology (/tech/) board. The page index can be omitted and defaults to 0.

const threads = await dangeru.getThreads("tech", 2);
[
  {...threadObject},
  ...threads
]

Get the replies to thread no. 376318

const replies = await dangeru.getReplies(376318);
[
  {...replyObject},
  ...replies
]

Get the amount of pages that the /u/ board has

NOTE: This data is scraped from the given board's web page (dangeru.us/u in this case) since it's not provided by the API

const threads = await dangeru.getPageCount("u");
5

Get the front page statistics

NOTE: This data is scraped from the front page since it's not provided by the API

const stats = await dangeru.getStats();
{
  threads: {
    active: 294,
    archived: 96801,
  },
  replies: {
    active: 8281,
    archived: 698258,
  },
  burgs: {
    normal: 51937,
    angry: 53127,
  }
}

Get the front page news announcement

WARNING: This may break if the date format in the announcement changes in the future

const news = await dangeru.getNews();
{
  announcement: "Song-chan's in trouble! If you can spare it, please help: https://dangeru.us/u/thread/828545",
  dateRaw: "18/02/22",
  date: Fri Feb 18 2022 00:00:00 GMT+0200 (Eastern European Summer Time)
}