Querying the Sklik API

The following classes can be used to query the report API.

class Query(select, from_report, where=None, during=None, granularity=Granularity.TOTAL)[source]

Query for report.

Parameters:
class Condition(column, op, value)[source]

Filter condition.

Parameters:
  • column (str) – Column name.

  • op (Op) – Operator. See Sklik API docs for allowed operators, some fields does not use operator and checks only for equivalence.

  • value (str | int | float | Date | Enum | list[str | int | float | Date | Enum]) – Value or list of values to match.

class Op(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
CONTAINS = 'CONTAINS'

String contains.

ENDS_WITH = 'ENDS_WITH'

String ends with.

EQ = 'EQ'

Equal.

GT = 'GT'

Greater than.

GTE = 'GTE'

Greater than or equal.

LT = 'LT'

Less than.

LTE = 'LTE'

Less than or equal.

NEGATIVE_PHRASE = 'NEGATIVE_PHRASE'

Negative phrase match.

NEQ = 'NEQ'

Not equal.

NOT_CONTAINS = 'NOT_CONTAINS'

String not contains.

NOT_ENDS_WITH = 'NOT_ENDS_WITH'

String does not end with.

NOT_STARTS_WITH = 'NOT_STARTS_WITH'

String does not start with.

PHRASE = 'PHRASE'

Phrase match: string contains all words in the given order. It may contain another characters between them.

STARTS_WITH = 'STARTS_WITH'

String starts with.

class DuringClause[source]

Abstract class for during clause. Use one of:

abstract get_date_from()[source]

Gets the start date.

Return type:

Date

abstract get_date_to()[source]

Gets the end date.

Return type:

Date

abstract get_title()[source]

Get the human readable title of the clause.

Return type:

str

class During[source]
LAST_14_DAYS = LastRange(date_range=DateRange(start=2025-04-29, end=2025-05-12))

Last 14 days, ends with yesterday (always 14 whole days).

LAST_180_DAYS = LastRange(date_range=DateRange(start=2024-11-14, end=2025-05-12))

Last 180 days, ends with yesterday (always 180 whole days).

LAST_30_DAYS = LastRange(date_range=DateRange(start=2025-04-13, end=2025-05-12))

Last 30 days, ends with yesterday (always 30 whole days).

LAST_365_DAYS = LastRange(date_range=DateRange(start=2024-05-13, end=2025-05-12))

Last 365 days, ends with yesterday (always 365 whole days).

LAST_7_DAYS = LastRange(date_range=DateRange(start=2025-05-06, end=2025-05-12))

Last 7 days, ends with yesterday (always whole days).

LAST_8_14_DAYS = LastRange(date_range=DateRange(start=2025-04-29, end=2025-05-05))

Last 8 - 14 days, ends with 8 days before today (always 7 whole days).

LAST_90_DAYS = LastRange(date_range=DateRange(start=2025-02-12, end=2025-05-12))

Last 90 days, ends with yesterday (always 90 whole days).

LAST_BUSINESS_WEEK = LastRange(date_range=DateRange(start=2025-05-05, end=2025-05-09))

Business days in the last week (always 5 whole days).

LAST_MONTH = LastRange(date_range=DateRange(start=2025-04-01, end=2025-04-30))

Last month (always whole month).

LAST_WEEK = LastRange(date_range=DateRange(start=2025-05-05, end=2025-05-11))

Last week, begins on monday (always whole week).

LAST_WEEK_SUN_SAT = LastRange(date_range=DateRange(start=2025-05-04, end=2025-05-10))

Last week, begins on sunday (always whole week).

THIS_MONTH = LastRange(date_range=DateRange(start=2025-05-01, end=2025-05-13))

This month up to today (partial).

THIS_WEEK_MON_TODAY = LastRange(date_range=DateRange(start=2025-05-12, end=2025-05-13))

This week, begins on monday (partial).

THIS_WEEK_SUN_TODAY = LastRange(date_range=DateRange(start=2025-05-11, end=2025-05-13))

This week, begins on sunday (partial).

TODAY = LastRange(date_range=DateRange(start=2025-05-13, end=2025-05-13))

Today.

YESTERDAY = LastRange(date_range=DateRange(start=2025-05-12, end=2025-05-12))

Yesterday.

class DateRange(start, end)[source]

Arbitrary date range.

Parameters:
  • start – Date from. Can be given as string in the YYYY-MM-DD format, or as a datetime.date instance.

  • end – Date to. Can be given as string in the YYYY-MM-DD format, or as a datetime.date instance.

get_date_from()[source]

Gets the start date.

Return type:

Date

get_date_to()[source]

Gets the end date.

Return type:

Date

get_title()[source]

Get the human readable title of the clause.

class LastNDaysRange(n_days, offset=1, title=None)[source]

Last N days range.

Parameters:
  • n_days (int) – Number of days to go back from the offset. Will be used to compute start date.

  • offset (int) – Number of days to go back from today. Will be used to compute end date. The default value of 1 means yesterday.

get_title()[source]

Get the human readable title of the clause.

Return type:

str

class LastNWeeksRange(n_weeks, title=None)[source]

Last N weeks range. This range will use only full weeks starting from the previous week (always relative to current date). Weeks begin on monday.

Parameters:

n_weeks (int) – Number of weeks, shall be 1 or greater.

get_title()[source]

Get the human readable title of the clause.

class Granularity(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
DAILY = 5

Per-day granularity.

MONTHLY = 3

Per month granularity.

QUARTERLY = 2

Per year-quarter granularity.

TOTAL = 0

Sum for the whole date-range.

WEEKLY = 4

Per-week granularity.

YEARLY = 1

Per-year granularity.