reddit-wrapper-v2
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -30,3 +30,2 @@ const request = require('request'); | ||
// DISABLED FOR NOW. CAUSING ERRORS WHEN USED WITH RETRY ON WAIT. | ||
// Retry on reddit server error | ||
@@ -33,0 +32,0 @@ // If this parameter is present, then the server will retry on a reddit server error. You can also specify the retry wait duration. |
{ | ||
"name": "reddit-wrapper-v2", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Simple Reddit API framework for nodejs. Replacing the no longer updated reddit-snooper. Relying more on promises rather than callbacks. Nicely handles multiple reddit errors.", | ||
@@ -5,0 +5,0 @@ "main": "reddit-wrapper.js", |
@@ -17,13 +17,14 @@ | ||
``` js | ||
reddit.api.get("/subreddits/mine/subscriber", { | ||
limit: 2, | ||
}) | ||
.then(function(response) { | ||
let responseCode = response[0]; | ||
let responseData = response[1]; | ||
reddit.api.get("/subreddits/mine/subscriber", { | ||
limit: 2, | ||
}) | ||
.then(function(response) { | ||
let responseCode = response[0]; | ||
let responseData = response[1]; | ||
console.log("Received response (" + responseCode + "): ", responseData); | ||
}) | ||
.catch(function(err) { | ||
}); | ||
console.log("Received response (" + responseCode + "): ", responseData); | ||
}) | ||
.catch(function(err) { | ||
console.log("Reddit Error: ", err); | ||
}); | ||
``` | ||
@@ -37,3 +38,3 @@ | ||
## Setup and Configuration | ||
### Installing reddit-snooper | ||
### Installing reddit-wrapper-v2 | ||
``` bash | ||
@@ -45,17 +46,16 @@ npm install reddit-wrapper-v2 --save | ||
``` js | ||
var RedditAPI = require('reddit-wrapper'); | ||
var RedditAPI = require('reddit-wrapper-v2'); | ||
var redditConn = new RedditAPI( | ||
{ | ||
// Options for Reddit Wrapper | ||
username: 'reddit_username', | ||
password: 'reddit password', | ||
app_id: 'reddit api app id', | ||
api_secret: 'reddit api secret', | ||
user_agent: 'user agent for your bot', | ||
retry_on_wait: true, | ||
retry_on_server_error: 5, | ||
retry_delay: 1, | ||
logs: true | ||
}) | ||
var redditConn = new RedditAPI({ | ||
// Options for Reddit Wrapper | ||
username: 'reddit_username', | ||
password: 'reddit password', | ||
app_id: 'reddit api app id', | ||
api_secret: 'reddit api secret', | ||
user_agent: 'user agent for your bot', | ||
retry_on_wait: true, | ||
retry_on_server_error: 5, | ||
retry_delay: 1, | ||
logs: true | ||
}); | ||
``` | ||
@@ -86,7 +86,7 @@ | ||
## Reddit API (api) | ||
## Reddit API | ||
Reddit Wrappers api component is an agnostic wrapper around Reddit's rest API that handles retries, and Reddit's different response codes. | ||
The API component is an agnostic wrapper around Reddit's rest API that handles retries, and Reddit's different response codes. | ||
In order to use the api head over to the [Reddit API Documentation](https://www.reddit.com/dev/api/). All of the api methods use one of the 5 HTTP methods (GET, POST, PATCH, PUT, DELETE) which map to the 5 different snooper.api methods. | ||
In order to use the api head over to the [Reddit API Documentation](https://www.reddit.com/dev/api/). All of the api methods use one of the 5 HTTP methods (GET, POST, PATCH, PUT, DELETE) which map to the 5 different redditAPI.api methods. | ||
@@ -138,7 +138,9 @@ ``` js | ||
*Note: new accounts get little to no posting privileges (1 comment or post per 5 minutes or more) if you dont have any karma. If you just want to play around with the api I recommend using an active account.* | ||
*Note: the response from any HTTP methods will be an array containing [responseCode, data].* | ||
*Note: Any 403 that occurs during a retry process will cause a token refresh and a endpoint retry.* | ||
### basic api usage | ||
### Basic API Usage | ||
@@ -145,0 +147,0 @@ check how much karma your bot has |
178
36079
903