I was able to recreate your case. Unfortunately I don’t have a solution, but thought it might encourage some discussion if someone else also saw this.
At first I thought it might had been an issue with that tweet getting more re-tweets while the API request for re-tweets was being made, but that was not the case. I tried on an older tweet, 1468347983838134274, that was not seeing as much activity and got a similar result of unexpected behavior.
My script in a loop of 10 made a call with current next_token, saved those results, made a call with the previous_token and compared those results to the results of the previous iteration of the loop’s api call with the next_token. Thinking the last iteration values should be the same as a call with ‘previous_token’ in this iteration. That didn’t work.
Second thought was that there was something with the token being invalidated if the APIs calls ‘changed direction’, so I tried
(the ‘direction pivot’ is on page 9. numbering is just for keeping tack of expected results, not used in the api calls)
The idea being the first set of results and the last set of results should be the same. In other words “count up to 10 from 0, then count down from 10 and expect to end at 0”.
This broke in a very weird way where the api only returned 2 “backwards” results before not including a ‘previous_token’.
And the results were not what I would expect in pagination.
I would have expected “forward page 8” and “backward page 8” to be the same. But “backward page 8” had results of “forward page 0” with some offset, “backward page 7” had results of “forward page 0” with NO offset and that was it.
The output of the 10-forward-10-backward is below. For readability I tweaked the response JSON for the ‘data’ key to just be the ID values, instead of the id, name, username dict. I kept the rest of the output, like the token values, intact incase someone could spot a flaw in my pagination that would explain the behavior.
Anyway, hope you get some feedback that helps resolve this seemingly repeatable issue.
2022-01-28 18:32:36 DEBUG FORWARD PAGE 0
2022-01-28 18:32:36 DEBUG https://api.twitter.com:443 “GET /2/tweets/1468347983838134274/retweeted_by?max_results=25 HTTP/1.1” 200 891
2022-01-28 18:32:36 DEBUG {‘data’: [‘1105855292443713537’, ‘245634496’, ‘24807828’, ‘3130347809’, ‘10680442’, ‘981519459306307584’, ‘1233080592’, ‘8657052’, ‘455900925’, ‘364499002’, ‘7153662’, ‘2645987132’, ‘234760327’, ‘203219181’, ‘755352’, ‘539458560’, ‘3769484542’, ‘426039231’, ‘765941712351027200’, ‘14228625’, ‘715598587816620032’, ‘19612717’, ‘49436627’, ‘2543762662’, ‘44961598’], ‘meta’: {‘result_count’: 25, ‘next_token’: ‘7140dibdnow9c7btw480j0b81ofbt02pm0qm9kwlwj5f6’}}
2022-01-28 18:32:36 DEBUG FORWARD PAGE 1
2022-01-28 18:32:36 DEBUG https://api.twitter.com:443 “GET /2/tweets/1468347983838134274/retweeted_by?max_results=25&pagination_token=7140dibdnow9c7btw480j0b81ofbt02pm0qm9kwlwj5f6 HTTP/1.1” 200 940
2022-01-28 18:32:36 DEBUG {‘data’: [‘1253694008611573760’, ‘20698952’, ‘489989624’, ‘15218327’, ‘372081433’, ‘14326197’, ‘1106227004024725505’, ‘198629740’, ‘23600888’, ‘872144505172094976’, ‘17727527’, ‘18749899’, ‘1343610488081379328’, ‘384198613’, ‘14298593’, ‘1408533062’, ‘732041910877978624’, ‘571543394’, ‘108101617’, ‘17927953’, ‘1461625477’, ‘275843300’, ‘1633239618’, ‘3182034907’, ‘14354574’], ‘meta’: {‘result_count’: 25, ‘next_token’: ‘7140dibdnow9c7btw480j0b806g1shcfl2zd80somlfsp’, ‘previous_token’: ‘77qpymm88g5h9vqkluxbzftksoctn4h35rep15w19t0dx’}}
2022-01-28 18:32:36 DEBUG FORWARD PAGE 2
2022-01-28 18:32:37 DEBUG https://api.twitter.com:443 “GET /2/tweets/1468347983838134274/retweeted_by?max_results=25&pagination_token=7140dibdnow9c7btw480j0b806g1shcfl2zd80somlfsp HTTP/1.1” 200 1079
2022-01-28 18:32:37 DEBUG {‘data’: [‘1251617479484493825’, ‘355318675’, ‘805054484’, ‘3184826318’, ‘216058226’, ‘16783281’, ‘2445387283’, ‘1928268895’, ‘850201293003948034’, ‘292068601’, ‘35600300’, ‘18150270’, ‘1333538552496476163’, ‘60267638’, ‘909596695020916737’, ‘914668145801142272’, ‘5749002’, ‘6479502’, ‘17332866’, ‘1575912229’, ‘466611416’, ‘9644882’, ‘1220534589145223169’, ‘52885052’, ‘934627337701920768’], ‘meta’: {‘result_count’: 25, ‘next_token’: ‘7140dibdnow9c7btw480j0b8060qxe6pym59ilupi8304’, ‘previous_token’: ‘77qpymm88g5h9vqkluxbzftkr6l1n0y9yxjax8grhpl4g’}}
2022-01-28 18:32:37 DEBUG FORWARD PAGE 3
2022-01-28 18:32:37 DEBUG https://api.twitter.com:443 “GET /2/tweets/1468347983838134274/retweeted_by?max_results=25&pagination_token=7140dibdnow9c7btw480j0b8060qxe6pym59ilupi8304 HTTP/1.1” 200 1044
2022-01-28 18:32:37 DEBUG {‘data’: [‘8814212’, ‘540640674’, ‘2660241685’, ‘11604242’, ‘2316095946’, ‘437984839’, ‘14414720’, ‘1137715867’, ‘37619775’, ‘376298012’, ‘3107483711’, ‘349208036’, ‘44504483’, ‘17098686’, ‘3216164855’, ‘84987375’, ‘112631234’, ‘1555221686’, ‘27152576’, ‘23278923’, ‘336443569’, ‘65688592’, ‘3478338192’, ‘312384480’, ‘285150493’], ‘meta’: {‘result_count’: 25, ‘next_token’: ‘7140dibdnow9c7btw480j0b8060lj44yclho12jrkdjqq’, ‘previous_token’: ‘77qpymm88g5h9vqkluxbzftkr65polmdveyf4pgv0o0mx’}}
2022-01-28 18:32:37 DEBUG FORWARD PAGE 4
2022-01-28 18:32:37 DEBUG https://api.twitter.com:443 “GET /2/tweets/1468347983838134274/retweeted_by?max_results=25&pagination_token=7140dibdnow9c7btw480j0b8060lj44yclho12jrkdjqq HTTP/1.1” 200 951
2022-01-28 18:32:37 DEBUG {‘data’: [‘353419774’, ‘18849368’, ‘1017586704935464960’, ‘451189887’, ‘208422641’, ‘13104972’, ‘22775788’, ‘16793718’, ‘1227844757813989376’, ‘208086641’, ‘1247736358409351170’, ‘1139046187’, ‘40434410’, ‘45323315’, ‘29837794’, ‘60378902’, ‘1055028384323911682’, ‘65027669’, ‘1202875621’, ‘96602143’, ‘1543761’, ‘2448231’, ‘43503’, ‘696163’, ‘111579405’], ‘meta’: {‘result_count’: 25, ‘next_token’: ‘7140dibdnow9c7btw480iy8adszdnjr7svsdymk1g592v’, ‘previous_token’: ‘77qpymm88g5h9vqkluxbzftkr65ld7hl2mzp2xz434oj7’}}
2022-01-28 18:32:37 DEBUG FORWARD PAGE 5
2022-01-28 18:32:38 DEBUG https://api.twitter.com:443 “GET /2/tweets/1468347983838134274/retweeted_by?max_results=25&pagination_token=7140dibdnow9c7btw480iy8adszdnjr7svsdymk1g592v HTTP/1.1” 200 1002
2022-01-28 18:32:38 DEBUG {‘data’: [‘65399345’, ‘92220058’, ‘485507437’, ‘14723614’, ‘1788441’, ‘31740492’, ‘2657944608’, ‘36551220’, ‘880183289516097536’, ‘56446996’, ‘48003589’, ‘981591766502690818’, ‘21496683’, ‘756197006171779072’, ‘833373698’, ‘377151387’, ‘3450800300’, ‘249361066’, ‘902735146037649408’, ‘49052724’, ‘14603117’, ‘1068443406’, ‘88764989’, ‘788092405’, ‘1468803615544520704’], ‘meta’: {‘result_count’: 25, ‘next_token’: ‘7140dibdnow9c7btw480iy7zmwvgkk3mnxz76rjt15pgx’, ‘previous_token’: ‘77qpymm88g5h9vqkluxbzdqn3bs1tcaccc32zy70kx9h4’}}
2022-01-28 18:32:38 DEBUG FORWARD PAGE 6
2022-01-28 18:32:38 DEBUG https://api.twitter.com:443 “GET /2/tweets/1468347983838134274/retweeted_by?max_results=25&pagination_token=7140dibdnow9c7btw480iy7zmwvgkk3mnxz76rjt15pgx HTTP/1.1” 200 1004
2022-01-28 18:32:38 DEBUG {‘data’: [‘17125397’, ‘1101507945202888706’, ‘791833176314417152’, ‘538512792’, ‘1439117031320735744’, ‘366067504’, ‘1203495444132827136’, ‘109975086’, ‘1085023245718437889’, ‘1109974599012438018’, ‘3313848900’, ‘1445233599263899648’, ‘3565687879’, ‘1010077316’, ‘96015170’, ‘14815682’, ‘27647185’, ‘18051104’, ‘86348953’, ‘14584235’, ‘362089000’, ‘773241147732979712’, ‘242078036’, ‘5614032’, ‘17977180’], ‘meta’: {‘result_count’: 25, ‘next_token’: ‘7140dibdnow9c7btw480iy7zjuzh0avn1xcdxn3hz7iuu’, ‘previous_token’: ‘77qpymm88g5h9vqkluxbzdqcdx0fda750djr7cvbk0vue’}}
2022-01-28 18:32:38 DEBUG FORWARD PAGE 7
2022-01-28 18:32:38 DEBUG https://api.twitter.com:443 “GET /2/tweets/1468347983838134274/retweeted_by?max_results=25&pagination_token=7140dibdnow9c7btw480iy7zjuzh0avn1xcdxn3hz7iuu HTTP/1.1” 200 921
2022-01-28 18:32:38 DEBUG {‘data’: [‘19234236’, ‘197978371’, ‘14432742’, ‘15453583’, ‘247630288’, ‘1119385290731397121’, ‘527884521’, ‘35498483’, ‘2244305374’, ‘458610932’, ‘844705818’, ‘11614102’, ‘114290226’, ‘15559361’, ‘2411730192’, ‘1092936374624370688’, ‘932101266687365121’, ‘173212823’, ‘623354495’, ‘1158665890172461056’, ‘19837512’, ‘1876932115’, ‘166416786’, ‘9035752’, ‘1462560314625458177’], ‘meta’: {‘result_count’: 25, ‘next_token’: ‘7140dibdnow9c7btw480iy7ziduqm5c5ytdlnxboa3msx’, ‘previous_token’: ‘77qpymm88g5h9vqkluxbzdqcav4fskfytofgfgn339s8p’}}
2022-01-28 18:32:38 DEBUG FORWARD PAGE 8
2022-01-28 18:32:39 DEBUG https://api.twitter.com:443 “GET /2/tweets/1468347983838134274/retweeted_by?max_results=25&pagination_token=7140dibdnow9c7btw480iy7ziduqm5c5ytdlnxboa3msx HTTP/1.1” 200 1126
2022-01-28 18:32:39 DEBUG {‘data’: [‘1135536966’, ‘1301306322’, ‘4859475975’, ‘28374587’, ‘929399424’, ‘1623634472’, ‘947601462246326272’, ‘954786982043045888’, ‘1420130200747192322’, ‘2921153492’, ‘1167284611044347904’, ‘1001628052424572928’, ‘966829738714173440’, ‘17962441’, ‘162566080’, ‘873780536’, ‘756551091182002176’, ‘2811954737’, ‘1601393774’, ‘3245486234’, ‘1070870213216874496’, ‘66489136’, ‘1242222318’, ‘2557179222’, ‘601521587’], ‘meta’: {‘result_count’: 25, ‘next_token’: ‘7140dibdnow9c7btw480iy7zidmzxvb2z1qe6h9pcqgqd’, ‘previous_token’: ‘77qpymm88g5h9vqkluxbzdqc9dzqgjmiue4hwifvnvjg7’}}
2022-01-28 18:32:39 DEBUG FORWARD PAGE 9
2022-01-28 18:32:39 DEBUG https://api.twitter.com:443 “GET /2/tweets/1468347983838134274/retweeted_by?max_results=25&pagination_token=7140dibdnow9c7btw480iy7zidmzxvb2z1qe6h9pcqgqd HTTP/1.1” 200 1058
2022-01-28 18:32:39 DEBUG {‘data’: [‘909216829’, ‘1065135901’, ‘232455203’, ‘1302706150694096897’, ‘1453199468132773891’, ‘1431636953263398914’, ‘547294860’, ‘1005541’, ‘714282261869297664’, ‘440079185’, ‘1874836183’, ‘46346652’, ‘473652715’, ‘213169226’, ‘1400062189403136005’, ‘63071573’, ‘3015246739’, ‘26702284’, ‘775884921705340928’, ‘1082015423212765184’, ‘278996803’, ‘782115568065228801’, ‘120841704’, ‘2865194824’, ‘21663770’], ‘meta’: {‘result_count’: 25, ‘next_token’: ‘7140dibdnow9c7btw480iy7zidfgt1hzh8ef5aculrghg’, ‘previous_token’: ‘77qpymm88g5h9vqkluxbzdqc9drzrt9x13d7hs5kwb77d’}}
2022-01-28 18:32:39 DEBUG BACKWARD PAGE 8
2022-01-28 18:32:39 DEBUG https://api.twitter.com:443 “GET /2/tweets/1468347983838134274/retweeted_by?max_results=25&pagination_token=77qpymm88g5h9vqkluxbzdqc9drzrt9x13d7hs5kwb77d HTTP/1.1” 200 901
2022-01-28 18:32:39 DEBUG {‘data’: [‘765941712351027200’, ‘14228625’, ‘715598587816620032’, ‘19612717’, ‘49436627’, ‘2543762662’, ‘44961598’, ‘1253694008611573760’, ‘20698952’, ‘489989624’, ‘15218327’, ‘372081433’, ‘14326197’, ‘1106227004024725505’, ‘198629740’, ‘23600888’, ‘872144505172094976’, ‘17727527’, ‘18749899’, ‘1343610488081379328’, ‘384198613’, ‘14298593’, ‘1408533062’, ‘732041910877978624’, ‘571543394’], ‘meta’: {‘result_count’: 25, ‘next_token’: ‘7140dibdnow9c7btw480j0b806g77irax088znwqvd1rl’, ‘previous_token’: ‘77qpymm88g5h9vqkluxbzftv7fwv8ofkr8mkchpkokc3d’}}
2022-01-28 18:32:39 DEBUG BACKWARD PAGE 7
2022-01-28 18:32:39 DEBUG https://api.twitter.com:443 “GET /2/tweets/1468347983838134274/retweeted_by?max_results=25&pagination_token=77qpymm88g5h9vqkluxbzftv7fwv8ofkr8mkchpkokc3d HTTP/1.1” 200 691
2022-01-28 18:32:39 DEBUG {‘data’: [‘1105855292443713537’, ‘245634496’, ‘24807828’, ‘3130347809’, ‘10680442’, ‘981519459306307584’, ‘1233080592’, ‘8657052’, ‘455900925’, ‘364499002’, ‘7153662’, ‘2645987132’, ‘234760327’, ‘203219181’, ‘755352’, ‘539458560’, ‘3769484542’, ‘426039231’], ‘meta’: {‘result_count’: 18, ‘next_token’: ‘7140dibdnow9c7btw480j0bigfrxj58be6iixlzwjty60’}}