GET search/tweets

Updated on Thu, 2013-03-07 10:35

Returns a collection of relevant Tweets matching a specified query.

Please note that Twitter's search service and, by extension, the Search API is not meant to be an exhaustive source of Tweets. Not all Tweets will be indexed or made available via the search interface.

In API v1.1, the response format of the Search API has been improved to return Tweet objects more similar to the objects you'll find across the REST API and platform. You may need to tolerate some inconsistencies and variance in perspectival values (fields that pertain to the perspective of the authenticating user) and embedded user objects.

To learn how to use Twitter Search effectively, consult our guide to Using the Twitter Search API. See Working with Timelines to learn best practices for navigating results by since_id and max_id.

Resource URL

https://api.twitter.com/1.1/search/tweets.json

Parameters

q required

A UTF-8, URL-encoded search query of 1,000 characters maximum, including operators. Queries may additionally be limited by complexity.

Example Values: @noradio

geocode optional

Returns tweets by users located within a given radius of the given latitude/longitude. The location is preferentially taking from the Geotagging API, but will fall back to their Twitter profile. The parameter value is specified by "latitude,longitude,radius", where radius units must be specified as either "mi" (miles) or "km" (kilometers). Note that you cannot use the near operator via the API to geocode arbitrary locations; however you can use this geocode parameter to search near geocodes directly. A maximum of 1,000 distinct "sub-regions" will be considered when using the radius modifier.

Example Values: 37.781157,-122.398720,1mi

lang optional

Restricts tweets to the given language, given by an ISO 639-1 code. Language detection is best-effort.

Example Values: eu

locale optional

Specify the language of the query you are sending (only ja is currently effective). This is intended for language-specific consumers and the default should work in the majority of cases.

Example Values: ja

result_type optional

Optional. Specifies what type of search results you would prefer to receive. The current default is "mixed." Valid values include:
  * mixed: Include both popular and real time results in the response.
  * recent: return only the most recent results in the response
  * popular: return only the most popular results in the response.

Example Values: mixed, recent, popular

count optional

The number of tweets to return per page, up to a maximum of 100. Defaults to 15. This was formerly the "rpp" parameter in the old Search API.

Example Values: 100

until optional

Returns tweets generated before the given date. Date should be formatted as YYYY-MM-DD. Keep in mind that the search index may not go back as far as the date you specify here.

Example Values: 2012-09-01

since_id optional

Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.

Example Values: 12345

max_id optional

Returns results with an ID less than (that is, older than) or equal to the specified ID.

Example Values: 54321

include_entities optional

The entities node will be disincluded when set to false.

Example Values: false

callback optional

If supplied, the response will use the JSONP format with a callback of the given name. The usefulness of this parameter is somewhat diminished by the requirement of authentication for requests to this endpoint.

Example Values: processTweets

Example Request

GET

