1.1.1 • Published 7 years ago
4chanapi.js v1.1.1
#install
The usual.
npm install --save 4chanapi.js
#usage
There are two functions exported, one to grab the threads on a particular board that match any of an array of keywords, and one that returns the media links for a given thread. This is done via promises or async/await.
#example
let chan = require('4chanapi.js')
async function testIt() {
let threads = await chan.threadsWithTopics("v", ["rpg", "metal gear"])
console.log(threads)
let results = await chan.threadMediaLinks(threads[0].url)
console.log(results)
}
testIt()
In the above example threads
would be an array of objects like this:
The url
is the url of the json api endpoint for that thread, as used by the other function. The semantic_url
is the slugified thread title, suitable for use as a folder name. The output of results
is an array of simple string values representing the pictures/webms in the thread.
[ 'https://i.4cdn.org/v/123.png' ]
There's no function provided to actually download the images, that's up to you.