search-tweets-python
search-tweets-python copied to clipboard
Parameter `sort_order` is missing in `gen_request_parameters()` (v2)
Describe the bug
The full-archive search endpoint in v2 of the Twitter API provides the parameter sort_order to sort the Tweets by recency or relevancy (see Twitter API documentation for the full-archive search). The implementation of gen_request_parameters() does not provide this parameter yet but it should.
To Reproduce
import searchtweets
req_params = searchtweets.gen_request_parameters("QUERY", sort_order="relevancy")
Error:
TypeError: gen_request_parameters() got an unexpected keyword argument 'sort_order'
Expected behavior
The function gen_request_parameters() should accept the parameter sort_order.
Workaround
If you want to use the sort_order parameter, you can use the following workaround until the bug is fixed:
import searchtweets
req_params = searchtweets.gen_request_parameters("QUERY", stringify=False)
req_params["sort_order"] = "relevancy"
response = searchtweets.ResultStream(request_parameters=req_params, ...)
The request parameters must be returned as dict instead of a JSON string (stringify=False). Then you can add the parameter sort_order manually.