Hi,

(Sorry I’m not allowed to include links so the post is not as clear as I expected)

I’m looking for a way to filter tweets returned by the full-archive endpoint by date and location with an academic account.

I noticed that the user interface allows searching tweets this way, specifying the location with ‘near’ (although it doesn’t appear in the advanced search box). For example the following url:

[can’t have link sorry]
twitter.com/search?q=horse%20until%3A2015-12-31%20since%3A2006-01-18%20near%3Adublin

returns tweets for the corresponding dates and location. As far as I know the location is based on the user profile, so not restricted to geo-tagged tweets only.

(I actually discovered this because this is apparently how snscrape [can’t have link] works.

However this seems to be impossible to achieve using the official API v2, because there’s no way to filter by location based on the user profile with the full-archive endpoint [can’t have link].

So apparently the only option currently for what I need is to scrape tweets externally?

I’m confused why the API doesn’t allow something which can be done with the UI? It seems there must be a better way.

There’s probably something that I misunderstood… Thank you in advance for any clarification about this!

The user interfaces is a totally different system than the API, and while there is some overlap the search operators are also different. It’s still worth using the web interface to test queries however, but be aware of the limitations.

The full list of operators for the API are here: Search Tweets - How to build a query | Docs | Twitter Developer Platform but filtering by date is set in the URL parameters, start_time and end_time GET /2/tweets/search/all | Docs | Twitter Developer Platform

Academic Access can filter live tweets using bio_location, but not search for old tweets: Filtered stream - How to build a rule | Docs | Twitter Developer Platform and also this is a text field, not a geo location or tag.

The closest equivalent in the API to near: is place: with the ID of Dublin, Ireland. Which is based on user tagged locations in tweets, not profiles.

1 Like

Thank you for your answer.

I’m surprised that the UI is significantly more flexible than the API wrt location filtering. My use case isn’t so special but apparently it can’t be done with the API (unless restricting to the 1-2% of geo-tagged tweets).

Thanks!

1 Like