gavinpower747 / pubg-dotnet Goto Github PK
View Code? Open in Web Editor NEWSync/async client library for the PlayerUnknown's Battlegrounds Developer Api
License: MIT License
Sync/async client library for the PlayerUnknown's Battlegrounds Developer Api
License: MIT License
In the JsonApi spec all related objects are listed in a separate "Relationships" object like so
{
{
"type": "articles",
"id": "1",
"attributes": {
"title": "JSON API paints my bikeshed!"
},
"relationships": {
"author": {
"links": {
"self": "http://example.com/articles/1/relationships/author",
"related": "http://example.com/articles/1/author"
},
"data": { "type": "people", "id": "9" }
},
"comments": {
"links": {
"self": "http://example.com/articles/1/relationships/comments",
"related": "http://example.com/articles/1/comments"
},
"data": [
{ "type": "comments", "id": "5" },
{ "type": "comments", "id": "12" }
]
}
},
"links": {
"self": "http://example.com/articles/1"
}
}
The Pubg API uses a lot of these relationships to simply contain the ids of the complete objects. In order to keep the returned object simple and flat I created the RelationshipIdConverter which delves into the data object and extracts these ids into an IEnumerable of type string. However, this has created an issue when you try to re-serialize the object and deserialize it again (when storing the objects in a cache or passing them between services for example). When the second deserialization happens the object has already been flattened into the desired array the data object no longer exists, so when we attempt to return data["id"] it's always null, leading to us losing the relationship ids in the newly deserialized object.
Due to the returns for the game mode no longer being limited to the documented values starting with Version 1.8.0 the GameMode value on the PubgMatch will no longer be an Enum and going forward will be a string.
I'm going to create an issue on the documentation repo to get a few things clarified if this is an issue and the API is supposed to be returning a limited amount of values as documented or get them to update their documentation. If this is an error the Enum will return otherwise, we'll be going with a string from now on.
On function matchService.GetMatchPC(match.matchid);
catch JsonException
Error converting value 63676723200 to type 'System.Int32'. Path 'data.attributes.duration'.
After requesting from the server we need to run the response stream through a GZIP decompression stream
Add the is custom match flag to the PubgMatch object to bring the library into line with API version 1.3
Missing Krakin Map From Map Name Enum
Getting the following message when trying to get match info
Name | Value | Type | |
---|---|---|---|
Message | "Unable to find specified resource" | string |
var matchService = new PubgMatchService(apiKey);
var matchInfo = matchService.GetMatch(PubgRegion.PCNorthAmerica, "8ab32840-2254-41cb-9d11-e903cbe709be");
Updated to the latest version, but haven't had a chance to review the source yet.
We need to remove the xbox telemetry converter and treat them the same as any other match
From the API Team:
@here Hey Everyone! During the closed BETA period we received a lot of feedback about the API, and have decided to make some changes before we go live. Namely, we are putting a flow in place now that will allow us to provide more information about players and the lifetime of their account in-game, rather than just fetching information about recent matches. While the information that the API is returning at launch will not be much different than was seen in the early access documentation, this change will allow us to provide more information about players in the near future. This means that:
- The access flow for matches is going to be slightly different. The /matches endpoint that was seen in the original documentation is no longer going to exist and will be replaced by /players and /players/:id endpoints. Included in this data will be a long list of matches that the player has been in within the last 14 days. The idea here is to start returning more player-specific information in the near future. The /matches/:id endpoint will continue to exist as-is.
- This change will make it much easier to determine whether or not you have the most recent match data for a given player, without needing to search through their match history.
- The structure of match and telemetry data will not change
We will be providing updated documentation in the very near future, and will post another announcement before this update is rolled out.
Once the documentation is updated we will need to add a new PubgPlayerService to retrieve player information along with the associated models.
We also need to remove the GetMatches and GetMatchesAsync methods from the PubgMatchService
It would be unfortunate if this project dies. Please add more maintainers if you don't have time to manage it.
It's currently lacking values for maps, game modes, and seasons. All of those are easy to fix by cloning. But it would be nice if the nuget packet gets updated.
We need to create more documentation. We need to cover some basic operations like retrieving matches, players and other entities.
We need to add integration for the built in .net DI.
Desired Syntax
services.AddPubgApi(opts =>
{
opts.ApiKey = "myApiKey";
})
potentially also adding a static method for configuration for people using other solutions
PubgApi.SetApiKey("myApiKey");
Appveyor or VSTS.... whatever
Hello I must wanted to know there i will be able to find killpoints, so I can calculate ratings for players when I search them. Is it not implemented on the models yet or just not available from the API?
Creating a new MatchService, it appears to be throwing an exception when the game mode type is "warmodefpp" or assuming "warmodetpp" (I don't play third person).
Name | Value | Type | |
---|---|---|---|
◢ | InnerException | {System.ArgumentException: Requested value 'warmodefpp' was not found. at Newtonsoft.Json.Utilities.EnumUtils.ParseEnum(Type enumType, String value, Boolean disallowNumber) at Newtonsoft.Json.Converters.StringEnumConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)} | System.Exception {System.ArgumentException} |
Name | Value | Type | |
---|---|---|---|
Message | "Requested value 'warmodefpp' was not found." | string |
Here is an example of a match that throws the error.
var matchService = new PubgMatchService("APIKEYHERE").GetMatch(PubgRegion.PCNorthAmerica,"46661de3-92e4-4842-9500-c2eaed0f7f63")
Implement a telemetry service in order to retrieve telemetry from the API
Note: For some reason the casing on xbox vs PC is different, need to write a json converter or something for this ...
Hello,
I want to inform you that killpoints does get responsed back from the API. You can add a new jsonpropperty to your 'PubgGameModeStats' model. Here is an example of response for the player/season object:
{
"data":{
"type":"playerSeason",
"attributes":{
"gameModeStats":{
"duo":{
"assists":2,
"boosts":2,
"dBNOs":2,
"dailyKills":0,
"damageDealt":1009.8745,
"days":3,
"headshotKills":1,
"heals":8,
"killPoints":1074.6542,
"kills":5,
"longestKill":133.63144,
"longestTimeSurvived":1743.825,
"losses":6,
"maxKillStreaks":1,
"mostSurvivalTime":1743.825,
"revives":1,
"rideDistance":7857.7017,
"roadKills":0,
"roundMostKills":3,
"roundsPlayed":6,
"suicides":0,
"teamKills":0,
"timeSurvived":5953.2993,
"top10s":2,
"vehicleDestroys":1,
"walkDistance":9712.629,
"weaponsAcquired":33,
"weeklyKills":5,
"winPoints":1509.8591,
"wins":0
},
"duo-fpp":{
"assists":0,
"boosts":0,
"dBNOs":0,
"dailyKills":0,
"damageDealt":0,
"days":0,
"headshotKills":0,
"heals":0,
"killPoints":0,
"kills":0,
"longestKill":0,
"longestTimeSurvived":0,
"losses":0,
"maxKillStreaks":0,
"mostSurvivalTime":0,
"revives":0,
"rideDistance":0,
"roadKills":0,
"roundMostKills":0,
"roundsPlayed":0,
"suicides":0,
"teamKills":0,
"timeSurvived":0,
"top10s":0,
"vehicleDestroys":0,
"walkDistance":0,
"weaponsAcquired":0,
"weeklyKills":0,
"winPoints":0,
"wins":0
},
"solo":{
"assists":0,
"boosts":0,
"dBNOs":0,
"dailyKills":0,
"damageDealt":0,
"days":0,
"headshotKills":0,
"heals":0,
"killPoints":0,
"kills":0,
"longestKill":0,
"longestTimeSurvived":0,
"losses":0,
"maxKillStreaks":0,
"mostSurvivalTime":0,
"revives":0,
"rideDistance":0,
"roadKills":0,
"roundMostKills":0,
"roundsPlayed":0,
"suicides":0,
"teamKills":0,
"timeSurvived":0,
"top10s":0,
"vehicleDestroys":0,
"walkDistance":0,
"weaponsAcquired":0,
"weeklyKills":0,
"winPoints":0,
"wins":0
},
"solo-fpp":{
"assists":0,
"boosts":0,
"dBNOs":0,
"dailyKills":0,
"damageDealt":0,
"days":0,
"headshotKills":0,
"heals":0,
"killPoints":0,
"kills":0,
"longestKill":0,
"longestTimeSurvived":0,
"losses":0,
"maxKillStreaks":0,
"mostSurvivalTime":0,
"revives":0,
"rideDistance":0,
"roadKills":0,
"roundMostKills":0,
"roundsPlayed":0,
"suicides":0,
"teamKills":0,
"timeSurvived":0,
"top10s":0,
"vehicleDestroys":0,
"walkDistance":0,
"weaponsAcquired":0,
"weeklyKills":0,
"winPoints":0,
"wins":0
},
"squad":{
"assists":10,
"boosts":11,
"dBNOs":15,
"dailyKills":15,
"damageDealt":3683.1875,
"days":2,
"headshotKills":4,
"heals":57,
"killPoints":1238.0754,
"kills":19,
"longestKill":205.73648,
"longestTimeSurvived":1936.159,
"losses":14,
"maxKillStreaks":2,
"mostSurvivalTime":1936.159,
"revives":4,
"rideDistance":19546.547,
"roadKills":0,
"roundMostKills":9,
"roundsPlayed":15,
"suicides":1,
"teamKills":1,
"timeSurvived":11421.584,
"top10s":5,
"vehicleDestroys":1,
"walkDistance":15032.113,
"weaponsAcquired":61,
"weeklyKills":19,
"winPoints":1532.7582,
"wins":1
},
"squad-fpp":{
"assists":0,
"boosts":0,
"dBNOs":0,
"dailyKills":0,
"damageDealt":0,
"days":0,
"headshotKills":0,
"heals":0,
"killPoints":0,
"kills":0,
"longestKill":0,
"longestTimeSurvived":0,
"losses":0,
"maxKillStreaks":0,
"mostSurvivalTime":0,
"revives":0,
"rideDistance":0,
"roadKills":0,
"roundMostKills":0,
"roundsPlayed":0,
"suicides":0,
"teamKills":0,
"timeSurvived":0,
"top10s":0,
"vehicleDestroys":0,
"walkDistance":0,
"weaponsAcquired":0,
"weeklyKills":0,
"winPoints":0,
"wins":0
}
}
},
"relationships":{
"matchesDuoFPP":{
"data":[
]
},
"matchesSquad":{
"data":[
{
"type":"match",
"id":"a32e06ef-5bd7-4d06-ab0d-3dbb4ce7bd65"
},
{
"type":"match",
"id":"17e91315-dc86-4858-86d5-ef469215b0b8"
},
{
"type":"match",
"id":"03693880-fcea-4c04-9a75-1e235ddd6af8"
},
{
"type":"match",
"id":"84456e9b-eca4-4086-981f-76f90f2ffb1e"
},
{
"type":"match",
"id":"b7415e80-4826-4cb9-b54c-f015e98944b6"
},
{
"type":"match",
"id":"1c54626b-9342-4617-b230-ab3e03530d4f"
},
{
"type":"match",
"id":"b6b1a4f2-ba65-428a-8aae-34f30593c246"
},
{
"type":"match",
"id":"9c21ce77-5bae-4be0-8348-ddeb92e38bbe"
},
{
"type":"match",
"id":"ecaf4ab7-0b54-4330-b7d8-a41bcd2fad65"
},
{
"type":"match",
"id":"d77b1ebe-8ed1-460e-aee7-dd9134120805"
},
{
"type":"match",
"id":"a1ece7f7-049c-40e3-aac2-b1b02f5b3cd6"
},
{
"type":"match",
"id":"9c426ea9-d43b-4938-8c70-f192c4cac663"
},
{
"type":"match",
"id":"969903e8-139d-41de-9124-02a25881feee"
},
{
"type":"match",
"id":"de8fbddc-f9ee-4d93-a0f7-2424eb813e6d"
},
{
"type":"match",
"id":"a4c264f5-08ff-498e-9806-eac6ec54e106"
}
]
},
"matchesSquadFPP":{
"data":[
]
},
"season":{
"data":{
"type":"season",
"id":"division.bro.official.2018-05"
}
},
"player":{
"data":{
"type":"player",
"id":"account.ba5d32b3d4d84625990d6e5528e16c48"
}
},
"matchesSolo":{
"data":[
]
},
"matchesSoloFPP":{
"data":[
]
},
"matchesDuo":{
"data":[
{
"type":"match",
"id":"5827fe44-e39a-429d-9bcb-feeeed251969"
},
{
"type":"match",
"id":"a15e3a20-9d18-48ac-8fd5-8ae6fe5bff9b"
},
{
"type":"match",
"id":"5ac47e70-1e6b-46ef-8a50-d968233c7554"
},
{
"type":"match",
"id":"9ab99c69-f96f-488a-9035-508077975883"
},
{
"type":"match",
"id":"884436e0-236c-4557-8932-751a1512c259"
},
{
"type":"match",
"id":"81bdf95f-2edd-4889-86f9-98aa68f7ffab"
}
]
}
}
},
"links":{
"self":"https://api.playbattlegrounds.com/shards/pc-eu/players/account.ba5d32b3d4d84625990d6e5528e16c48/seasons/division.bro.official.2018-05"
},
"meta":{
}
}
Hello,
We have the information when a player kill another one but not when the player DBNO another player.
We don't have the weapon information. Is it possible to have information about a dbno like a kill ?
thank
Hello everyone,
For everyone following the development of the api on either the mailing list or the official api discord you'll know that there is a rather large update coming today (03/10/18) the main feature of this is a changing of the PC URL's to include the platforms rather than the region. This means that there are now different URLs for accessing matches on the PC and Xbox and as such there will be a small change in how this library is now called. Rather than the traditional
matchService.GetMatch(PubgRegion.PCEurope, "MatchID");
Which we use today there will now be two different methods, one for PC and one for Xbox and they will be suffixed as such
matchService.GetMatchPC(PubgPlatform.Steam, "matchID");
matchService.GetMatchXbox(PubgRegion.XboxEurope, "MatchID");
This also may take a little bit of time to get into your hands as there will need to be some sort of testing done once the API goes live. Luckily the suite of tests should be enough to run but we don't have clear information on how things like match samples will be affected by this change so there could be a case of some trial or error in the testing phase.
Sorry for any inconvienience this has caused and we'll look to get 2.0.0 into your hands ASAP
Hi
I get nullrefex when i want to use getplayers. Here: playerService.GetPlayersAsync(PubgRegion.PCEurope, request) - at Pubg.Net.Infrastructure.RequestBuilder.BuildRequestUrl (System.String baseUrl, Pubg.Net.Services.PubgRequest request)
Error converting value "DihorOtok_Main" to type 'Pubg.Net.PubgMap'. Path 'data.attributes.mapName'.
Requested value 'DihorOtok_Main' was not found.
Why are matchids empty?
The conquest, esports, war and zombie items are missing. [Do you want a PR, or is this repo no longer maintained?]
Hello. First of all, thank you for your NuGet.
My problem is i cant find GetPubgMatchesRequest.
And GetPlayers always run into nullref ex.
Im developing Xamarin.Forms app.
In the telemetry JSON, there is a Common element that stores some common information. There is currently not a data structure for this.
The samples endpoint has just been released which allows people to get a sample of matches. Write a PubgSampleService with sync/async paths to request a sample of matches
I think we should have an enum for the regions instead of having to memorize. Either 2 different enums for each platform or just a joint enum.
I'll start working on this if I get the time.
(I'm just gonna help with tweaks and make the API easier to use ?)
Savage please add in Models/Match/PubgMap.cs
i have catch
Error converting value "Savage_Main" to type 'Pubg.Net.PubgMap'. Path 'data.attributes.mapName'.
Data version 1.2.0 has been released! Some new data has been added (for PC) for swim events, vehicle events, and armor destruction. Check out the details here: https://documentation.playbattlegrounds.com/en/changelog/changelog.html#v1-2-0
I've updated the JsonApiSerializer package from 1.3.1 to 1.74 and had a bug where the converters are not being used,
to test a fix I updated the GetPlayersAsync method to add the converter to the JsonApiSerializerSettings and the RelationshipIdConverter is now being used.
var settings = new JsonApiSerializerSettings();
settings.Converters.Add(new RelationshipIdConverter());
public virtual async Task<IEnumerable<PubgPlayer>> GetPlayersAsync(PubgPlatform platform, GetPubgPlayersRequest filter, CancellationToken cancellationToken = default(CancellationToken))
{
var url = RequestBuilder.BuildRequestUrl(Api.Players.PlayersEndpoint(platform), filter);
var apiKey = string.IsNullOrEmpty(filter.ApiKey) ? ApiKey : filter.ApiKey;
var collectionJson = await HttpRequestor.GetStringAsync(url, cancellationToken, apiKey).ConfigureAwait(false);
var settings = new JsonApiSerializerSettings();
settings.Converters.Add(new RelationshipIdConverter());
return JsonConvert.DeserializeObject<IEnumerable<PubgPlayer>>(collectionJson, settings);
}
I have another bug now with the RelationshipIdConverter where var dataToken = jt.SelectToken("data");
is null
I've tried changing this to var dataToken = jt.SelectToken("relationships.matches.data");
that returns
{[
{
"type": "match",
"id": "e14ca749-3c19-49dd-9486-03de90669fa3"
},
{
"type": "match",
"id": "73dbca3e-eeee-44eb-9c43-3f71df0e02ae"
},
{
"type": "match",
"id": "e9f80ed0-1e78-4500-950f-174028fb73cc"
}
]}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
//if the reader is not reading a relationship object just deserialize as normal.
//This allows us to serialize and deserialize multiple times after converting from the Json-API format
if (reader.TokenType != JsonToken.StartObject)
return serializer.Deserialize(reader, objectType);
JToken jt = JToken.Load(reader);
//var dataToken = jt.SelectToken("data");
var dataToken = jt.SelectToken("relationships.matches.data");
if (objectType == typeof(string))
return dataToken["id"].ToString();
return dataToken.Select(x => (string)x["id"]).ToList();
}
but this fails with the error
ArgumentException: The value "System.Collections.Generic.List'1[System.String]" is not of type "PUBGChampionApi.PubgPlayer" and cannot be used in this generic collection. (Parameter 'value')
I'm pretty new to to working with Json Serializing and Deserializing, Anyone able to offer any solution to whats happening?
This is the full Json retuned fro the API
{
"data":[
{
"type":"player",
"id":"account.f96f1d482a5d4a21a4135f598f5a5c6a",
"attributes":{
"name":"Nomad_o7",
"stats":null,
"titleId":"pubg",
"shardId":"steam",
"patchVersion":""
},
"relationships":{
"assets":{
"data":[
]
},
"matches":{
"data":[
{
"type":"match",
"id":"e14ca749-3c19-49dd-9486-03de90669fa3"
},
{
"type":"match",
"id":"73dbca3e-eeee-44eb-9c43-3f71df0e02ae"
},
{
"type":"match",
"id":"e9f80ed0-1e78-4500-950f-174028fb73cc"
}
]
}
},
"links":{
"self":"https://api.pubg.com/shards/steam/players/account.f96f1d482a5d4a21a4135f598f5a5c6a",
"schema":""
}
},
{
"type":"player",
"id":"account.82bad0072f31455d8d9f8d834da2f2f3",
"attributes":{
"name":"TGLTN",
"stats":null,
"titleId":"pubg",
"shardId":"steam",
"patchVersion":""
},
"relationships":{
"assets":{
"data":[
]
},
"matches":{
"data":[
{
"type":"match",
"id":"4a6f064e-c292-4e9b-a3a6-bbaed891ce27"
},
{
"type":"match",
"id":"efd9434c-4116-4b56-815d-e30903b37c23"
},
{
"type":"match",
"id":"c1e56bff-db4c-470b-bb44-3c2068e33245"
},
{
"type":"match",
"id":"44d27efc-3cc6-4935-8bbe-702e4da44744"
},
{
"type":"match",
"id":"be3ebed3-9183-47f1-b4b0-40a2229dd5ff"
}
]
}
},
"links":{
"self":"https://api.pubg.com/shards/steam/players/account.82bad0072f31455d8d9f8d834da2f2f3",
"schema":""
}
}
],
"links":{
"self":"https://api.pubg.com/shards/steam/players?filter[playerNames]=Nomad_o7,TGLTN"
},
"meta":{
}
}
Need to create the tournament service to match up with the newly released tournament endpoint
We need converters to convert enum members to strings for things like GameMode and potentially regions. They should plug into Newtonsoft and convert the enums accordingly at serialization time
At the moment the tests pull from a list of known players as we were unable to request a list of matches or players. With the release of the new sample endpoint, we will be able to pull some matches and get some player id's from those matches.
There is a player death type in the match object for 'logout'. When this appears in the match, the json parser breaks. See error below:
Newtonsoft.Json.JsonSerializationException: 'Error converting value "logout" to type 'Pubg.Net.Models.Participants.PubgParticipantDeathType'. Path 'included[187].attributes.stats.deathType'.'
ArgumentException: Requested value 'logout' was not found.
I have never gone through the process of creating a nuget package, but I believe that could be beneficial for this project.
I would do so, but I don't know the side-effects of somebody who is not the original content owner doing this. But if you'd like, I can take a stab at it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.