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

redddit

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redddit - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

LICENSE

52

index.js

@@ -28,4 +28,9 @@ const needle = require('needle');

if (!post) {
console.error("post param required");
return false;
var err = {
"err": {
"message": "Post parameter required.",
"code": "noParam"
}
}
return cb(err, null);
}

@@ -57,4 +62,9 @@ var opt = { headers: {

if (!query) {
console.error("query param required");
return false;
var err = {
"err": {
"message": "Query parameter required.",
"code": "noParam"
}
}
return cb(err, null);
}

@@ -79,2 +89,36 @@ var opt = { headers: {

})
}
exports.getURL = (url, param, cb) => {
if (!url) {
var err = {
"err": {
"message": "Query parameter required.",
"code": "noParam"
}
}
return cb(err, null);
}
if (!cb) {
var cb = param;
var param = "";
}
var opt = { headers: {
"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Encoding":"gzip, deflate, br",
"Connection":"keep-alive",
"DNT":"1",
"Host":"www.reddit.com",
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0",
}}
needle.get("https://reddit.com" + url + ".json" + param,opt,async function(err,resp,body) {
if (err) {
var body = null;
cb(err,body);
} else {
var err = null;
var res = body.data.children;
cb(err,res)
}
})
}

4

package.json
{
"name": "redddit",
"version": "1.0.2",
"version": "1.1.0",
"description": "reddit api without any authentication!",

@@ -18,3 +18,3 @@ "main": "index.js",

"author": "n0rmancodes",
"license": "ISC",
"license": "UNLICENSED",
"bugs": {

@@ -21,0 +21,0 @@ "url": "https://github.com/n0rmancodes/redddit/issues"

# redddit
Simple Reddit API, no authentication needed!
## sample code
```js
const redddit = require('./index.js');
redddit.topPosts("videos",function(err,res){
if (err !== null) {
console.log(err.code)
} else {
var post = res[0].data.permalink;
redddit.getPost(post, function(err,res) {
console.log(res.comments)
})
}
});
```
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