https://api.twitter.com/1.1/search/tweets.json?q=%23freebandnames&since_id=24012619984051000&max_id=250126199840518145&result_type=mixed&count=4

  1. {
  2.   "statuses": [
  3.     {
  4.       "coordinates": null,
  5.       "favorited": false,
  6.       "truncated": false,
  7.       "created_at": "Mon Sep 24 03:35:21 +0000 2012",
  8.       "id_str": "250075927172759552",
  9.       "entities": {
  10.         "urls": [
  11.  
  12.         ],
  13.         "hashtags": [
  14.           {
  15.             "text": "freebandnames",
  16.             "indices": [
  17.               20,
  18.               34
  19.             ]
  20.           }
  21.         ],
  22.         "user_mentions": [
  23.  
  24.         ]
  25.       },
  26.       "in_reply_to_user_id_str": null,
  27.       "contributors": null,
  28.       "text": "Aggressive Ponytail #freebandnames",
  29.       "metadata": {
  30.         "iso_language_code": "en",
  31.         "result_type": "recent"
  32.       },
  33.       "retweet_count": 0,
  34.       "in_reply_to_status_id_str": null,
  35.       "id": 250075927172759552,
  36.       "geo": null,
  37.       "retweeted": false,
  38.       "in_reply_to_user_id": null,
  39.       "place": null,
  40.       "user": {
  41.         "profile_sidebar_fill_color": "DDEEF6",
  42.         "profile_sidebar_border_color": "C0DEED",
  43.         "profile_background_tile": false,
  44.         "name": "Sean Cummings",
  45.         "profile_image_url": "http://a0.twimg.com/profile_images/2359746665/1v6zfgqo8g0d3mk7ii5s_normal.jpeg",
  46.         "created_at": "Mon Apr 26 06:01:55 +0000 2010",
  47.         "location": "LA, CA",
  48.         "follow_request_sent": null,
  49.         "profile_link_color": "0084B4",
  50.         "is_translator": false,
  51.         "id_str": "137238150",
  52.         "entities": {
  53.           "url": {
  54.             "urls": [
  55.               {
  56.                 "expanded_url": null,
  57.                 "url": "",
  58.                 "indices": [
  59.                   0,
  60.                   0
  61.                 ]
  62.               }
  63.             ]
  64.           },
  65.           "description": {
  66.             "urls": [
  67.  
  68.             ]
  69.           }
  70.         },
  71.         "default_profile": true,
  72.         "contributors_enabled": false,
  73.         "favourites_count": 0,
  74.         "url": null,
  75.         "profile_image_url_https": "https://si0.twimg.com/profile_images/2359746665/1v6zfgqo8g0d3mk7ii5s_normal.jpeg",
  76.         "utc_offset": -28800,
  77.         "id": 137238150,
  78.         "profile_use_background_image": true,
  79.         "listed_count": 2,
  80.         "profile_text_color": "333333",
  81.         "lang": "en",
  82.         "followers_count": 70,
  83.         "protected": false,
  84.         "notifications": null,
  85.         "profile_background_image_url_https": "https://si0.twimg.com/images/themes/theme1/bg.png",
  86.         "profile_background_color": "C0DEED",
  87.         "verified": false,
  88.         "geo_enabled": true,
  89.         "time_zone": "Pacific Time (US & Canada)",
  90.         "description": "Born 330 Live 310",
  91.         "default_profile_image": false,
  92.         "profile_background_image_url": "http://a0.twimg.com/images/themes/theme1/bg.png",
  93.         "statuses_count": 579,
  94.         "friends_count": 110,
  95.         "following": null,
  96.         "show_all_inline_media": false,
  97.         "screen_name": "sean_cummings"
  98.       },
  99.       "in_reply_to_screen_name": null,
  100.       "source": "<a href=\"http://itunes.apple.com/us/app/twitter/id409789998?mt=12\" rel=\"nofollow\">Twitter for Mac</a>",
  101.       "in_reply_to_status_id": null
  102.     },
  103.     {
  104.       "coordinates": null,
  105.       "favorited": false,
  106.       "truncated": false,
  107.       "created_at": "Fri Sep 21 23:40:54 +0000 2012",
  108.       "id_str": "249292149810667520",
  109.       "entities": {
  110.         "urls": [
  111.  
  112.         ],
  113.         "hashtags": [
  114.           {
  115.             "text": "FreeBandNames",
  116.             "indices": [
  117.               20,
  118.               34
  119.             ]
  120.           }
  121.         ],
  122.         "user_mentions": [
  123.  
  124.         ]
  125.       },
  126.       "in_reply_to_user_id_str": null,
  127.       "contributors": null,
  128.       "text": "Thee Namaste Nerdz. #FreeBandNames",
  129.       "metadata": {
  130.         "iso_language_code": "pl",
  131.         "result_type": "recent"
  132.       },
  133.       "retweet_count": 0,
  134.       "in_reply_to_status_id_str": null,
  135.       "id": 249292149810667520,
  136.       "geo": null,
  137.       "retweeted": false,
  138.       "in_reply_to_user_id": null,
  139.       "place": null,
  140.       "user": {
  141.         "profile_sidebar_fill_color": "DDFFCC",
  142.         "profile_sidebar_border_color": "BDDCAD",
  143.         "profile_background_tile": true,
  144.         "name": "Chaz Martenstein",
  145.         "profile_image_url": "http://a0.twimg.com/profile_images/447958234/Lichtenstein_normal.jpg",
  146.         "created_at": "Tue Apr 07 19:05:07 +0000 2009",
  147.         "location": "Durham, NC",
  148.         "follow_request_sent": null,
  149.         "profile_link_color": "0084B4",
  150.         "is_translator": false,
  151.         "id_str": "29516238",
  152.         "entities": {
  153.           "url": {
  154.             "urls": [
  155.               {
  156.                 "expanded_url": null,
  157.                 "url": "http://bullcityrecords.com/wnng/",
  158.                 "indices": [
  159.                   0,
  160.                   32
  161.                 ]
  162.               }
  163.             ]
  164.           },
  165.           "description": {
  166.             "urls": [
  167.  
  168.             ]
  169.           }
  170.         },
  171.         "default_profile": false,
  172.         "contributors_enabled": false,
  173.         "favourites_count": 8,
  174.         "url": "http://bullcityrecords.com/wnng/",
  175.         "profile_image_url_https": "https://si0.twimg.com/profile_images/447958234/Lichtenstein_normal.jpg",
  176.         "utc_offset": -18000,
  177.         "id": 29516238,
  178.         "profile_use_background_image": true,
  179.         "listed_count": 118,
  180.         "profile_text_color": "333333",
  181.         "lang": "en",
  182.         "followers_count": 2052,
  183.         "protected": false,
  184.         "notifications": null,
  185.         "profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/9423277/background_tile.bmp",
  186.         "profile_background_color": "9AE4E8",
  187.         "verified": false,
  188.         "geo_enabled": false,
  189.         "time_zone": "Eastern Time (US & Canada)",
  190.         "description": "You will come to Durham, North Carolina. I will sell you some records then, here in Durham, North Carolina. Fun will happen.",
  191.         "default_profile_image": false,
  192.         "profile_background_image_url": "http://a0.twimg.com/profile_background_images/9423277/background_tile.bmp",
  193.         "statuses_count": 7579,
  194.         "friends_count": 348,
  195.         "following": null,
  196.         "show_all_inline_media": true,
  197.         "screen_name": "bullcityrecords"
  198.       },
  199.       "in_reply_to_screen_name": null,
  200.       "source": "web",
  201.       "in_reply_to_status_id": null
  202.     },
  203.     {
  204.       "coordinates": null,
  205.       "favorited": false,
  206.       "truncated": false,
  207.       "created_at": "Fri Sep 21 23:30:20 +0000 2012",
  208.       "id_str": "249289491129438208",
  209.       "entities": {
  210.         "urls": [
  211.  
  212.         ],
  213.         "hashtags": [
  214.           {
  215.             "text": "freebandnames",
  216.             "indices": [
  217.               29,
  218.               43
  219.             ]
  220.           }
  221.         ],
  222.         "user_mentions": [
  223.  
  224.         ]
  225.       },
  226.       "in_reply_to_user_id_str": null,
  227.       "contributors": null,
  228.       "text": "Mexican Heaven, Mexican Hell #freebandnames",
  229.       "metadata": {
  230.         "iso_language_code": "en",
  231.         "result_type": "recent"
  232.       },
  233.       "retweet_count": 0,
  234.       "in_reply_to_status_id_str": null,
  235.       "id": 249289491129438208,
  236.       "geo": null,
  237.       "retweeted": false,
  238.       "in_reply_to_user_id": null,
  239.       "place": null,
  240.       "user": {
  241.         "profile_sidebar_fill_color": "99CC33",
  242.         "profile_sidebar_border_color": "829D5E",
  243.         "profile_background_tile": false,
  244.         "name": "Thomas John Wakeman",
  245.         "profile_image_url": "http://a0.twimg.com/profile_images/2219333930/Froggystyle_normal.png",
  246.         "created_at": "Tue Sep 01 21:21:35 +0000 2009",
  247.         "location": "Kingston New York",
  248.         "follow_request_sent": null,
  249.         "profile_link_color": "D02B55",
  250.         "is_translator": false,
  251.         "id_str": "70789458",
  252.         "entities": {
  253.           "url": {
  254.             "urls": [
  255.               {
  256.                 "expanded_url": null,
  257.                 "url": "",
  258.                 "indices": [
  259.                   0,
  260.                   0
  261.                 ]
  262.               }
  263.             ]
  264.           },
  265.           "description": {
  266.             "urls": [
  267.  
  268.             ]
  269.           }
  270.         },
  271.         "default_profile": false,
  272.         "contributors_enabled": false,
  273.         "favourites_count": 19,
  274.         "url": null,
  275.         "profile_image_url_https": "https://si0.twimg.com/profile_images/2219333930/Froggystyle_normal.png",
  276.         "utc_offset": -18000,
  277.         "id": 70789458,
  278.         "profile_use_background_image": true,
  279.         "listed_count": 1,
  280.         "profile_text_color": "3E4415",
  281.         "lang": "en",
  282.         "followers_count": 63,
  283.         "protected": false,
  284.         "notifications": null,
  285.         "profile_background_image_url_https": "https://si0.twimg.com/images/themes/theme5/bg.gif",
  286.         "profile_background_color": "352726",
  287.         "verified": false,
  288.         "geo_enabled": false,
  289.         "time_zone": "Eastern Time (US & Canada)",
  290.         "description": "Science Fiction Writer, sort of. Likes Superheroes, Mole People, Alt. Timelines.",
  291.         "default_profile_image": false,
  292.         "profile_background_image_url": "http://a0.twimg.com/images/themes/theme5/bg.gif",
  293.         "statuses_count": 1048,
  294.         "friends_count": 63,
  295.         "following": null,
  296.         "show_all_inline_media": false,
  297.         "screen_name": "MonkiesFist"
  298.       },
  299.       "in_reply_to_screen_name": null,
  300.       "source": "web",
  301.       "in_reply_to_status_id": null
  302.     },
  303.     {
  304.       "coordinates": null,
  305.       "favorited": false,
  306.       "truncated": false,
  307.       "created_at": "Fri Sep 21 22:51:18 +0000 2012",
  308.       "id_str": "249279667666817024",
  309.       "entities": {
  310.         "urls": [
  311.  
  312.         ],
  313.         "hashtags": [
  314.           {
  315.             "text": "freebandnames",
  316.             "indices": [
  317.               20,
  318.               34
  319.             ]
  320.           }
  321.         ],
  322.         "user_mentions": [
  323.  
  324.         ]
  325.       },
  326.       "in_reply_to_user_id_str": null,
  327.       "contributors": null,
  328.       "text": "The Foolish Mortals #freebandnames",
  329.       "metadata": {
  330.         "iso_language_code": "en",
  331.         "result_type": "recent"
  332.       },
  333.       "retweet_count": 0,
  334.       "in_reply_to_status_id_str": null,
  335.       "id": 249279667666817024,
  336.       "geo": null,
  337.       "retweeted": false,
  338.       "in_reply_to_user_id": null,
  339.       "place": null,
  340.       "user": {
  341.         "profile_sidebar_fill_color": "BFAC83",
  342.         "profile_sidebar_border_color": "615A44",
  343.         "profile_background_tile": true,
  344.         "name": "Marty Elmer",
  345.         "profile_image_url": "http://a0.twimg.com/profile_images/1629790393/shrinker_2000_trans_normal.png",
  346.         "created_at": "Mon May 04 00:05:00 +0000 2009",
  347.         "location": "Wisconsin, USA",
  348.         "follow_request_sent": null,
  349.         "profile_link_color": "3B2A26",
  350.         "is_translator": false,
  351.         "id_str": "37539828",
  352.         "entities": {
  353.           "url": {
  354.             "urls": [
  355.               {
  356.                 "expanded_url": null,
  357.                 "url": "http://www.omnitarian.me",
  358.                 "indices": [
  359.                   0,
  360.                   24
  361.                 ]
  362.               }
  363.             ]
  364.           },
  365.           "description": {
  366.             "urls": [
  367.  
  368.             ]
  369.           }
  370.         },
  371.         "default_profile": false,
  372.         "contributors_enabled": false,
  373.         "favourites_count": 647,
  374.         "url": "http://www.omnitarian.me",
  375.         "profile_image_url_https": "https://si0.twimg.com/profile_images/1629790393/shrinker_2000_trans_normal.png",
  376.         "utc_offset": -21600,
  377.         "id": 37539828,
  378.         "profile_use_background_image": true,
  379.         "listed_count": 52,
  380.         "profile_text_color": "000000",
  381.         "lang": "en",
  382.         "followers_count": 608,
  383.         "protected": false,
  384.         "notifications": null,
  385.         "profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/106455659/rect6056-9.png",
  386.         "profile_background_color": "EEE3C4",
  387.         "verified": false,
  388.         "geo_enabled": false,
  389.         "time_zone": "Central Time (US & Canada)",
  390.         "description": "Cartoonist, Illustrator, and T-Shirt connoisseur",
  391.         "default_profile_image": false,
  392.         "profile_background_image_url": "http://a0.twimg.com/profile_background_images/106455659/rect6056-9.png",
  393.         "statuses_count": 3575,
  394.         "friends_count": 249,
  395.         "following": null,
  396.         "show_all_inline_media": true,
  397.         "screen_name": "Omnitarian"
  398.       },
  399.       "in_reply_to_screen_name": null,
  400.       "source": "<a href=\"http://twitter.com/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>",
  401.       "in_reply_to_status_id": null
  402.     }
  403.   ],
  404.   "search_metadata": {
  405.     "max_id": 250126199840518145,
  406.     "since_id": 24012619984051000,
  407.     "refresh_url": "?since_id=250126199840518145&q=%23freebandnames&result_type=mixed&include_entities=1",
  408.     "next_results": "?max_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=mixed",
  409.     "count": 4,
  410.     "completed_in": 0.035,
  411.     "since_id_str": "24012619984051000",
  412.     "query": "%23freebandnames",
  413.     "max_id_str": "250126199840518145"
  414.   }
  415. }

Please note that the "results_per_page" field will soon become "count".