zewicz
zewicz

Reputation: 145

How to build a query that includes # and @ in Twitter API v2?

I'm not very good at interpreting how to build a query= with multiple operators. The below examples of attempts that are invalid for the Twitter API v2 . Can someone show me how to make a proper query with multiple operators using the Tweet Count API?

Attempts (title: 'Invalid Request', detail: 'One or more parameters to your request was invalid.',):

https://api.twitter.com/2/tweets/counts/recent?query=#animals OR @animals

https://api.twitter.com/2/tweets/counts/recent?query=(#animals OR @animals)

Working (would like to combine these):

https://api.twitter.com/2/tweets/counts/recent?query=#animals

https://api.twitter.com/2/tweets/counts/recent?query=@animals

Upvotes: 0

Views: 507

Answers (1)

zewicz
zewicz

Reputation: 145

Figured it out. It appears Twitter v2 API requires encoded # (%23), spaces (%20), and @ (%40). The below query is valid:

https://api.twitter.com/2/tweets/counts/recent?query=%23animals%20OR%20%40animals

Upvotes: 1

Related Questions