yarn add grepper
npm install grepper
const GREPPER = require("grepper");
Quick Guide
- Global Functions
- User Related Functions
- Answer Related Functions
- Settings Related Functions
- Raw API Documentation
Global
checkToken()
To check if a token is valid use this function.
async function __main__() {
GREPPER.checkToken({
token: process.ENV.TOKEN, // access_token of the Targeted user
userId: process.ENV.TOKEN, // userId of the Targeted user
})
.then((res) => {
// Your Code Goes Here
})
.catch((err) => {
console.log(err);
});
}
__main__();
nominateSuper()
Nominate a user as a super nominee.
async function __main__() {
const Data = await GREPPER.nominateSuper({
nomineeId: 98467, // The user you want to nominate
awardName: "best_coder", // The award name
token: process.ENV.TOKEN, // access_token of the Targeted user
userId: process.ENV.TOKEN, // userId of the Targeted user
});
console.log(Data);
}
__main__();
Award Names:
most_helpful, hard_worker, class_clown, best_smile, most_likely_billion, best_hair, most_intelligent, best_coder, most_attractive, most_creative
Login()
Login with username & password.
async function __main__() {
const Account = await GREPPER.Login({
email: process.env.EMAIL, // Your Account Email
password: process.env.PASSWORD, // Your Account Password
});
console.log(Account);
}
__main__();
{
"errors": [],
"success": true,
"access_token": "",
"user_id": 0,
"email": "",
"hide_grepper_button": 0,
"grepper_user_langs": [
{
"lkey": "abap",
"name": "Abap",
"enabled": 0
}
],
"blacklists": []
}
Signup()
Signup with username & password.
async function __main__() {
const Account = await GREPPER.Signup({
email: process.env.EMAIL, // Account Email
password: process.env.PASSWORD, // Account Password
});
console.log(Account);
}
__main__();
{
"Success": true,
"Message": "Successfuly Registered New Account.",
"Data": {
"errors": [],
"success": true,
"access_token": "",
"user_id": 1,
"email": "string",
"hide_grepper_button": null,
"grepper_user_langs": [
{
"lkey": "abap",
"name": "Abap",
"enabled": 0
}
],
"blacklists": [],
},
};
getCommunity()
Function to get codegrepper top users(community) from the community page. The first parameter is the [Token][], The second parameter is limit of users to get(default: 100
).
async function __main__() {
Data = await GREPPER.getCommunity(
{
token: process.ENV.TOKEN, // access_token of the Targeted user
userId: process.ENV.TOKEN, // userId of the Targeted user
},
200
);
console.log(Data);
}
__main__();
sendPasswordResetEmail()
Sends a reset password email to the provided email address.
async function __main__() {
Data = await GREPPER.sendPasswordResetEmail("example@example.com");
console.log(Data);
}
__main__();
Users
userInfo()
Fetches code Grepper user's profile information. The first parameter is the user_id(int)
.
async function __main__() {
Data = await GREPPER.userInfo(98467);
console.log(Data);
}
__main__();
updateProfile()
Update user's profile.
async function __main__() {
const Data = await GREPPER.updateProfile({
token: process.ENV.TOKEN, // access_token of the Targeted user
userId: process.ENV.TOKEN, // userId of the Targeted user
funName: `GrepperBot`,
realName: `GrepperBot-betav1`,
websiteURL: User.website_url,
location: User.location,
donateURL: User.donate_link,
twitterName: User.twitter_name,
howToHelp: User.how_to_help,
});
console.log(Data);
}
__main__();
updateProfileImage()
Update user's profile image(avatar).
async function __main__() {
const Data = await GREPPER.updateProfileImage({
token: process.ENV.TOKEN, // access_token of the Targeted user
userId: process.ENV.TOKEN, // userId of the Targeted user
imageURL: `https://.../example.png`, // URL of the image you want as your profile picture
});
console.log(Data);
}
__main__();
{
"Success": true,
"Message": "Profile Updated",
"Data": {
"URL": "https://www.codegrepper.com/profile/username"
}
}
userByToken()
Fetches code Grepper user's information by their ACCESS_TOKEN.
async function __main__() {
Data = await GREPPER.userByToken({
token: process.ENV.TOKEN, // access_token of the Targeted user
userId: process.ENV.TOKEN, // userId of the Targeted user
});
console.log(`Successfuly Logged in as ${Data.Name}`);
}
__main__();
userBeltStats()
Fetches The user's code grepper belt stats. The first parameter is the user_id(int)
.
async function __main__() {
Data = await GREPPER.userBeltStats(98467);
console.log(Data);
}
__main__();
userStats()
Fetches The user's code grepper helped and problems solved stats. The first parameter is the user_id(int)
.
async function __main__() {
Data = await GREPPER.userStats(98467);
console.log(Data);
}
__main__();
userTopAnswers()
Fetches The user's top code grepper answers. The first parameter is the user_id(int)
.
async function __main__() {
Data = await GREPPER.userTopAnswers(98467);
console.log(Data);
}
__main__();
searchUsers()
Searches for code grepper users The first parameter is the user_name(str)
.
async function __main__() {
Data = await GREPPER.searchUsers("Jareer");
console.log(Data);
}
__main__();
getWhoToFollow()
This functions gets all the recommended users to follow that you can find on the feed page.
async function __main__() {
Data = await GREPPER.getWhoToFollow({
token: process.ENV.TOKEN, // access_token of the Targeted user
userId: process.ENV.TOKEN, // userId of the Targeted user
});
console.log(Data);
}
__main__();
Answers
getAnswers()
Fetches coding answers from code grepper, enter the query in the first parameter.
async function __main__() {
Data = await GREPPER.getAnswers("js loop");
console.log(Data);
}
__main__();
saveAnswer()
Save an answer to grepper.
async function __main__() {
const Res = await GREPPER.saveAnswer({
token: process.ENV.TOKEN, // access_token of the Targeted user
userId: process.ENV.TOKEN, // userId of the Targeted user
sourceURL: ``,
teamIds: [],
langauge: `js`
isPrivate: false, // default false
query: `Javascript Loop`, // required
answer: `for(i...`, // required
});
}
__main__();
getComments()
Fetches comments from code grepper coding answers, first parameter is answerId(int)
.
async function __main__() {
Data = await GREPPER.getComments(23);
console.log(Data);
}
__main__();
getSimiliarQueries()
Fetches similiar queries like the one provided, eg, if you enter js loop
it will return javascript loop
, loop in javascript
, loop javascript
async function __main__() {
Data = await GREPPER.getSimiliarQueries("js loop");
console.log(Data);
}
__main__();
Settings
enableCommentNotif()
Enables your comment notifications from the settings.
async function __main__() {
Data = await GREPPER.enableCommentNotif({
token: process.ENV.TOKEN, // access_token of the Targeted user
userId: process.ENV.TOKEN, // userId of the Targeted user
});
console.log(Data);
}
__main__();
disableCommentNotif()
Disables your comment notifications from the settings.
async function __main__() {
Data = await GREPPER.disableCommentNotif({
token: process.ENV.TOKEN, // access_token of the Targeted user
userId: process.ENV.TOKEN, // userId of the Targeted user
});
console.log(Data);
}
__main__();
getPrivacySettings()
Gets you privacy settings.
async function __main__() {
Data = await GREPPER.getPrivacySettings({
token: process.ENV.TOKEN, // access_token of the Targeted user
userId: process.ENV.TOKEN, // userId of the Targeted user
});
console.log(Data); // Data.Data is the actual object with data
}
__main__();
Teams
inviteToTeam()
Invite users to a team.
async function __main__() {
Data = await GREPPER.inviteToTeam({
teamId: 525,
usersArray: [4, 98467], // Ids of the users you want
});
console.log(Data); // Data.Data is the actual object with data
}
__main__();
Example Usage
// Fetching Privacy Settings By Username & Password
async function __main__() {
const Account = await GREPPER.Login({
email: "account@email.com",
password: "password",
});
const Data = await GREPPER.Login({
token: Account.Data.access_token,
userId: Account.Data.user_id,
});
console.log(Data);
}
__main__();