How does Twitter's Streaming API match keywords? - twitter

When using the Twitter site streaming API, one must provide keywords in order to initiate the streaming.
If I supply, for example, the keyword "great", would the streaming API return tweets containing something like "ABCDgreat"?
In other words; does the search terms are matched only when they are bounded by spaces?

The search terms are not bounded by spaces.
Using your example, if you provide the keyword "great", the API will return tweets containing "ABCDgreat" in their text. Not even if you put spaces before and after the search term, the effect is like a .trim(). If you need it, you'll have to cleanup afterwards.
You can find here some info from twitter, however it does not address exactly the situation you are describing.
I've been based on hbc for streaming.

Related

YT search API to search for Arabic speaking channels locally in Israel

How can I retrieve all Arabic speaking channels locally in Israel.
Using the API explorer, I don't see such an option.
Which fields are mandatory for search to call the search API?
Is there any way to fulfill this task?
Update:
API Explorer
I couldn't get results
There are lots of parameters in the API v3 Docs for Search that you can play around with, some in particular you might find helpful are:
location
locationRadius
regionCode
relevanceLanguage
and you'll need to set type = "channel" to return only channels.
The only mandatory parameter is part which is what data you want returned from your results. For this search call, you only have one option for part, which is "snippet".
This is the only way to do it simply within your multiple parameters, and it will take 100 quota per search, assuming you have an API key already.
If you press 'Try This API' on the right, it'll even give you code snippets you can copy in a variety of languages, since you didn't specify one in the prompt.
Depending on the language, a call could look like the following:
GET https://youtube.googleapis.com/youtube/v3/search?part=snippet&location=Israel&regionCode=IL&relevanceLanguage=ar&type=channel&key=[YOUR_API_KEY] HTTP/1.1

Does twitter stream API allow filtering by urls?

I am trying to do a filter by urls but no result is being returned.
From the following doc, it shows it is possible https://developer.twitter.com/en/docs/tweets/rules-and-filtering/overview/premium-operators
but I think it's a premium feature. Is this true? If yes then is there any other way to filter by urls without using the premium feature?
Standard Twitter streaming API provide us with 'track' parameter. This is a Standard streaming API parameter (see the doc). It matches Tweets as by phrases as by URLs. A common use case according to the doc:
a common use case where you may want to track all mentions of a particular domain name (i.e., regardless of subdomain or path), you should use “example com” as the track parameter for “example.com”
This parameter value Will match...:
example.comwww.example.com foo.example.com foo.example.com/bar I hope my startup isn’t merely another example of a dot com boom!
I tested the option by means of twitter-hbc library for Java. It works as expected!
To avoid confusion, please, take the note:
The text of the Tweet and some entity fields are considered for matches. Specifically, the text attribute of the Tweet, expanded_url and display_url for links and media, text for hashtags, and screen_name for user mentions are checked for matches.

twitter/tweepy filter tweets that start with a given string

I'm using tweepy stream api now.
I can filter the keyword use the stream.fileter(track=[]) method.
I also want to filter the tweets that starts with a given string.
But he method stream.filter(track=['H']) won't match the tweet 'Hello'
Can i do that and how to do it?
Irnzcig is correct, that kind of restrictions aren't available through twitter Streaming API. What you can do is open a connection to receive all the allowed tweets and filter yourself the ones that start with H
To be more specific, however, Streaming API request parameters is what you're looking for. The link provided in the comment is for the Rest API, while they operate on somewhat similar query input they're vastly different.

Twitter api (Twitter4j). How to get US tweets?

I'm trying to get random stream US tweets by using twitter4j, but it seems there is no way I can do that.
I decided to use streaming api, because it looks like it suits for my purposes, but the thing is. I can get random tweets, using method sample(). But it returns random tweets without any ability to filter US tweets.
So I used filter method without any success, because I have to set track words and it's not actually what I need.
I tried to use not stream api and it seems that it's possible to reach my purpose, but it's bloody hell.
Does anyone know how to subscribe for US tweets in English by using stream twitter api?
Why don't you use filter mechanism in the streamin api? There is an optional parameter that you can specifically set the coordinated wherever you want, then you will be getting only the tweets determined by these coordinates.
You can have a look at following links for further info:
https://dev.twitter.com/docs/api/1.1/post/statuses/filter
https://dev.twitter.com/docs/streaming-apis/parameters#locations
However, there is no way to filter tweets in terms of language yet in Streaming API, but search API has that functionality.
With Search API, if you can live with omitting Alaska/Hawaii and including Toronto you could go with something like (geocode:"41.2,-113.6,1000km" OR geocode:"38.1,-88.3,1600km"). That gives this sort of coverage:
Or just create longer boolean that does what you want..

Twitter Streaming API - combine two predicates

I'd like my Twitter Streaming API to catch all tweets mentioned using some #HashTag within the USA. However, if I use the filter.json service specifying location= &track=, then I get the collective OR. I believe I read somewhere on Stack Overflow that it's by design, but I don't still have that reference.
Is it possible to combine those using AND?
You can't have the API deliver only tweets that match both conditions (AND), but you can collect tweets for either condition (OR), and then only use or save the tweets that match both conditions.

Resources