fortnite-basic-api
Basic Fortnite API for stats and server status built with async/await
Inspired by other repos about Fortnite API's as:
Which I previously used fortnite-api but have gotten issues with unhandledrejections which causing issues in other projects. Therefore I rebuilt with focus on Async/await to resolve the issues and adding support for V2 API endpoint.
BREAKING CHANGES
From v1.5 backward compatibility methods & ways of doing things has been removed. Check the examples how to use it properly.
- Generate device id from exchange example: https://github.com/iXyles/fortnite-basic-api/blob/master/example-test/generatedeviceauth.js
- Login with regular creds and use device auth example: https://github.com/iXyles/fortnite-basic-api/blob/master/example-test/deviceauth.js
Example usage:
const Client Communicator FriendStatus = ; // Creation of the Client, autokill will kill the session when client is disposed.// If you are not giving any tokens it will use the default ones that are needed.// If you got rate limited (captcha_invalid) you can use an exchangeCode to generate a deviceauth.// You get the exchangeCode at https://www.epicgames.com/id/login?redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Fid%2Fapi%2Fexchange.// Remember that you must be logged in with the account you want at https://epicgames.com// AND BE CAREFUL! The generated code bypasses all 2FA logins & credentials, so do not share it.const client = email: processenvFORTNITE_EMAIL // PLEASE USE ENV VARIABLES! password: processenvFORTNITE_PASSWORD // PLEASE USE ENV VARIABLES! // You should not have to update any of the tokens. launcherToken: 'MzRhMDJjZjhmNDQxNGUyOWIxNTkyMTg3NmRhMzZmOWE6ZGFhZmJjY2M3Mzc3NDUwMzlkZmZlNTNkOTRmYzc2Y2Y=' fortniteToken: 'ZWM2ODRiOGM2ODdmNDc5ZmFkZWEzY2IyYWQ4M2Y1YzY6ZTFmMzFjMjExZjI4NDEzMTg2MjYyZDM3YTEzZmM4NGQ=' autokill: true; // Creation of communicatorconst communicator = client; // Example of usageasync { // Perform the login process of the "client" console; // Setup communicator events communicatorevents; communicatorevents; communicatorevents; communicatorevents; communicatorevents; communicatorevents; communicatorevents; communicatorevents; communicatorevents; // Then connect it console; // Since everything is async based, we can query everything parallel how ever we want with await const parallel = await Promiseall // Supports both name & id clientstats clientstats // Or maybe just lookup? clientlookup clientlookup // or maybe a couple at a time? clientlookup client client // insert a different language code if wanted client client client // or maybe the current logged in user accountId clientauthenticatoraccountId ; parallel; // Node will die and print that the session has been killed if login was successful};
License
MIT License
Copyright (c) 2019-2020 iXyles
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.