Skip to content

Commit c5f5562

Browse files
author
Aaron Gonzales
authored
Merge pull request #9 from twitterdev/naming_results_params
updating max_results -> results_per_call in the payload generation
2 parents 37bd67d + 4a9d6db commit c5f5562

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ It can be far easier to specify your information in a configuration file. An exa
117117
[gnip_search_rules]
118118
from_date = 2017-06-01
119119
to_date = 2017-09-01
120-
max_results = 100
120+
results_per_call = 100
121121
pt_rule = beyonce has:hashtags
122122
123123
@@ -230,7 +230,7 @@ what a rule looks like.
230230

231231
.. code:: python
232232
233-
rule = gen_rule_payload("@robotprincessfi", max_results=100) # testing with a sandbox account
233+
rule = gen_rule_payload("@robotprincessfi", results_per_call=100) # testing with a sandbox account
234234
print(rule)
235235
236236
@@ -334,7 +334,7 @@ stop on number of pages to limit your API call usage.
334334
"maxResults":100
335335
},
336336
"tweetify":true,
337-
"max_results":500
337+
"results_per_call":500
338338
}
339339
340340
@@ -464,7 +464,7 @@ method; please see your developer console for details.
464464

465465
.. code:: python
466466
467-
rule = gen_rule_payload("from:jack", from_date="2017-09-01", to_date="2017-10-30", max_results=100)
467+
rule = gen_rule_payload("from:jack", from_date="2017-09-01", to_date="2017-10-30", results_per_call=100)
468468
print(rule)
469469
470470

examples/api_example.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
}
123123
],
124124
"source": [
125-
"rule = gen_rule_payload(\"@robotprincessfi\", max_results=100) # testing with a sandbox account\n",
125+
"rule = gen_rule_payload(\"@robotprincessfi\", results_per_call=100) # testing with a sandbox account\n",
126126
"print(rule)"
127127
]
128128
},
@@ -255,7 +255,7 @@
255255
" \"maxResults\":100\n",
256256
" },\n",
257257
" \"tweetify\":true,\n",
258-
" \"max_results\":500\n",
258+
" \"results_per_call\":500\n",
259259
"}\n"
260260
]
261261
}

examples/readme.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ what a rule looks like.
9191

9292
.. code:: python
9393
94-
rule = gen_rule_payload("@robotprincessfi", max_results=100) # testing with a sandbox account
94+
rule = gen_rule_payload("@robotprincessfi", results_per_call=100) # testing with a sandbox account
9595
print(rule)
9696
9797
@@ -135,7 +135,7 @@ Let's see how it goes:
135135
136136
.. code:: python
137137
138-
tweets = collect_results(rule, max_results=500, result_stream_args=premium_search_args) # change this if you need to
138+
tweets = collect_results(rule, results_per_call=500, result_stream_args=premium_search_args) # change this if you need to
139139
140140
141141
.. parsed-literal::
@@ -195,7 +195,7 @@ stop on number of pages to limit your API call usage.
195195
"maxResults":100
196196
},
197197
"tweetify":true,
198-
"max_results":500
198+
"results_per_call":500
199199
}
200200
201201
@@ -327,7 +327,7 @@ method; please see your developer console for details.
327327

328328
.. code:: python
329329
330-
rule = gen_rule_payload("from:jack", from_date="2017-09-01", to_date="2017-10-30", max_results=100)
330+
rule = gen_rule_payload("from:jack", from_date="2017-09-01", to_date="2017-10-30", results_per_call=100)
331331
print(rule)
332332
333333

twittersearch/api_utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def change_to_count_endpoint(endpoint):
107107
return "https://" + '/'.join(filt_tokens) + '/' + "counts.json"
108108

109109

110-
def gen_rule_payload(pt_rule, max_results=500,
110+
def gen_rule_payload(pt_rule, results_per_call=500,
111111
from_date=None, to_date=None, count_bucket=None,
112112
tag=None,
113113
stringify=True):
@@ -119,7 +119,8 @@ def gen_rule_payload(pt_rule, max_results=500,
119119
pt_rule (str): The string version of a powertrack rule,
120120
e.g., "kanye west has:geo". Accepts multi-line strings
121121
for ease of entry.
122-
max_results (int): max results for the batch.
122+
results_per_call (int): number of tweets or counts returned per API
123+
call. This maps to the ``maxResults`` search API parameter.
123124
Defaults to 500 to reduce API call usage.
124125
from_date (str or None): Date format as specified by
125126
`convert_utc_time` for the starting time of your search.
@@ -140,7 +141,7 @@ def gen_rule_payload(pt_rule, max_results=500,
140141
"""
141142

142143
pt_rule = ' '.join(pt_rule.split()) # allows multi-line strings
143-
payload = {"query": pt_rule, "maxResults": max_results}
144+
payload = {"query": pt_rule, "maxResults": results_per_call}
144145
if to_date:
145146
payload["toDate"] = convert_utc_time(to_date)
146147
if from_date:
@@ -175,7 +176,7 @@ def gen_params_from_config(config_dict):
175176
rule = gen_rule_payload(pt_rule=config_dict["pt_rule"],
176177
from_date=config_dict.get("from_date", None),
177178
to_date=config_dict.get("to_date", None),
178-
max_results=int(config_dict.get("max_results")),
179+
results_per_call=int(config_dict.get("results_per_call")),
179180
count_bucket=config_dict.get("count_bucket", None))
180181

181182
_dict = {"endpoint": endpoint,

0 commit comments

Comments
 (0)