earnapp.js
v2.2.0
Published
A JavaScript library for interacting with the EarnApp API
Downloads
769
Readme
Upgrading from version 1.X.X to version 2.X.X
All methods that requires authentication (dashboard API) are moved to client.dashboard.
example:
- client.stats()
+ client.dashboard.stats()
The methods left on client don't need authentication and are uuid bound.
EarnApp.js
earnapp.js is a Node.js module that allows you to easily interact with the EarnApp API.
- Promise-based
- Performant
- 100% coverage of the EarnApp API
Installation
- Install NodeJS.
With GitHub:
- Download or clone the project.
- Go to the
earnapp.js
folder and runnpm install
. - Require
client.js
.
With npm:
- Run
npm install earnapp.js
. - Require the library.
Documentation
Example usage
The library can be used in both CommonJS and ES Modules
Using the library
The library is async, be sure to use async functions or .then()
const { Client } = require("earnapp.js");
//OR
import { Client } from "earnapp.js";
const client = new Client();
client.dashboard.login({
authMethod: "google",
oauthRefreshToken: "1%2F%2F0dx...mfz75",
xsrfToken: "uE9Tm4sXtk4wHEz4tZFJyANB",
//needed for endpoints like linking a device / or making a payout
});
client.dashboard.stats().then((data) => {
console.log(data);
});
//OR
const getStats = async () => {
const data = await client.dashboard.stats();
console.log(data);
};
getStats();
You can also get the CSRF token and login like this:
const main = async () => {
const cookie = "1%2F%2F0dx...mfz75";
const { token } = await client.dashboard.getCSRF({
authMethod: "google",
oauthRefreshToken: cookie,
});
client.dashboard.login({
authMethod: "google",
oauthRefreshToken: cookie,
xsrfToken: token,
//needed for endpoints like linking a device / or making a payout
});
};
main();
Credits
Copyright
See the license