Some of the method use Authentification by a special service like fnbr.co or fortnitetracker.com. Make sure you have the api key for these service if you want to use their service.
Create a Client
You're not obliged to create a client if you doesn't want to use fnbr.co and fortnitetracker api. Make sure you have insert your credentials in the client.
example:
constfortnite=require("fortnite-9812")
constclient=newfortnite.Client({
TRN:"<TRN API key if you have one>",
fnbrToken:"<fnbr API key if you have one>"
})//from now, you can use all the function that require the client
Get the fortnite in-game news
there is currently one method to get the news. it's fortnite#brNews
example:
constfortnite=require("fortnite-9812")
fortnite.brNews()
.then(news=>console.log(news))
.catch(err=>console.eror(err))
Get the fortnite in-game shop
There is three method to get the shop, the first uses an API key from fnbr.co, the second uses an APi key from trackernetworkand the last doesn't use any API key.
FNBR method
constfortnite=require("fortnite-9812")
constclient=newfortnite.Client({
//TRN: "<TRN API key if you have one>", Not required for this example
fnbrToken:"<fnbr API key if you have one>"
})//from now, you can use all the function that require the client
client.fnbrShop()
.then(shop=>console.log(shop))
.catch(err=>console.error(err))
this example retrieve the shop in the format json:
{
"status":200,
"data":{
"date":"2019-01-12T00:00:00.000Z",
"featured":[
//anarraywithfeatureditems
],
"daily":[
//anarraywithdailyitems
]
}
}
TRN method
constfortnite=require("fortnite-9812")
constclient=newfortnite.Client({
TRN:"<TRN API key if you have one>"
//fnbrToken: "<fnbr API key if you have one>" Not required for this example
})//from now, you can use all the function that require the client
client.TRNShop()
.then(shop=>console.log(shop))
.catch(err=>console.error(err))
this example retrieve the shop in the format json:
There is two ways to get the battle royale stats, the first is without API key and the second uses TRN api key
Without APi keynote: this method do the same as fortnite#getID and fortnite#getStatsId
It is better to use this method than get the id and use getStatsId.
This method does not require an API key
this console.log: "http://fortnitefontgenerator.com/img.php?fontsize=160&textcolor=FFFFFF&text=this%20is%20a%20test%20for%20the%20fortnite.text%20method"
the object in the parameters is necessary. The "text" var in the json is obliged. the color and size are optional.
the color parameter is a hex color and the size is size in pixel for the text.
Get a list of fortnite challenge
there is two method for getting challenge, One with TRN API key and the other without.
TRN method
example:
constfortnite=require("fortnite-9812")
constclient=newfortnite.Client({
TRN:"<TRN API key if you have one>"
//fnbrToken: "<fnbr.co API key if you have one>"
})//from now, you can use all the function that require the client
client.TRNChallenge()
.then(challenge=>console.log(challenge)))
.catch(err=>console.error(err))
example response:
{
"items":[
{
"metadata":[
{
"key":"type",
"value":"challenge"
},
{
"key":"name",
"value":"Record a speed of 27 or more on different Radar Signs"
"challenge":"Search a Chest in different Named Locations",
"total":7,
"stars":5,
"difficulty":"normal"
}
],
"week3":[
{
"identifier":"d2ddea1-8f00665-ce8623e-36bd4e3",
"challenge":"Ride a Zipline in different matches",
"total":5,
"stars":5,
"difficulty":"normal"
}
],
"week4":[
{
"identifier":"ad61ab1-43223ef-bc24c7d-2583be6",
"challenge":"Use an X-4 Stormwing plane in different matches",
"total":5,
"stars":5,
"difficulty":"normal"
}
],
"week5":[
{
"identifier":"d09bf41-544a336-5a46c90-77ebb5e",
"challenge":"Stage 1: Land at Polar Peak",
"total":1,
"stars":1,
"difficulty":"normal"
}
],
"week6":[
{
"identifier":"fbd7939-d674997-cdb4692-d34de86",
"challenge":"Search an Ammo Box in different Named Locations",
"total":7,
"stars":5,
"difficulty":"normal"
}
],
"week7":[],
"week8":[],
"week9":[],
"week10":[]
}
}
This wil return something like that.
Get any URL with a fnbr.co api key
If you want to call an URL that is not on their api with your API key, you can:
constfortnite=require("fortnite-9812")
constclient=newfortnite.Client(
fnbrToken:"<FNBR API key>"
)
client.fnbrGet("https://fnbr.co/api/stats")//maybe you're using some kind of proxies so you can change the url to get these data.
.then(res=>console.log(res))
.catch(err=>console.error(err))
note: use the adapted method, if you want to get the shop, then, get the shop with Client#fnbrShop. This is only for people who want to use another URL or if the api gets uptdated and the package is not yet
Get a list of items in the game
You can get a list of cosmetics items in the game without authentication.
use fortnite#
Credits:
All credit goes to Epic Games for all request without token, fnbr.co for all request with their api key and TRN for request with their API key.
If you need help, create an issue or contact me on discord: Manaf#9812