devRant
Unofficial wrapper for the public devRant API.
Requirements
You need node version 6 or greater.
Installation
npm i -S devrant
Interface
This module exposes methods to fetch rants (posts) from devRant and to fetch the profile of a devRant user by username.
devRant Display Requirements
When displaying the contents of a rant fetched from the devRant API, it is required to credit the author of a rant by displaying their devRant username.
Syntax
devRant ;
Methods
After requiring the module, the following methods can be used:
METHOD | ARGUMENTS | RETURNS | DESCRIPTION |
---|---|---|---|
rant | Yes | Promise |
Retrieve a single rant from devRant. Use this method to retrieve a rant with its full text and comments. The retrieved rant is a Full Rant Object. |
rants | Optional | Promise |
Retrieve rants from devRant. The retrieved rants are Simple Rant Objects. |
search | Yes | Promise |
Retrieve rants from devRant that match a specific search term. The retrieved rants are Simple Rant Objects. |
profile | Yes | Promise |
Retrieve the profile of a devRant user by username. The retrieved profile is a Profile Object. |
.rant(id)
Retrieve a single rant from devRant. Use this method to retrieve a rant with its full text and comments.
The retrieved rant is a Full Rant Object.
Arguments
NAME | TYPE | DESCRIPTION |
---|---|---|
id | Number | The rant id. For example 43511 . |
Returns
Promise
.
.rants(options)
Retrieve rants from devRant.
By providing an options Object as an argument, it's possible
to sort by algo
, recent
and top
rants. As well as
limiting and skipping the amount of rants to be fetched.
The retrieved rants are Simple Rant Objects.
Arguments
NAME | TYPE | DESCRIPTION |
---|---|---|
options | Object | Optional. The options to control the rants to be fetched. When omitted, 50 rants of type algo will be fetched and 0 rants will be skipped. |
Options
OPTIONS KEY | TYPE | DESCRIPTION |
---|---|---|
sort | String | Optional. The type of rants to be fetched. Must be algo , recent or top . When omitted, it defaults to algo . |
limit | Number | Optional. The amount of rants to be fetched. When omitted, it defaults to 50 . |
skip | Number | Optional. The amount of rants to be skipped. When omitted, it defaults to 0 . |
Returns
Promise
.
.search(term)
Retrieve rants from devRant that match a specific search term.
The retrieved rants are Simple Rant Objects.
Arguments
NAME | TYPE | DESCRIPTION |
---|---|---|
term | String | The search term used to match specific rants. For example javascript , xcode , wk2 , devrant , etc. |
Returns
Promise
.
.profile(username)
Retrieve the profile of a devRant user by username.
The retrieved profile is a Profile Object.
Arguments
NAME | TYPE | DESCRIPTION |
---|---|---|
username | String | The devRant username. For example danillouz , dfox , localhost , etc. |
Returns
Promise
.
Rant Object Simple
Rant Object Full
Profile Object
Examples
43511
Fetch rant with id 'use strict'; const devRant = ; devRant ;
10
rants of type top
and skip the first 10
Fetch const devRant = ; devRant ;
50
rants of type algo
and skip 0
by using default behavior
Fetch 'use strict'; const devRant = ;const co = ; { return ;} ;
javascript
Fetch all rants that match the search term 'use strict'; const devRant = ;const co = ; { return ;} ;
dfox
Fetch the profile of the devRant user with username 'use strict'; const devRant = ;const co = ; { return ;} ;