=========================================
.. class:: API([auth_handler=None], [host='api.twitter.com'], [cache=None], \
- [api_root='/1'], , [retry_count=0], [retry_delay=0], \
- [retry_errors=None], [timeout=60], [parser=ModelParser], \
+ [retry_count=0], [retry_delay=0], [retry_errors=None], \
+ [timeout=60], [parser=ModelParser], \
[wait_on_rate_limit=False], [proxy=None])
This class provides a wrapper for the API as provided by Twitter.
:param auth_handler: authentication handler to be used
:param host: general API host
:param cache: cache backend to use
- :param api_root: general API path root
:param retry_count: default number of retries to attempt when error occurs
:param retry_delay: number of seconds to wait between retries
:param retry_errors: which HTTP status codes to retry
def __init__(self, auth_handler=None,
host='api.twitter.com', upload_host='upload.twitter.com',
- cache=None, api_root='/1.1', upload_root='/1.1',
- retry_count=0, retry_delay=0, retry_errors=None, timeout=60,
- parser=None, wait_on_rate_limit=False, proxy=''):
+ cache=None, retry_count=0, retry_delay=0, retry_errors=None,
+ timeout=60, parser=None, wait_on_rate_limit=False, proxy=''):
"""
API instance constructor
:param upload_host: url of the upload server,
default: 'upload.twitter.com'
:param cache: Cache to query if a GET method is used, default: None
- :param api_root: suffix of the api version, default: '/1.1'
- :param upload_root: suffix of the upload version, default: '/1.1'
:param retry_count: number of allowed retries, default: 0
:param retry_delay: delay in second between retries, default: 0
:param retry_errors: default: None
self.auth = auth_handler
self.host = host
self.upload_host = upload_host
- self.api_root = api_root
- self.upload_root = upload_root
self.cache = cache
self.retry_count = retry_count
self.retry_delay = retry_delay
api.cached_result = False
# Build the request URL
+ path = f'/1.1/{endpoint}.json'
if upload_api:
- path = f'{api.upload_root}/{endpoint}.json'
url = 'https://' + api.upload_host + path
else:
- path = f'{api.api_root}/{endpoint}.json'
url = 'https://' + api.host + path
if params is None: