io.github.robertograham:nadir

Apex Legends REST API client


Keywords
apex, apex-legends, api, api-client, client, legends, origin, rest, rest-client, uid, xmpp, xmpp-client
License
MIT

Documentation

Maven Central

nadir

Features

  • Get UID of authenticated account
  • Get UIDs of other accounts by their usernames
  • Lazily reestablishes authentication session
  • Can establish connection to Origin's XMPP server

Usage

Get UID of authenticated account

import io.github.robertograham.nadir.Account;
import io.github.robertograham.nadir.Nadir;

import java.io.IOException;

public final class Main {

    public static void main(final String[] args) {
        try (final var nadir = Nadir.newNadir("emailAddress", "password")) {
            nadir.accounts()
                .findOneBySessionToken()
                .map(Account::userId)
                .ifPresent(System.out::println);
        } catch (final IOException exception) {
            exception.printStackTrace();
        }
    }
}

Get UID of other account by its username

import io.github.robertograham.nadir.Account;
import io.github.robertograham.nadir.Nadir;

import java.io.IOException;

public final class Main {

    public static void main(final String[] args) {
        try (final var nadir = Nadir.newNadir("emailAddress", "password")) {
            final var usernameString = "DiegosaursTTV";
            nadir.accounts()
                .findAllBySearchTerms(usernameString)
                .flatMap((final var accountList) -> accountList.stream()
                    .filter((final var account) -> usernameString.equalsIgnoreCase(account.username()))
                    .findFirst()
                    .map(Account::userId))
                .ifPresent(System.out::println);
        } catch (final IOException exception) {
            exception.printStackTrace();
        }
    }
}

Establish connection to Origin's XMPP server

import io.github.robertograham.nadir.Nadir;
import org.jivesoftware.smack.AbstractXMPPConnection;

import java.io.IOException;

public final class Main {

    public static void main(final String[] args) {
        try (final var nadir = Nadir.newBuilder("emailAddress", "password")
            .establishXmppConnection(true)
            .debugXmppTraffic(true)
            .build()) {
            nadir.xmppConnection()
                .map(AbstractXMPPConnection::isAuthenticated)
                .ifPresent(System.out::println);
        } catch (final IOException exception) {
            exception.printStackTrace();
        }
    }
}