rvpals
rvpals

Reputation: 189

How to specify a language using Insight API for Twitter from IBM Bluemix Platform

I'm starting to use Insight API for Twitter from IBM Bluemix.

It's hard to find supporting resource for using this. So far I am using CURL and specifically formed URL to query the API service, and the service returns results in JSON format.

Here's an example of the URL I used with CURL to search for some tweets with the API:

https://(my seucrity key)@cdeservice.mybluemix.net:443/api/v1/messages/search?q=$MSFT%28posted:2016-01-01T00:00:00Z,2016-09-01T00:00:00Z%29&size=20

This URL returns a JSON object with tweets with keyword #MSFT, and between the time frame of 2016-1-1 to 2016-9-1, only return 20 tweets.

I would like to add to that link by specifying a language for the tweet to search for, so far I come up empty. Can you please help me ?

I have tried adding the following to the URL and did not do anything:

Thanks.

Upvotes: 0

Views: 64

Answers (1)

Alex da Silva
Alex da Silva

Reputation: 4590

The syntax is lang:en and you need to make sure to include it as part of your query.

I created the following query based on the one you provided in your question:

https://username:[email protected]:443/api/v1/messages/search?q=(%24MSFT%20AND%20posted%3A2016-01-01T00%3A00%3A00Z%2C2016-09-01T00%3A00%3A00Z%20AND%20lang%3Aen)&size=20

The unencoded query is

($MSFT AND posted:2016-01-01T00:00:00Z,2016-09-01T00:00:00Z AND lang:en)

You can find documentation here.

But in this link you can find more details on the syntax, which is:

/api/v1/messages/search?q=QUERY&size=NUMBER&from=NUMBER

Upvotes: 2

Related Questions