Skip to content

Fortnite API wrapper based on RxJava and Retrofit. Incomplete (work in progress).

License

Notifications You must be signed in to change notification settings

whiskermrr/rxjava-fortnite-api

Repository files navigation

RxAndroid Fortnite API Wrapper

Packagist

Usage

Prerequisites

You need to create EpicGames account and download EpicGames Launcher here. After this you will need to install Fortnite.

Installation

Gradle:

dependencies {
    implementation 'com.whiskermrr:rxjava-fortnite-api:0.3.7'
}

Maven:

<dependency> 
  <groupId>com.whiskermrr</groupId>
  <artifactId>rxjava-fortnite-api</artifactId>
  <version>0.3.6</version>
  <type>pom</type>
</dependency>

Obtaining Tokens

Follow these steps to get your launcher and fortnite tokens:

  • Install Fiddler or other application for capturing HTTPS requests.
  • Start EpicGames Launcher and Login (wrapper does not support 2-step verification).
  • Look for request to /account/api/oauth/token endpoint and go to Authorization Header.
  • Copy the value of header without 'basic'. This is Launcher Token.
  • Launch Fortnite.
  • Check for another request to /account/api/oauth/token endpoint and go to Authorization Header.
  • Once again copy the new value of header without 'basic'. This is Fortnite Token.

Creating API Instance

FortniteApi fortniteApi = new FortniteApi(retrofit, EMAIL, PASSWORD, LAUNCHER_TOKEN, FORTNITE_TOKEN);
fortniteApi.authenticate();

Battle Royale Stats

fortniteApi.getUserBattleRoyaleStats("whiskermrr")
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(new SingleObserver<BattleRoyaleStats>() {
            @Override
            public void onSubscribe(Disposable d) {
                // e.g. disposables.add(d);
            }

            @Override
            public void onSuccess(BattleRoyaleStats stats) {
                // e.g. update view
            }

            @Override
            public void onError(Throwable e) {
                // e.g. notify view about error
            }
        });

Blogs

Example of how to get 10 News with offset 0:

fortniteApi.getBlogs(FortniteApiConstants.PATCH_NOTES, 10, 0, Locale.US.toString())
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(new SingleObserver<BlogHolder>() {
            @Override
            public void onSubscribe(Disposable d) {
                // e.g. disposables.add(d);
            }

            @Override
            public void onSuccess(BlogHolder news) {
                // e.g. update recyclerview
            }

            @Override
            public void onError(Throwable e) {
                // e.g. notify view about error
            }
        });

Python Script to create weapons Json file

If You have installed Python on your computer You can check fortnite_weapons.py file which is in the root directory of repo.
Script is getting data about all weapons in Battle Royale Mode from Gamepedia and save them in json file.
It is also capable to download all images of weapons when -img argument of the script is specified.
-img values:
0 - do not download images
1 - download images (120px)
2 - download images (240px)
3 - download images (360px)

How to run script

Open terminal/cmd and go to directory where fornite_weapons.py is located than execute this command:

    python fortnite_weapons.py -img 2

Contributors

Just me :) Feel free to join me.

About

Fortnite API wrapper based on RxJava and Retrofit. Incomplete (work in progress).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published