Giter Site home page Giter Site logo

tfd-api-sdk's Introduction

The First Descendant API SDK

An Unofficial dotnet / csharp SDK for Nexon's OpenAPI for The First Descendant

Work In Progress. Feel free to make pull requests to improve. Example code worked for me :)

Credit To FraWolf's Typescript Version for some of the models

using TfdApiSDK;
using TfdApiSDK.Models.General;
using TfdApiSDK.Models.Account;
using TfdApiSDK.Models.Game;
using System.Web;
using System.Text.Json;

namespace YourApp
{
    internal class Program
    {
        private const string KEY = "test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        private const string USERNAME = "User#1234";

        static async Task Main(string[] args)
        {
            APIClient client = new TfdApiSDK.APIClient(KEY, throwOnSdkError: true);

            // MetaData API
            //APIResponse<IDescendant[]>? DescendantMetadata = await client.metadataAPI.GetDescendantMetadata();
            //APIResponse<IWeapon[]>? WeaponMetadata = await client.metadataAPI.GetWeaponMetadata();
            APIResponse<IModule[]>? ModuleMetadata = await client.metadataAPI.GetModuleMetadata();
            //APIResponse<IReactor[]>? ReactorMetadata = await client.metadataAPI.GetReactorMetadata();
            //APIResponse<IExternalComponent[]>? ExternalComponentMetadata = await client.metadataAPI.GetExternalComponentMetadata();
            //APIResponse<IReward[]>? RewardMetadata = await client.metadataAPI.GetRewardMetadata();
            //APIResponse<IStat[]>? StatMetadata = await client.metadataAPI.GetStatMetadata();
            //APIResponse<IVoidBattle[]>? VoidBattleMetadata = await client.metadataAPI.GetVoidBattleMetadata();
            //APIResponse<ITitle[]>? TitleMetadata = await client.metadataAPI.GetTitleMetadata();

            // Account API
            APIResponse<User>? UserOUID = await client.accountAPI.GetUserOUID(USERNAME);
            string? ouid = UserOUID?.Value.ouid;

            if(ouid is null) { return; }

            APIResponse<UserBasic>? UserBasicInfo = await client.accountAPI.GetUserBasicInfo(ouid);
            APIResponse<UserDescendant>? UserDescendantInfo = await client.accountAPI.GetUserDescendantInfo(ouid);
            APIResponse<UserWeapon>? UserWeaponInfo = await client.accountAPI.GetUserWeaponInfo(ouid);
            APIResponse<UserReactor>? UserReactorInfo = await client.accountAPI.GetUserReactorInfo(ouid);
            APIResponse<ExternalComponent>? UserExternalComponent = await client.accountAPI.GetUserExternalComponent(ouid);

            string? descendant_id = UserDescendantInfo?.Value.descendant_id;
            string? weapon_id = UserWeaponInfo?.Value.weapon[0].weapon_id; // first (top slot) weapon ID
            string? void_battle_id = "651000001"; // Grave Walker
            QueryPeriod period = QueryPeriod.Last7Days;

            if (descendant_id is null || weapon_id is null || void_battle_id is null) { return; }

            APIResponse<RecommendationModule>? RecommendationModule = 
                await client.accountAPI.GetRecommendationModule(descendant_id, weapon_id, void_battle_id, period);

            if(RecommendationModule?.Value.descendant.recommendation.Length == 0) { return; }

            string? module_id = RecommendationModule?.Value.descendant.recommendation[0].module_id;
            string? module_name = ModuleMetadata?.Value.FirstOrDefault((mod) => mod.module_id == module_id)?.module_name;
            Console.WriteLine($"The Module You Should Pick Is: {module_name ?? "N/A"}");
        }
    }
}

tfd-api-sdk's People

Contributors

glatrix avatar

Stargazers

Bryan Lee avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.