Tweeter API: How to write a query to search in User accounts?

Viewed 114

I need to use Tweeter APIs to search User accounts. The best API is in this link.

The Api example is as below:

https://api.twitter.com/1.1/users/search.json?q=soccer

where the q is the query. In the example, it selects the users who has the word "soccer" in their profile's name.

I need to write a query in a way that

  1. It searches for all the users (regardless of their name, so I don't what q should be?)
  2. The account is verified (attribute is verified)
  3. The language is Spanish (attribute status.lang)
  4. The followers_count is bigger than 10,000 (attribute followers_count)

I have tried the below request

https://api.twitter.com/1.1/users/search.json?q=fake&verified=true&followers_count>10000&status.lang=de

But, it is not working

Point:

When you request an account, the response is as below. So, i guess, the query should be written based on this:

[
    {
        "id": 149450476,
        "id_str": "149450476",
        "name": "Nathan Fake",
        "screen_name": "nathanfake",
        "location": "UK",
        "description": "Official Nathan Fake Twitter.\nLIVE/DJ BOOKINGS:\nWorld excl. Americas: Mia Perelmuter - mia@lb-agency.net\nAmericas: Andres Montes - andres@surefireagency.com",
        "url": "Some url",
        "entities": {
            "url": {
                "urls": [
                    {
                        "url": "Some url",
                        "expanded_url": "http://nathanfake.com",
                        "display_url": "nathanfake.com",
                        "indices": [
                            0,
                            23
                        ]
                    }
                ]
            },
            "description": {
                "urls": []
            }
        },
        "protected": false,
        "followers_count": 19819,
        "friends_count": 641,
        "listed_count": 354,
        "created_at": "Sat May 29 09:27:07 +0000 2010",
        "favourites_count": 3619,
        "utc_offset": null,
        "time_zone": null,
        "geo_enabled": true,
        "verified": true,
        "statuses_count": 5006,
        "lang": null,
        "status": {
            "created_at": "Tue May 19 09:09:41 +0000 2020",
            "id": 1262671759951695874,
            "id_str": "1262671759951695874",
            "text": "@DasGiftBerlin they're a delicacy in galicia and portugal.. I wasn't that into it though",
            "truncated": false,
            "entities": {
                "hashtags": [],
                "symbols": [],
                "user_mentions": [
                    {
                        "screen_name": "DasGiftBerlin",
                        "name": "DasGift",
                        "id": 514663060,
                        "id_str": "514663060",
                        "indices": [
                            0,
                            14
                        ]
                    }
                ],
                "urls": []
            },
            "source": "<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>",
            "in_reply_to_status_id": 1262664168857092096,
            "in_reply_to_status_id_str": "1262664168857092096",
            "in_reply_to_user_id": 514663060,
            "in_reply_to_user_id_str": "514663060",
            "in_reply_to_screen_name": "DasGiftBerlin",
            "geo": null,
            "coordinates": null,
            "place": null,
            "contributors": null,
            "is_quote_status": false,
            "retweet_count": 0,
            "favorite_count": 0,
            "favorited": false,
            "retweeted": false,
            "lang": "en"
        },
        "contributors_enabled": false,
        "is_translator": false,
        "is_translation_enabled": false,
        "profile_background_color": "C0DEED",
        "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
        "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
        "profile_background_tile": true,
        "profile_image_url": "http://pbs.twimg.com/profile_images/1239999310181302276/qE-m2d2n_normal.jpg",
        "profile_image_url_https": "https://pbs.twimg.com/profile_images/1239999310181302276/qE-m2d2n_normal.jpg",
        "profile_banner_url": "https://pbs.twimg.com/profile_banners/149450476/1584473432",
        "profile_link_color": "4A913C",
        "profile_sidebar_border_color": "FFFFFF",
        "profile_sidebar_fill_color": "DDEEF6",
        "profile_text_color": "333333",
        "profile_use_background_image": true,
        "has_extended_profile": false,
        "default_profile": false,
        "default_profile_image": false,
        "following": false,
        "follow_request_sent": false,
        "notifications": false,
        "translator_type": "none"
    }
]
1 Answers

I found that the search for users (/users/search API endpoint) does not care about lang:es filter.

One approach to meet your requirement is to search for tweets (/search/tweets.json API endpoint https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets) with query q parameter set as filter:verified and lang parameter set to es. That will return tweets from verified users in Spanish.

From these tweet objects returned by Twitter API, you can select the user objects who have follower_count more than 10000. This customized processing is to be done by you in some programming language. Twitter API does not provide ready made methods to perform such complex queries.

Related