twitter v1.1 v2 api

免费增值
通过 apidance.pro | 已更新 2 месяца назад | Data
人气

9.7 / 10

延迟

2,337ms

服务等级

100%

Health Check

N/A

返回所有讨论

How to paginate via cursor?

Rapid account: Sourcefrom
sourcefrom
3 месяца назад

Hi,

I tried SearchTimeline endpoint, and noticed the “cursor” API param and two TimelineTimelineCursor entries in the result. Could you give me a quick example of how to properly paginate?

For instance, searching the latest tweets based on a query, and page from the first (latest) page of tweets to the next page till the end of the query result? The documentation is not as clear as I had hoped.

Great work, and thanks for the help!

Rapid account: Sourcefrom
sourcefrom Commented 3 месяца назад

So would the following query (use both “since yesterday” and “Latest”, without "until: today) ensure getting the most recent tweets from yesterday to the present of today? Then I can just paginate via the bottom cursor till I consume the remaining query results?

{“rawQuery”:"(word1 OR word2) lang:en since:2024-03-07 -filter:replies)",“count”:10,“cursor”:"",“querySource”:“typed_query”,“product”:“Latest”,“includePromotedContent”:false}

Thanks again!

Rapid account: Abcdsxg
abcdsxg Commented 3 месяца назад

The search api can only filter by date range, not to the minute.

{“rawQuery”:“until:2024-03-07 since:2024-03-08 search something”,“count”:20,“querySource”:“typed_query”,“product”:“Latest”}

Rapid account: Abcdsxg
abcdsxg Commented 3 месяца назад

Yes, the top of the first page also has a value, and if you use the cursor in this top 1 minute later, the api will only return the new content, which is equivalent to flipping forward.

Rapid account: Sourcefrom
sourcefrom Commented 3 месяца назад

Also is it possible to filter time by hours/minutes instead of dates, such as new tweets within the last 10 minutes?

Rapid account: Sourcefrom
sourcefrom Commented 3 месяца назад

Thanks for the reply. Assuming the following query is used.
{“rawQuery”:"(word1 OR word2) lang:en since:2024-03-01 -filter:replies)",“count”:10,“cursor”:"",“querySource”:“typed_query”,“product”:“Latest”,“includePromotedContent”:false}

Please note the order of retrieval is “Latest” and “Since”, so I assume the tweets are returned in the order of post date, starting from the latest. So the correct pagination logic would be: make the first request, then keep paging with the Bottom cursor till the query result returns empty (end of query results)?

What’s confusing though is after the first request, the Top cursor (as you said for “previous page”) is also non-empty, and one can paginate through the Top cursor and get non-empty results back (which means the first query doesn’t return the most latest tweets?). Such behavior is different from a database cursor, and I am just trying to get a clear understanding of how to properly paginate though the query results so that I don’t end up with missing tweets or duplicate tweets (again this depends on the cursor behavior).

Thanks again for the clarifications!

Rapid account: Abcdsxg
abcdsxg Commented 3 месяца назад
Rapid account: Abcdsxg
abcdsxg Commented 3 месяца назад

There are two TimelineTimelineCursors in the api return

cursorType for Bottom is the cursor to pass to get the next page and cursorType for Top is the cursor to pass to get the previous page, value is the cursor parameter you need.

加入讨论 - 在下面添加评论:

登录/注册以发布新的评论