Coder Social home page Coder Social logo

pubgsharp's Introduction

Important update (2018)

As of April 2018, this project will become completely obsolete by the introduction of the official PUBG Developer API. This project will not be updated to support the official API, but there might be a new, separate project created from scratch that will do so at some point. Thanks to everyone who contributed to this project.

Build status NuGet version

PUBGSharp

C# wrapper for PUBG stats API provided by https://pubgtracker.com

Notes

  • The API is maintained and provided by pubgtracker.com and all credits go to them. This project just wraps the API for easy usage in C#.
  • The project targets .NET Framework 4.5 and .NET Core 1.1.
  • No need to implement throttling yourself, PUBGSharp does this for you.

Installation

To add PUBGSharp to your project, run the following command in the NuGet Package Manager Console:

Install-Package PUBGSharp

Getting API key

You can get your API key from here: https://pubgtracker.com/site-api

Usage

A very basic example, getting the KDR of the specified player in duo mode, in all regions combined in Early Access Season 1.

var statsClient = new PUBGStatsClient("api-key-here");
var stats = await statsClient.GetPlayerStatsAsync("player-name-here");
try
{
    var kdr = stats.Stats.Find(x => x.Mode == Mode.Duo && x.Region == Region.AGG && x.Season == Seasons.EASeason1).Stats.Find(x => x.Stat == Stats.KDR);
    Console.WriteLine($"Duo KDR: {kdr.Value}");
}
catch (NullReferenceException)
{
    Console.WriteLine($"Could not retrieve stats for {stats.PlayerName}..");
}

For a bit more detailed examples, see the Examples project.

pubgsharp's People

Contributors

aeonlucid avatar beartastic avatar eklypss avatar isatishyadav avatar jinivus avatar wasntafairfight avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pubgsharp's Issues

PUBGSharpException > 'Player data is not valid....'

Hi!

First of all, i wanna say thank you to this nugget, but unfortunatelly not working for me. :( I have api key, but GetPlayerStatsAsync result's is always throw the following ex: 'Player data is not valid.. Player might not exist, or their stats have not been updated yet.' What's the problem?

NullReferenceException in GetPlayerID

Hi!

In this line
var opid = doc.DocumentNode.SelectSingleNode(@"//div[@id='userNickname']").Attributes["data-user_id"].Value;

i get nullreferenceexception. Can you chek it out?

rank value

Hi,
I am beginner and i'm sorry if question is stupid, but i cant find rank stats nowhere. I supposed it will be under Stats.Rank, but rank does not exist. Where i can find rank stats?
ty

Failed to deserialize data - new region

After pubgtracker.com added the newew regions, the data may not be deserialized propperly anymore when someone played on for example a 'Korean' server.

Here is a screenshot showing the actual error (debug mode):
https://www.screencast.com/t/kk3vBW3Rq3Bh

I think this can be fixxed by updating the class, so the data can be deserialized again. (Stats[37] - Season -> enumerator?)

With kind regards,
Younes van Ruth

Better way to handle seasons, at least until the game is out of EA

Since PUBG is now doing monthly resets could we have a way to get the most recent season easily? I assumed that the API was going to return the current season by default but this is not what I see happening. For example if I do this:

var duos = stats.Stats.Find(s => s.Region == PUBGSharp.Data.Region.NA && s.Mode == 
 PUBGSharp.Data.Mode.Duo);

I still get season 3 stats.

The way it is currently it seems we would need to update the code every month, that is a real pain.

Since season 4 started on September 1 we could start with this and take the current date and figure out how many months since the monthly reset epoch (Sept 2017).

Something like this?

        public static string CurrentSeason() {
            var season4StartDate = new DateTime(2017, 9, 1);
            var today = DateTime.Now;
            var monthsSinceSept2017 = ((today.Year - season4StartDate.Year) * 12) + Math.Abs(today.Month - season4StartDate.Month);

            var season = 4 + monthsSinceSept2017;

            return $"{today.Year}-pre{season}";
        }

It says this problem was solved in the last commit but I don't see how. This would future proof at least until the game is out of early access.

New FPP leaderboards are giving errors when PUBGSharp is trying to parse the data

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentException: Requested value 'duo-fpp' was not found.
at System.Enum.EnumResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument)
at System.Enum.TryParseEnum(Type enumType, String value, Boolean ignoreCase, EnumResult& parseResult)
at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
at Newtonsoft.Json.Utilities.EnumUtils.ParseEnumName(String enumText, Boolean isNullable, Boolean disallowValue, Type t)
at Newtonsoft.Json.Converters.StringEnumConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)

Cant get data if pubg servers are down.

Hey is there a way to get the last non updated data? I see its viable as I saw at other people program, but I dont know how to get it here, I see when I have GetPlayerAsync and servers are down I get an exception and I cant find a way to get the older data from their database

GetPlayerStatsAsync throws Exception with new update

I'm getting a generic Exception when I run this code:

var stats = await statsClient.GetPlayerStatsAsync(pubg_name).ConfigureAwait(false);

This command worked before the FPP stats began.

Will there be an update to this package to fix it, and make it compatible with FPP?

Compiling

How do i compile the wrapper, using VS 2015 never ran into the problem before.
PUBGSharp\PUBGSharp.csproj : error : The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the <Project> element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format. C:\Users\tuba\Documents\GitHub\PUBGSharp\PUBGSharp\PUBGSharp.csproj

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.