aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2019-04-28 21:15:47 +0200
committerLorenz Diener <[email protected]>2019-04-28 21:15:47 +0200
commitc82b0b19196d5d390419d71e2b45f11ec1c74a05 (patch)
treec0563458afd26ddf9c7ed705fdfbbba9ccdf87ac /mastodon/Mastodon.py
parentc815cdb2128da4b9a96de56f739c1f24bf01755b (diff)
downloadmastodon.py-c82b0b19196d5d390419d71e2b45f11ec1c74a05.tar.gz
Add more parameters to search API
Diffstat (limited to 'mastodon/Mastodon.py')
-rw-r--r--mastodon/Mastodon.py44
1 files changed, 36 insertions, 8 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index 679aac8..dd710b7 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -1090,28 +1090,56 @@ class Mastodon:
1090 ### 1090 ###
1091 # Reading data: Searching 1091 # Reading data: Searching
1092 ### 1092 ###
1093 @api_version("1.1.0", "2.1.0", __DICT_VERSION_SEARCHRESULT) 1093 @api_version("2.8.0", "2.8.0", __DICT_VERSION_SEARCHRESULT)
1094 def search(self, q, resolve=False): 1094 def search(self, q, resolve=True, result_type=None, account_id=None, offset=None, min_id=None, max_id=None):
1095 """ 1095 """
1096 Fetch matching hashtags, accounts and statuses. Will search federated 1096 Fetch matching hashtags, accounts and statuses. Will perform webfinger
1097 instances if resolve is True. Full-text search is only enabled if 1097 lookups if resolve is True. Full-text search is only enabled if
1098 the instance supports it, and is restricted to statuses the logged-in 1098 the instance supports it, and is restricted to statuses the logged-in
1099 user wrote or was mentioned in. 1099 user wrote or was mentioned in.
1100
1101 `result_type` can be one of "accounts", "hashtags" or "statuses", to only
1102 search for that type of object.
1103
1104 Specify `account_id` to only get results from the account with that id.
1105
1106 `offset`, `min_id` and `max_id` can be used to paginate.
1107
1108 Returns a `search result dict`_, with tags as `hashtag dicts`_.
1109 """
1110 return self.search_v2(q, resolve=resolve, result_type=result_type, account_id=account_id,
1111 offset=offset, min_id=min_id, max_id=max_id)
1112
1113 @api_version("1.1.0", "2.1.0", __DICT_VERSION_SEARCHRESULT)
1114 def search_v1(self, q, resolve=False):
1115 """
1116 Identical to `search_v2()`, except in that it does not return
1117 tags as `hashtag dicts`_.
1100 1118
1101 Returns a `search result dict`_. 1119 Returns a `search result dict`_.
1102 """ 1120 """
1103 params = self.__generate_params(locals()) 1121 params = self.__generate_params(locals())
1122 if resolve == False:
1123 del params['resolve']
1104 return self.__api_request('GET', '/api/v1/search', params) 1124 return self.__api_request('GET', '/api/v1/search', params)
1105 1125
1106 @api_version("2.4.3", "2.4.3", __DICT_VERSION_SEARCHRESULT) 1126 @api_version("2.8.0", "2.8.0", __DICT_VERSION_SEARCHRESULT)
1107 def search_v2(self, q, resolve=False): 1127 def search_v2(self, q, resolve=True, result_type=None, account_id=None, offset=None, min_id=None, max_id=None):
1108 """ 1128 """
1109 Identical to `search()`, except in that it returns tags as 1129 Identical to `search_v1()`, except in that it returns tags as
1110 `hashtag dicts`_. 1130 `hashtag dicts`_, has more parameters, and resolves by default.
1111 1131
1112 Returns a `search result dict`_. 1132 Returns a `search result dict`_.
1113 """ 1133 """
1114 params = self.__generate_params(locals()) 1134 params = self.__generate_params(locals())
1135
1136 if resolve == False:
1137 del params['resolve']
1138
1139 if "result_type" in params:
1140 params["type"] = params["result_type"]
1141 del params["result_type"]
1142
1115 return self.__api_request('GET', '/api/v2/search', params) 1143 return self.__api_request('GET', '/api/v2/search', params)
1116 1144
1117 ### 1145 ###
Powered by cgit v1.2.3 (git 2.41.0)