Sklik Client
- class SklikClient(user_id=None, endpoint='https://api.sklik.cz/drak/json/v5/', max_retries=5, session=None)[source]
Client for accessing the Sklik API.
Performs authentication, session handling, and provides a generic
call()method for calling any other operations in the API. This method can automatically inject session and user IDs as the first parameter.- Parameters:
- call(operation, *args, **kwargs)[source]
Performs the given API call and returns its result.
If the
authenticatedkwarg is set toTrue(or not given at all), this function passes the object withsession(anduserId, if it was set during the creation) as the first argument. You have to omit the argument when performing call.Example:
>>> client = SklikClient(user_id=10) >>> client.login('<api_token>') >>> client.call('client.stats', {'dateFrom': '2020-01-01', 'dateTo': '2020-01-02', 'granularity': 'daily'}) { 'status': 200, 'statusMessage': 'OK', 'report': [ { 'date': '20200101T00:00:00+0000', 'impressions': 0, 'clicks': 0, 'ctr': 0, 'cpc': 0, 'price': 0, 'avgPosition': 0.0, 'conversions': 0, 'conversionRatio': 0, 'conversionAvgPrice': 0, 'conversionValue': 0, 'conversionAvgValue': 0, 'conversionValueRatio': 0, 'transactions': 0, 'transactionAvgPrice': 0, 'transactionAvgValue': 0, 'transactionAvgCount': 0 }, { 'date': '20200102T00:00:00+0000', 'impressions': 0, 'clicks': 0, 'ctr': 0, 'cpc': 0, 'price': 0, 'avgPosition': 0.0, 'conversions': 0, 'conversionRatio': 0, 'conversionAvgPrice': 0, 'conversionValue': 0, 'conversionAvgValue': 0, 'conversionValueRatio': 0, 'transactions': 0, 'transactionAvgPrice': 0, 'transactionAvgValue': 0, 'transactionAvgCount': 0 } ] }
- Parameters:
operation – Name of the Sklik API operation to call, e.g.
keywords.create.args – Arguments of the operation. If
authenticatedisTrue(default), start with the second argument.authenticated – If set to
True(default value), session ID will be passed as the first parameter of the call.include_user_id – If set to
True(default value), user ID will be passed in the first parameter of the call.
- Return type:
- Returns:
Response from the API as a dictionary.
- Raises:
SklikCallError – if the operation did not succeed.
- get_batch_limit(operation, default_limit=100)[source]
Gets the limit of report rows/request entities for the given operation.
This function retrieves the result of
api.limitsoperation, caches it, and tries to look up the limit in the following order:Given the operation in the format
<entity>.<method>(e.g.keywords.update):<entity>.<method>(keywords.update)global.<method>(global.update)Return value of the
default_limitparameter.
- load_limits()[source]
Loads the batch operation limits using the
api.limitscall. Requires the client to be authenticated, because theapi.limitscall requires user authentication.
- property logged_in
- Returns:
Trueif the client is logged in.