Skip to content
TORNLIFE More

API BUG faction-attacks pagination, Missing attack

Started by JaxkStorm [3382206] on in API Development.

2 replies · 73 views · thread synced · 5 days ago · View on torn.com
About this thread

Posts archived: 3 / 3 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
3
Discussion span
→
People posting
2
Likes on archived posts
1
Authority score
50 / 100
Historical score
18 / 100
Story score
24 / 100
Engagement score
42 / 100
JaxkStorm [3382206]

FAO: API Developers

 

Hello!

 

Am implementing some custom reports and such after wars for specific payout etc etc and to do this I heavily rely on a lot of the specific data provided with the faction/attacks endpoint (v2) from the start of the war to the end of the war.

 

It has been working wonderfully except when last war my report 'lost' one attack randomly, after some thorough investigate it seems the 'automatic' pagination links combined with an awkwardly timed attack resulted in the API providing links that left one attack in the 'gap' between pages.

 

I've emitted all previous links to get to the current two as they are not relevant to this issue and can be reproduced easily with just these two.

Reference Data:
Initial API request which provides the _meta > previous link to follow to - https://api.torn.com/v2/faction/attacks?&limit=100&sort=desc&from=1734120000&to=1734145229

Followed through link provided by previous request - https://api.torn.com/v2/faction/attacks?&limit=100&sort=desc&from=1734120000&to=1734133561

 

Missing Attack (redacted attack code):

{
  "id": 343224834,
  "code": "REDACTED",
  "started": 1734133558,
  "ended": 1734133563,
  "attacker": {
    "id": 3404427,
    "name": "UncleLeeLee",
    "level": 35,
    "faction": {
      "id": 51716,
      "name": "Develop (Hiring)"
    }
  },
  "defender": {
    "id": 2855990,
    "name": "Lunarfoxx",
    "level": 22,
    "faction": {
      "id": 49924,
      "name": "OnlyXans Premium"
    }
  },
  "result": "Attacked",
  "respect_gain": 4.48,
  "respect_loss": 1.12,
  "chain": 1,
  "is_interrupted": false,
  "is_stealthed": false,
  "is_raid": false,
  "is_ranked_war": true,
  "modifiers": {
    "fair_fight": 2.02,
    "war": 2,
    "retaliation": 1,
    "group": 1,
    "overseas": 1,
    "chain": 1,
    "warlord": 1
  }
}

 

 

 

As you can see by the timestamps this attack is missed, to verify attack exists you can change the URL to:

https://api.torn.com/v2/faction/attacks?&limit=100&sort=desc&from=1734120000&to=1734133567 and it is the first in the list.

(Not sure how easy this will be for developers to view since you're not in the faction, data for each requested can be sent if that makes it easier.)

 

Omanpx [1906686]

The attack ended past the to timestamp in the call if I'm seeing correct. So it's not missing, but rather timestamps look at attack end time, not start.

JaxkStorm [3382206]

It is missing because the previous call it tells me that is the previous page and should account for that attack.

i do not make the timestamps, they are provided by the API’s _meta previous/next links.

 

But as an update @splent does know about this issue and plans to focus on it in the new year so fingers crossed!