Is lang operator working as intended?

search

#1

I just purchased premium api access and right now trying to get it to work with the lang operator.

I am using endpoint https://api.twitter.com/1.1/tweets/search/30day/<…and a valid label here>

Trying out a query that looks like “lang:sv (apple watch) OR tele2” just gives me results in any available language.

However … using a browser to search for it here: https://twitter.com/search?f=tweets&q=lang%3Asv%20(apple%20watch)%20OR%20tele2&src=typd

works perfectly fine…

Am I missing something in the premium API call??


#2

Hej @abstractitsthlm! I believe the issue is with the way you’re running the request. Could you send me your request (with keys/tokens redacted)?

Also, check out this Premium Search tutorial on how to quickly build and run a query using cURL or Twurl.

Hamza


#3

Hi @hmz

This pretty much replicates the issue… just replace the environment and token placeholders.

curl --request POST \
  --url https://api.twitter.com/1.1/tweets/search/30day/<ENV>.json \
  --header 'authorization: Bearer <TOKEN>' \
  --header 'content-type: application/json' \
  --data '{
                "query":"lang:sv tele2 OR (apple watch)",
                "maxResults": "100",
                "fromDate":"201901101000"
                }'

It is a bit unclear from the API documentation exactly how the query should be created in cases like this.
Especially since the query from above actually works perfectly fine on twitter.com.


#4

Hmm, when I run the exact same query I’m able to successfully get the data I request, which leads me to believe the issue may be with your command line only displaying a certain amount of data. Have you tried to run the request with Postman or Insomnia?


#5

Sorry, I am not sure if you understood my issue.
Did you check the data you got back? What languages are the posts marked as?
I do get get data back according the terms, however I get too much. I get tweets that are in English or other languages too, but I specified that I wanted only Swedish results. The lang operator doesn’t seem to work as I would have expected in this case.