API examples

Node.js example

using @drep/api

1
$ npm install @drep/api
Copied!

Usage

1
const { DRepClient } = require('@drep/api');
2
const drep = new DRepClient('D-REP.YOUR-KEY');
Copied!

Endpoints

1
class DRepClient {
2
rep(userID: string): Reputation;
3
infractions(userID: string): Ban | Warn | null;
4
}
Copied!

Return Types

1
interface Reputation {
2
upvotes: number;
3
downvotes: number;
4
reputation: number;
5
rank: string;
6
xp: number;
7
staff: boolean;
8
}
9
10
interface Ban {
11
moderator: string;
12
reason: string;
13
date: Date;
14
}
15
16
interface Warn {
17
moderator: string;
18
reason: string;
19
date: Date;
20
}
Copied!

Full example of getting reputation

1
const { DRepClient } = require('@drep/api');
2
const drep = new DRepClient('D-REP.YOUR-KEY');
3
4
let getReputation = async (userID) => {
5
let rep = await drep.rep(userID);
6
console.log(rep);
7
}
8
9
getReputation('1234567891234567');
Copied!
Last modified 1yr ago
Copy link