Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reddit-api-image-getter

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reddit-api-image-getter

Gets images of a Subreddit and can optionally save them.

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-25%
Maintainers
0
Weekly downloads
 
Created
Source

Reddit API Image Getter

Install

npm i reddit-api-image-getter --save

Open Source

Check out the source code on GitHub and dig in a little for yourself.

Example

// example
const path = require('path')
redditApiImageGetter = require('reddit-api-image-getter')

getter = new redditApiImageGetter()

// `getHotImagesOfSubReddit('subreddit')`
// returns a Promise, that, when successful returns
// an Array containing RedditImageEntry object instances.
// 
// Each RedditImageEntry object is then passed to
// `saveRedditImageEntryToDisk(imageEntry, path)`
// to be saved to disk. 
//
// See what each RedditImageEntry does in 
// lib/classes/RedditImageEntry.js and lib/classes/RedditEntry.js
//
// get the top images of a subreddit: using
// getTopImagesOfSubReddit(subreddit = 'ProgrammerHumor')
// 
getter.getHotImagesOfSubReddit('ProgrammerHumor').then(function (result) {
  for (imageEntry of result) {
    const targetDirectory = path.resolve(__dirname, 'images', 'hot');
    getter.saveRedditImageEntryToDisk(imageEntry, targetDirectory);
  }
}).catch(function (error) {
  console.log(error)
})

getter.getTopImagesOfSubReddit('ProgrammerHumor').then(function (result) {
  for (imageEntry of result) {
    // do begin with a starting '/' if you need to: 
    // https://nodejs.org/api/path.html#path_path_resolve_paths
    const targetDirectory = path.resolve(__dirname, 'images', 'top');
    getter.saveRedditImageEntryToDisk(imageEntry, targetDirectory);
  }
}).catch(function (error) {
  console.log(error)
})

Example with Telegram Bot

https://www.simon-neutert.de/2020/telegraf-bot-nodejs/

Inspiration

go crazy, send the pictures to your telegram via a bot (using a bot) and make your day a happy day :tada:

Keywords

FAQs

Package last updated on 24 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc