Hi all,

Attempting to perform recent search for tweets using custom start_time as beow.
However this doesn’t work - am I forming the query wrong?

I am adapting the code from the Github examples (can’t link them unfortunately)

The code works fine before adding start_time Query Parameter.

Thanks,

C

def create_url():
    query = "from:twitterdev start_time:2020-09-18T00:00:00Z  -is:retweet"
    tweet_fields = "tweet.fields=author_id"
    url = "https://api.twitter.com/2/tweets/search/recent?query={}&{}".format(
        query, tweet_fields
    )
    return url

You mean these? GitHub - twitterdev/Twitter-API-v2-sample-code: Sample code for the Twitter API v2 endpoints

start_time and end_time are part of the url parameters, not part of the query - it should work with that change GET /2/tweets/search/recent | Docs | Twitter Developer Platform

1 Like

Thank you very much, that works!

So my url now looks like this as an example:
https://api.twitter.com/2/tweets/search/recent?query=Tesla is:retweet&start_time=2020-09-18T00:00:00Z&tweet.fields=author_id,text,lang

to add a second URL Parameter is it added using the & (just want to check my understanding - ran the url and it works):

https://api.twitter.com/2/tweets/search/recent?query=Tesla is:retweet&start_time=2020-09-18T00:00:00Z&end_time=2020-09-18T01:00:00Z&tweet.fields=author_id,text,lang

Best,
C

2 Likes

Yes, that’s correct - that’s how HTTP GET parameters work.