xbl.io

1.4.7 • Public • Published

XBL.IO Unnofficial Client

BY: DerpDevs


What is this?

This is a project made by DerpDevs, we had been using xbl.io for a while and we wanted to make it easier for everyone to use it.

This works just like any API handler, but please note that we are not the official developers of xbl.io and that there may be issues with this.


Starting Off

To get started, head over to xbl.io and create an account, you can pick a free one but if you would like you may upgrade it (Note: Free accounts allow a maximum of 500 API requests per hour). Once you have created an account, go to your profile by clicking on your username, and clicking profile. Once you are there, make a new API Key and put it somewhere safe. At this point get your code editor open and run npm install xbl.io in the terminal to install the package (You need at least node 12 to use this package).

Note: For these examples, replace API_KEY and NEW_API_KEY with the actual api keys.


Instantiate Client

const XBL = require("xbl.io");
var client = new XBL.Client();



client.login(API_KEY, (account) => {
	console.log("Logged in as: " + account.settings.Gamertag + "!")
})

OR

await client.login(API_KEY)
console.log("Logged in as: " + account.settings.Gamertag + "!")

WARNING: client.login() is async (this is due to the fact that it must verify that the API Key is valid) so it may not be instant (though it is pretty quick) unless you run it with an await before it in an async function. Though you can run a callback with a parameter which is your account and another one which would be your oldAccount if you were logged in before.


You can easily login to another user by doing:

client.login(NEW_API_KEY, (newAccount, oldAccount) => {
	console.log("Logged out from: " + oldAccount.settings.Gamertag + " and logged in as: " + newAccount.settings.Gamertag + "!")
})



await client.login(NEW_API_KEY)
console.log("Logged in as: " + account.settings.Gamertag + "!")

Properties

cache

// Object
client.cache

The cache which stores all data recently fetched from the servers.

account

// Object
client.account

The most recent save of the client's account.

Cache

accounts

// Object<String:Object>
client.cache.accounts

The save of all accounts fetched (Saves non-repetitive objects with the user xuid as the key and the account object as the value).

Methods

logout

client.logout(optional:function:callback);

Logs out of the current account and calls callback with one parameter being the account that was logged out of.

getAccount

await client.getAccount(optional:String/Int/null:XUID);

Grabs the account of the XUID specified, if no XUID is specified, uses the currently logged in account's XUID.

getAccounts

await client.getAccounts(required:Array<String/Int/Null>:XUIDs);

Iterates throught the inputted Array and returns an array of the accounts of all the xuids inputted.

friends

await client.friends(optional:String/Int:XUID);

Grabs the accounts of all the friends of the account specified, if no account is specified, uses the currently logged in account.

userFetch

await client.userFetch(required:String:gamertag);

Grabs the account of the user specified.

friendAdd (Currently not working)

await client.friendAdd(required:String/Int:XUID);

Adds a friend to your friends list.

friendRemove (Currently not working)

await client.friendRemove(required:String/Int:XUID);

Removes a friend from your friends list.

favoriteAdd (Currently not working)

await client.favoriteAdd(required:String/Int:XUID);

Adds a friend to your favorites.

favoriteRemove (Currently not working)

await client.favoriteRemove(required:String/Int:XUID);

Removes a friend from your favorites while still keeping them in your friends list.

fetchPresence

await client.fetchPresence(optional:Array<String/Int>:XUIDs /* array */);

Fetches the presences of all the XUIDs in the array (they must be friends of yours) . If no array is inputted, it will fetch the presence of all your friends.

fetchConversation/fetchConversations

await client.fetchConversation(optional:String/Int:XUID);
OR
await client.fetchConversations(optional:String/Int:XUID);

Fetches the conversations between you and the user with the XUID. If no XUID is given, fetches all of your conversations.

sendMessage (UNTESTED)

await client.sendMessage(required:String:(user, u, or user/u) or (group, g, or group/g), required:String/Int:groupId or user XUID, required:String:message);

Sends a message to the user or group specified.

sendGroupMessage/sendUserMessage

Same arguments just without the first one. Does the same thing as sendMessage, just another method.






We hope this guide was helpful for you on your journey!

Readme

Keywords

none

Package Sidebar

Install

npm i xbl.io

Weekly Downloads

2

Version

1.4.7

License

ISC

Unpacked Size

13.1 kB

Total Files

6

Last publish

Collaborators

  • derpdevs