tfd-api
Version:
A simple API wrapper to interact with The First Descendant API
370 lines (361 loc) • 10.9 kB
text/typescript
interface ErrorMessage {
error: {
name: string;
message: string;
};
}
type Languages = "ko" | "en" | "de" | "fr" | "ja" | "zh-CN" | "zh-TW" | "it" | "pl" | "pt" | "ru" | "es";
interface Options {
api_key?: string;
default_language?: Languages;
}
interface ClientOptions {
host: string;
default_language: Languages;
headers: {
"x-nxopen-api-key"?: string;
};
}
type APIResponse<T = unknown> = T extends ErrorMessage ? ErrorMessage : T;
interface User {
ouid: string;
}
interface UserBasic {
ouid: string;
user_name: string;
platform_type: string;
mastery_rank_level: number;
mastery_rank_exp: number;
title_prefix_id?: string;
title_suffix_id?: string;
os_language: string;
game_language: Languages;
}
interface UserDescendant {
ouid: string;
user_name: string;
descendant_id: string;
descendant_slot_id: string;
descendant_level: number;
module_max_capacity: number;
module_capacity: number;
module: UserModule[];
}
interface UserWeapon {
ouid: string;
user_name: string;
weapon: Weapon[];
}
interface UserExternalComponent {
ouid: string;
user_name: string;
external_component: ExternalComponent[];
}
interface UserReactor {
ouid: string;
user_name: string;
reactor_id: string;
reactor_slot_id: string;
reactor_level: number;
reactor_additional_stat: AdditionalStat[];
reactor_enchant_level: number;
}
interface Weapon {
module_max_capacity: number;
module_capacity: number;
weapon_slot_id: string;
weapon_id: string;
weapon_level: number;
perk_ability_enchant_level: number;
weapon_additional_stat: AdditionalStat[];
module: UserModule[];
}
interface ExternalComponent {
external_component_slot_id: string;
external_component_id: string;
external_component_level: number;
external_component_additional_stat: AdditionalStat[];
}
interface AdditionalStat {
additional_stat_name: string;
additional_stat_value: string;
}
interface UserModule {
module_slot_id: string;
module_id: string;
module_enchant_level: number;
}
interface IDescendant {
descendant_id: string;
descendant_name: string;
descendant_image_url: string;
descendant_stat: IDescendantStat[];
descendant_skill: IDescendantSkill[];
}
interface IDescendantStat {
level: number;
stat_detail: IDescendantDetail[];
}
interface IDescendantDetail {
stat_type: string;
stat_value: number;
}
interface IDescendantSkill {
skill_type: string;
skill_name: string;
element_type: string;
arche_type: string;
skill_image_url: string;
skill_description: string;
}
interface IWeapon {
weapon_name: string;
weapon_id: string;
image_url: string;
weapon_type: string;
weapon_tier: string;
weapon_rounds_type: string;
base_stat: IWeaponBaseStat[];
firearm_atk: IWeaponFirearmAtk[];
weapon_perk_ability_name: string;
weapon_perk_ability_description: string;
}
interface IWeaponBaseStat {
stat_id: string;
stat_value: number;
}
interface IWeaponFirearmAtk {
level: number;
firearm: IWeaponFirearm[];
}
interface IWeaponFirearm {
firearm_atk_type: string;
firearm_atk_value: number;
}
interface IModule {
module_name: string;
module_id: string;
image_url: string;
module_type: string;
module_tier: string;
module_socket_type: string;
module_class: string;
module_stat: IModuleStat[];
}
interface IModuleStat {
level: number;
module_capacity: number;
value: string;
}
interface IReactor {
reactor_id: string;
reactor_name: string;
image_url: string;
reactor_tier: string;
reactor_skill_power: IReactorSkillPower[];
optimized_condition_type: string;
}
interface IReactorSkillPower {
level: number;
skill_atk_power: number;
sub_skill_atk_power: number;
skill_power_coefficient: IReactorPowerCoefficient[];
enchant_effect: IReactorEnchantEffect[];
}
interface IReactorPowerCoefficient {
coefficient_stat_id: string;
coefficient_stat_value: number;
}
interface IReactorEnchantEffect {
enchant_level: number;
stat_type: string;
value: number;
}
interface IExternalComponent {
external_component_id: string;
external_component_name: string;
image_url: string;
external_component_equipment_type: string;
external_component_tier: string;
base_stat: IExternalComponentBaseStat[];
set_option_detail: IExternalComponentSetOptionDetail[];
}
interface IExternalComponentBaseStat {
level: number;
stat_id: string;
stat_value: number;
}
interface IExternalComponentSetOptionDetail {
set_option: string;
set_count: number;
set_option_effect: string;
}
interface IReward {
map_id: string;
map_name: string;
battle_zone: IRewardBattleZone[];
}
interface IRewardBattleZone {
battle_zone_id: string;
battle_zone_name: string;
reward: IRewardBattleZoneReward[];
}
interface IRewardBattleZoneReward {
rotation: number;
reward_type: string;
reactor_element_type: string;
weapon_rounds_type: string;
arche_type: string;
}
interface IStat {
stat_id: string;
stat_name: string;
}
interface IVoidBattle {
void_battle_id: string;
void_battle_name: string;
}
interface ITitle {
title_id: string;
title_name: string;
}
declare enum QueryPeriod {
Last7Days = 0,
Last30Days = 1,
AllTime = 2
}
interface RecommendationModule {
descendant: RecommendationModuleDescendant;
weapon: RecommendationModuleWeapon;
}
interface RecommendationModuleDescendant {
descendant_id: string;
recommendation: RecommendationModuleRecommendation[];
}
interface RecommendationModuleWeapon {
weapon_id: string;
recommendation: RecommendationModuleRecommendation[];
}
interface RecommendationModuleRecommendation {
module_id: string;
}
declare class Account {
private url;
private headers;
private default_language;
constructor(url: string, headers: Record<string, string>, default_language: Languages);
/**
* Retrieve account identifier (OUID)
* @param user_name Nickname
* @returns
*/
getId(user_name: string): Promise<APIResponse<User>>;
/**
* Retrieves basic information.
* @param ouid OUID
* @returns
*/
getUserBasic(ouid: string): Promise<APIResponse<UserBasic>>;
/**
* Retrieves information about the equipped descendant.
* @param ouid OUID
* @returns
*/
getUserDescendant(ouid: string): Promise<APIResponse<UserDescendant>>;
/**
* Retrieves information about weapons equipped in all slots.
* @param ouid OUID
* @param language_code language code
* @returns
*/
getUserWeapon(ouid: string, language_code?: Languages): Promise<APIResponse<UserWeapon>>;
/**
* Retrieves information about the equipped Reactor.
* @param ouid OUID
* @param language_code language code
* @returns
*/
getUserReactor(ouid: string, language_code?: Languages): Promise<APIResponse<UserReactor>>;
/**
* Retrieves information about external components equipped in all slots.
* @param ouid OUID
* @param language_code language code
* @returns
*/
getUserExternalComponent(ouid: string, language_code?: Languages): Promise<APIResponse<ExternalComponent>>;
/**
* Recommends modules suited to the user.
* @param descendant_id Descendant identifier (Refer to /meta/descendant API)
* @param weapon_id Weapon identifier (Refer to /meta/weapon API)
* @param void_battle_id Void Intercept Battle identifier (Refer to /meta/void-battle API)
* @param period Query period
* @returns
*/
getRecommendationModule(descendant_id: string, weapon_id: string, void_battle_id: string, period: QueryPeriod): Promise<RecommendationModule>;
}
declare class Metadata {
private url;
private default_language;
constructor(url: string, default_language: Languages);
/**
* Retrieve descendant metadata
* @param language_code Languages
* @returns
*/
getDescendant(language_code?: Languages): Promise<APIResponse<IDescendant[]>>;
/**
* Retrieve weapon metadata
* @param language_code Languages
* @returns
*/
getWeapon(language_code?: Languages): Promise<APIResponse<IWeapon[]>>;
/**
* Retrieve module metadata
* @param language_code Languages
* @returns
*/
getModule(language_code?: Languages): Promise<APIResponse<IModule[]>>;
/**
* Retrieve Reactor metadata
* @param language_code Languages
* @returns
*/
getReactor(language_code?: Languages): Promise<APIResponse<IReactor[]>>;
/**
* Retrieve external component metadata
* @param language_code Languages
* @returns
*/
getExternalComponent(language_code?: Languages): Promise<APIResponse<IExternalComponent[]>>;
/**
* Retrieve Difficulty Level Rewards metadata
* @param language_code Languages
* @returns
*/
getReward(language_code?: Languages): Promise<APIResponse<IReward[]>>;
/**
* Retrieve base stat metadata
* @param language_code Languages
* @returns
*/
getStat(language_code?: Languages): Promise<APIResponse<IStat[]>>;
/**
* Retrieve Void Intercept Battle metadata
* @param language_code Languages
* @returns
*/
getVoidBattle(language_code?: Languages): Promise<APIResponse<IVoidBattle[]>>;
/**
* Retrieve Title metadata
* @param language_code Languages
* @returns
*/
getTitle(language_code?: Languages): Promise<APIResponse<ITitle[]>>;
}
declare class TFDApi {
private options;
account: Account;
metadata: Metadata;
constructor(config: Options);
}
export { type APIResponse, type AdditionalStat, type ClientOptions, type ErrorMessage, type ExternalComponent, type IDescendant, type IDescendantDetail, type IDescendantSkill, type IDescendantStat, type IExternalComponent, type IExternalComponentBaseStat, type IExternalComponentSetOptionDetail, type IModule, type IModuleStat, type IReactor, type IReactorEnchantEffect, type IReactorPowerCoefficient, type IReactorSkillPower, type IReward, type IRewardBattleZone, type IRewardBattleZoneReward, type IStat, type ITitle, type IVoidBattle, type IWeapon, type IWeaponBaseStat, type IWeaponFirearm, type IWeaponFirearmAtk, type Languages, type Options, QueryPeriod, type RecommendationModule, type RecommendationModuleDescendant, type RecommendationModuleRecommendation, type RecommendationModuleWeapon, TFDApi, type User, type UserBasic, type UserDescendant, type UserExternalComponent, type UserModule, type UserReactor, type UserWeapon, type Weapon };