1.3.1 • Published 2 years ago

assistants-api v1.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

assistants-api

Below we present the documentation of the assistants-api module used to communicate with the API Assistants Center (assistants.ga).

Installation

npm i assistants-api

Errors Handling

If an error occurred while executing an action, the function returned the following value:

{error: true, message: "error text"}

If all is successful, the following value will be returned:

{error: false, data: returnedData_ifThereIs}

API client

Require module

const Assistants = require('assistants-api');

New client

const client = new Assistants.Client(parametr, password);

where parametr is user username or e-mail adress and password is user password

Functions

Login

const user = await client.login();

success:

{
  error: false,
  data: { username: '', email: '' }
}

error:

As in Errors Handling above

Session

const session = await client.session();

success:

{
  cookie: {
    originalMaxAge: Number,
    expires: DateString,
    httpOnly: Boolean,
    path: String
  },
  user: { sid: String, username: String },
  __lastAccess: Number,
  apples: Number
}

error:

As in Errors Handling above

Register

const newAccount = await client.register({username: String, email: String, password: String, tos: Boolean})

success:

{
  error: false,
  data: { username: String, email: String }
}

error:

As in Errors Handling above

Events Listeners

You can connect to API Assistants to listen for the latest updates. For example, you can know when the daily store is updated, in what language, and get a ready-made store image buff.

Init

const events = await client.events();

Errors

As in Errors Handling above

Fortnite Daily Shop Updates

const shopEmitter = events.shop;
shopEmitter.on('shop::new', ({buff,lang}) => {
    console.log(`NEW SHOP! IMAGE buff: ${buff}, lang: ${lang}`);
});

Fortnite Sections Updates

const sectionsEmitter = events.sections;
sectionsEmitter.on('sections::new', ({buff,lang}) => {
    console.log(`NEW SECTIONS! IMAGE buff: ${buff}, lang: ${lang}`);
});

Ready-to-use example with public account

const Assistants = require('assistants-api');

const client = new Assistants.Client("assistants_api", "public123");

client.login().then(async (res)=>{
    if(res.error)return console.log(res);
    console.log(res);

    const userSession = await client.session();
    console.log(userSession);

    const newAccount = await client.register({username: "", email: "", password: "", tos: true});
    console.log(newAccount);


    const events = await client.events();

    const shopEmitter = events.shop;
    shopEmitter.on('shop::new', ({buff,lang}) => {
        console.log(`NEW SHOP! IMAGE buff: ${buff}, lang: ${lang}`);
    });

    const sectionsEmitter = events.sections;
    sectionsEmitter.on('sections::new', ({buff,lang}) => {
        console.log(`NEW SECTIONS! IMAGE buff: ${buff}, lang: ${lang}`);
    });
});
1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.0.0-readmefix

3 years ago

1.0.0

3 years ago

0.0.1

3 years ago