Skip to content

Commit 23baff1

Browse files
Merge pull request #96 from apivideo/sort-params-in-analytics
Add sort parameters in analytics routes
2 parents f30ea2b + 2977ea7 commit 23baff1

File tree

7 files changed

+65
-6
lines changed

7 files changed

+65
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22
All changes to this project will be documented in this file.
33

4+
## [1.4.1] - 2024-09-05
5+
- Add sort parameters in analytics endpoints
6+
47
## [1.4.0] - 2024-07-29
58
- Add new analytics methods
69
- Add livestream complete() method

apivideo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"""
1010

1111

12-
__version__ = "1.4.0"
12+
__version__ = "1.4.1"
1313

1414
# import ApiVideoClient
1515
from apivideo.auth_api_client import AuthenticatedApiClient

apivideo/api/analytics_api.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ def get_metrics_breakdown(
234234
Keyword Args:
235235
_from (datetime): Use this query parameter to define the starting date-time of the period you want analytics for. - If you do not set a value for `from`, the default assigned value is 1 day ago, based on the `to` parameter. - The maximum value is 30 days ago. - The value you provide should follow the ATOM date-time format: `2024-02-05T00:00:00+01:00` . [optional]
236236
to (datetime): Use this query parameter to define the ending date-time of the period you want analytics for. - If you do not set a value for `to`, the default assigned value is `now`. - The value for `to` is a non-inclusive value: the API returns data **before** the date-time that you set. . [optional]
237+
sort_by (str): Use this parameter to choose which field the API will use to sort the analytics data. These are the available fields to sort by: - `metricValue`: Sorts the results based on the **metric** you selected in your request. - `dimensionValue`: Sorts the results based on the **dimension** you selected in your request. . [optional]
238+
sort_order (str): Use this parameter to define the sort order of results. These are the available sort orders: - `asc`: Sorts the results in ascending order: `A to Z` and `0 to 9`. - `desc`: Sorts the results in descending order: `Z to A` and `9 to 0`. . [optional]
237239
filter_by (FilterBy2): Use this parameter to filter the API's response based on different data dimensions. You can serialize filters in your query to receive more detailed breakdowns of your analytics. - If you do not set a value for `filterBy`, the API returns the full dataset for your project. - The API only accepts the `mediaId` and `mediaType` filters when you call `/data/metrics/play/total` or `/data/buckets/play-total/media-id`. These are the available breakdown dimensions: - `mediaId`: Returns analytics based on the unique identifiers of a video or a live stream. - `mediaType`: Returns analytics based on the type of content. Possible values: `video` and `live-stream`. - `continent`: Returns analytics based on the viewers' continent. The list of supported continents names are based on the [GeoNames public database](https://www.geonames.org/countries/). You must use the ISO-3166 alpha2 format, for example `EU`. Possible values are: `AS`, `AF`, `NA`, `SA`, `AN`, `EU`, `AZ`. - `country`: Returns analytics based on the viewers' country. The list of supported country names are based on the [GeoNames public database](https://www.geonames.org/countries/). You must use the ISO-3166 alpha2 format, for example `FR`. - `deviceType`: Returns analytics based on the type of device used by the viewers. Response values can include: `computer`, `phone`, `tablet`, `tv`, `console`, `wearable`, `unknown`. - `operatingSystem`: Returns analytics based on the operating system used by the viewers. Response values can include `windows`, `mac osx`, `android`, `ios`, `linux`. - `browser`: Returns analytics based on the browser used by the viewers. Response values can include `chrome`, `firefox`, `edge`, `opera`. - `tag`: Returns analytics for videos using this tag. This filter only accepts a single value and is case sensitive. Read more about tagging your videos [here](https://docs.api.video/vod/tags-metadata). . [optional]
238240
current_page (int): Choose the number of search results to return per page. Minimum value: 1. [optional] if omitted the server will use the default value of 1
239241
page_size (int): Results per page. Allowed values 1-100, default is 25.. [optional] if omitted the server will use the default value of 25
@@ -276,6 +278,8 @@ def get_metrics_breakdown(
276278
'breakdown',
277279
'_from',
278280
'to',
281+
'sort_by',
282+
'sort_order',
279283
'filter_by',
280284
'current_page',
281285
'page_size',
@@ -294,6 +298,8 @@ def get_metrics_breakdown(
294298
'enum': [
295299
'metric',
296300
'breakdown',
301+
'sort_by',
302+
'sort_order',
297303
],
298304
'validation': [
299305
]
@@ -320,6 +326,16 @@ def get_metrics_breakdown(
320326
"OPERATING-SYSTEM": "operating-system",
321327
"BROWSER": "browser"
322328
},
329+
('sort_by',): {
330+
331+
"METRICVALUE": "metricValue",
332+
"DIMENSIONVALUE": "dimensionValue"
333+
},
334+
('sort_order',): {
335+
336+
"ASC": "asc",
337+
"DESC": "desc"
338+
},
323339
}
324340
openapi_types = {
325341
'metric':
@@ -330,6 +346,10 @@ def get_metrics_breakdown(
330346
(datetime,),
331347
'to':
332348
(datetime,),
349+
'sort_by':
350+
(str,),
351+
'sort_order':
352+
(str,),
333353
'filter_by':
334354
(FilterBy2,),
335355
'current_page':
@@ -346,6 +366,8 @@ def get_metrics_breakdown(
346366
'breakdown': 'breakdown',
347367
'_from': 'from',
348368
'to': 'to',
369+
'sort_by': 'sortBy',
370+
'sort_order': 'sortOrder',
349371
'filter_by': 'filterBy',
350372
'current_page': 'currentPage',
351373
'page_size': 'pageSize',
@@ -355,6 +377,8 @@ def get_metrics_breakdown(
355377
'breakdown': 'path',
356378
'_from': 'query',
357379
'to': 'query',
380+
'sort_by': 'query',
381+
'sort_order': 'query',
358382
'filter_by': 'query',
359383
'current_page': 'query',
360384
'page_size': 'query',
@@ -423,6 +447,8 @@ def get_metrics_over_time(
423447
_from (datetime): Use this query parameter to define the starting date-time of the period you want analytics for. - If you do not set a value for `from`, the default assigned value is 1 day ago, based on the `to` parameter. - The maximum value is 30 days ago. - The value you provide should follow the ATOM date-time format: `2024-02-05T00:00:00+01:00` . [optional]
424448
to (datetime): Use this query parameter to define the ending date-time of the period you want analytics for. - If you do not set a value for `to`, the default assigned value is `now`. - The value for `to` is a non-inclusive value: the API returns data **before** the date-time that you set. . [optional]
425449
interval (str): Use this query parameter to define how granularity of the data. Possible values: `hour`, `day`. - Default: If no interval specified and the period (different between from and to) ≤ 2 days then hour, otherwise day. - If you do not set a value for `interval`, and the period you set using the `from` and `to` parameters is less than or equals to 2 days, then the default assigned value is `hour`. Otherwise the API sets it to `day`. . [optional]
450+
sort_by (str): Use this parameter to choose which field the API will use to sort the analytics data. These are the available fields to sort by: - `metricValue`: Sorts the results based on the **metric** you selected in your request. - `emittedAt`: Sorts the results based on the **timestamp** of the event in ATOM date-time format. . [optional]
451+
sort_order (str): Use this parameter to define the sort order of results. These are the available sort orders: - `asc`: Sorts the results in ascending order: `A to Z` and `0 to 9`. - `desc`: Sorts the results in descending order: `Z to A` and `9 to 0`. . [optional]
426452
filter_by (FilterBy2): Use this parameter to filter the API's response based on different data dimensions. You can serialize filters in your query to receive more detailed breakdowns of your analytics. - If you do not set a value for `filterBy`, the API returns the full dataset for your project. - The API only accepts the `mediaId` and `mediaType` filters when you call `/data/metrics/play/total` or `/data/buckets/play-total/media-id`. These are the available breakdown dimensions: - `mediaId`: Returns analytics based on the unique identifiers of a video or a live stream. - `mediaType`: Returns analytics based on the type of content. Possible values: `video` and `live-stream`. - `continent`: Returns analytics based on the viewers' continent. The list of supported continents names are based on the [GeoNames public database](https://www.geonames.org/countries/). You must use the ISO-3166 alpha2 format, for example `EU`. Possible values are: `AS`, `AF`, `NA`, `SA`, `AN`, `EU`, `AZ`. - `country`: Returns analytics based on the viewers' country. The list of supported country names are based on the [GeoNames public database](https://www.geonames.org/countries/). You must use the ISO-3166 alpha2 format, for example `FR`. - `deviceType`: Returns analytics based on the type of device used by the viewers. Response values can include: `computer`, `phone`, `tablet`, `tv`, `console`, `wearable`, `unknown`. - `operatingSystem`: Returns analytics based on the operating system used by the viewers. Response values can include `windows`, `mac osx`, `android`, `ios`, `linux`. - `browser`: Returns analytics based on the browser used by the viewers. Response values can include `chrome`, `firefox`, `edge`, `opera`. - `tag`: Returns analytics for videos using this tag. This filter only accepts a single value and is case sensitive. Read more about tagging your videos [here](https://docs.api.video/vod/tags-metadata). . [optional]
427453
current_page (int): Choose the number of search results to return per page. Minimum value: 1. [optional] if omitted the server will use the default value of 1
428454
page_size (int): Results per page. Allowed values 1-100, default is 25.. [optional] if omitted the server will use the default value of 25
@@ -463,6 +489,8 @@ def get_metrics_over_time(
463489
'_from',
464490
'to',
465491
'interval',
492+
'sort_by',
493+
'sort_order',
466494
'filter_by',
467495
'current_page',
468496
'page_size',
@@ -480,6 +508,8 @@ def get_metrics_over_time(
480508
'enum': [
481509
'metric',
482510
'interval',
511+
'sort_by',
512+
'sort_order',
483513
],
484514
'validation': [
485515
]
@@ -500,6 +530,16 @@ def get_metrics_over_time(
500530
"HOUR": "hour",
501531
"DAY": "day"
502532
},
533+
('sort_by',): {
534+
535+
"METRICVALUE": "metricValue",
536+
"EMITTEDAT": "emittedAt"
537+
},
538+
('sort_order',): {
539+
540+
"ASC": "asc",
541+
"DESC": "desc"
542+
},
503543
}
504544
openapi_types = {
505545
'metric':
@@ -510,6 +550,10 @@ def get_metrics_over_time(
510550
(datetime,),
511551
'interval':
512552
(str,),
553+
'sort_by':
554+
(str,),
555+
'sort_order':
556+
(str,),
513557
'filter_by':
514558
(FilterBy2,),
515559
'current_page':
@@ -526,6 +570,8 @@ def get_metrics_over_time(
526570
'_from': 'from',
527571
'to': 'to',
528572
'interval': 'interval',
573+
'sort_by': 'sortBy',
574+
'sort_order': 'sortOrder',
529575
'filter_by': 'filterBy',
530576
'current_page': 'currentPage',
531577
'page_size': 'pageSize',
@@ -535,6 +581,8 @@ def get_metrics_over_time(
535581
'_from': 'query',
536582
'to': 'query',
537583
'interval': 'query',
584+
'sort_by': 'query',
585+
'sort_order': 'query',
538586
'filter_by': 'query',
539587
'current_page': 'query',
540588
'page_size': 'query',

apivideo/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
7575
self.default_headers[header_name] = header_value
7676
self.cookie = cookie
7777

78-
self.default_headers['AV-Origin-Client'] = "python:1.4.0"
78+
self.default_headers['AV-Origin-Client'] = "python:1.4.1"
7979

8080
def __enter__(self):
8181
return self

apivideo/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def to_debug_report(self):
391391
"OS: {env}\n"\
392392
"Python Version: {pyversion}\n"\
393393
"Version of the API: 1\n"\
394-
"SDK Package Version: 1.4.0".\
394+
"SDK Package Version: 1.4.1".\
395395
format(env=sys.platform, pyversion=sys.version)
396396

397397
def get_host_settings(self):

0 commit comments

Comments
 (0)