Skip to content

Commit

Permalink
Merge pull request #222 from apivideo/sort-params-in-analytics
Browse files Browse the repository at this point in the history
Add sort parameters in analytics routes
  • Loading branch information
bot-api-video authored Sep 5, 2024
2 parents 4aa5fdf + a56b989 commit 7a3f72e
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All changes to this project will be documented in this file.

## [2.6.1] - 2024-09-05
- Add sort parameters in analytics endpoints

## [2.6.0] - 2024-07-29
- Add new analytics methods
- Add livestream complete() method
Expand Down
4 changes: 4 additions & 0 deletions docs/api/AnalyticsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Retrieve detailed analytics play-rate and number of impressions segmented by dim
| **breakdown** | **'media-id' \| 'media-type' \| 'continent' \| 'country' \| 'device-type' \| 'operating-system' \| 'browser'**| **yes**| Use this path parameter to define a dimension for segmenting analytics data. You must use `kebab-case` for path parameters. These are the available dimensions: - `media-id`: Returns analytics based on the unique identifiers of a video or a live stream. - `media-type`: 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/). 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/). - `device-type`: Returns analytics based on the type of device used by the viewers. Response values can include: `computer`, `phone`, `tablet`, `tv`, `console`, `wearable`, `unknown`. - `operating-system`: 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`. |
| **from** | **Date**| no| 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` |
| **to** | **Date**| no| 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. |
| **sortBy** | **'metricValue' \| 'dimensionValue'**| no| 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. |
| **sortOrder** | **'asc' \| 'desc'**| no| 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`. |
| **filterBy** | [**FilterBy2**](../model/.md)| no| 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). |
| **currentPage** | **number**| no| Choose the number of search results to return per page. Minimum value: 1 |
| **pageSize** | **number**| no| Results per page. Allowed values 1-100, default is 25. |
Expand Down Expand Up @@ -77,6 +79,8 @@ Retrieve countable metrics like the number of plays or impressions, grouped by t
| **from** | **Date**| no| 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` |
| **to** | **Date**| no| 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. |
| **interval** | **'hour' \| 'day'**| no| 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`. |
| **sortBy** | **'metricValue' \| 'emittedAt'**| no| 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. |
| **sortOrder** | **'asc' \| 'desc'**| no| 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`. |
| **filterBy** | [**FilterBy2**](../model/.md)| no| 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). |
| **currentPage** | **number**| no| Choose the number of search results to return per page. Minimum value: 1 |
| **pageSize** | **number**| no| Results per page. Allowed values 1-100, default is 25. |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@api.video/nodejs-client",
"version": "2.6.0",
"version": "2.6.1",
"description": "api.video nodejs API client",
"keywords": [
"api.video",
Expand Down
2 changes: 1 addition & 1 deletion src/HttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class HttpClient {
this.chunkSize = params.chunkSize;
this.headers = new AxiosHeaders({
Accept: 'application/json, */*;q=0.8',
'AV-Origin-Client': 'nodejs:2.6.0',
'AV-Origin-Client': 'nodejs:2.6.1',
Authorization: this.apiKey ? `Basic ${encode(`${this.apiKey}:`)}` : '',
...(params.applicationName && params.applicationVersion
? {
Expand Down
Loading

0 comments on commit 7a3f72e

Please sign in to comment.