dowmeister

[TruckersMP API] Possibile bug in player search via API

Recommended Posts

Hi,

 

i'm integrating the player search via TruckersMP api in my app and i've encountered a strange case:

 

Searching for player id 1168240 on https://api.truckersmp.com/v2/player/1168240, it returns the steamID64 as 76561198347861090 but the correct one is 76561198347861093 .

 

Can you help me to understand? :D

 

Thank you!

 

 

Share this post


Link to post
Share on other sites

It seems to be related to steamID64 dimension ( https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER )

 

from Chrome (parsed with JSON extension)

{

error: false,

response: {

id: 1168240,

name: "hristospasoff",

avatar: "https://static.truckersmp.com/avatars/1168240.1493059488.jpg",

joinDate: "2016-11-26 18:37:04",

steamID64: 76561198347861090,

groupName: "Player",

groupID: 1,

permissions: {

isGameAdmin: false,

showDetailedOnWebMaps: false

}}

}

 

The same from react-native, when parsing with JSON.parse 76561198347861093 becomes 76561198347861090 . It's funny :)

 

from Chrome (real response)

 

{"error":false,"response":{"id":1168240,"name":"hristospasoff","avatar":"https:\/\/static.truckersmp.com\/avatars\/1168240.1493059488.jpg","joinDate":"2016-11-26 18:37:04","steamID64":76561198347861093,"groupName":"Player","groupID":1,"permissions":{"isGameAdmin":false,"showDetailedOnWebMaps":false}}}

 

from Chrome - Incognito mode

 

{"error":false,"response":{"id":1168240,"name":"hristospasoff","avatar":"https:\/\/static.truckersmp.com\/avatars\/1168240.1493059488.jpg","joinDate":"2016-11-26 18:37:04","steamID64":76561198347861093,"groupName":"Player","groupID":1,"permissions":{"isGameAdmin":false,"showDetailedOnWebMaps":false}}}

 

from Firefox

 

{"error":false,"response":{"id":1168240,"name":"hristospasoff","avatar":"https:\/\/static.truckersmp.com\/avatars\/1168240.1493059488.jpg","joinDate":"2016-11-26 18:37:04","steamID64":76561198347861093,"groupName":"Player","groupID":1,"permissions":{"isGameAdmin":false,"showDetailedOnWebMaps":false}}}

 

From ARC (Chrome extension to execute web request)

 

api_arc.JPG.5807fcc662ece86cf5194d7a230b9155.JPG

 

I think the fix is to return steamID64 as string and not as integer or add a property as string with same value.

 

  • Upvote 1

Share this post


Link to post
Share on other sites

^Good catch, we'll make sure to fix that issue in the future. (yay for assuming 64bit integers was common these days...)

 

 

edit:

If another developer comes by, check API-8

  • Upvote 2

Share this post


Link to post
Share on other sites
On 25.04.2017 at 3:12 PM, Tuxy Fluffyclaws said:

^Good catch, we'll make sure to fix that issue in the future. (yay for assuming 64bit integers was common these days...)

 

 

edit:

If another developer comes by, check API-8

I just wondered, any developer checked the api-8 ? ^^

Share this post


Link to post
Share on other sites

We're not prioritizing it as we're not using javascript outside non-essential systems.

 

All our API endpoints are primarily for internal use, but left open for others to use, as long as we don't experience any issues with it, we're not going to prioritize it.

 

As for API-8, after some thoughts, it might never be fixed for the same reason as stated above.

  • Thanks 1

Share this post


Link to post
Share on other sites

Ok @Tuxy Fluffyclaws , for those who wants use TruckersMP API via node.js , parsing api response with this package https://www.npmjs.com/package/json-bigint fix it , like below:

 

var resultText = await this.executeRequest('player/' + playerID);

var result = JSONbig.parse(resultText);

 

Edited by dowmeister

Share this post


Link to post
Share on other sites

Just to add to that^

 

If you use axios, you can instantiate it with an override on the transformResponse like so:

{ transformResponse: [data => JSONbig.parse(data)] }

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now