Migrating to version 3#
Important
This page only details changes and additions between versions 2.2.0 and 3.0.0. Make sure to check the changelog for updates beyond v3.0.0.
Breaking changes#
Python 3.6 is no longer supported
Analytics#
The
YouTubeAnalytics
class is now calledAnalytics
The
Analytics
class is now imported asanalytix.Analytics
The
_token
instance attribute is now_tokens
, and stores all tokens as aTokens
object instead of just the access tokenThe
secrets
instance attribute is now aSecrets
object rather than a dictionaryThe
authorized
property alias no longer existsThe
project_id
property no longer existsThe
YouTubeAnalytics.from_file
classmethod is nowAnalytics.with_secrets
The
YouTubeAnalytics.from_dict
classmethod no longer exists- The
authorise
method no longer provides the
store_token
keyword argument – tokens are now always stored (though you can choose where)no longer uses the
requests_oauthlib.OAuth2Session
to handle requests, so you can no longer pass those options
- The
- The
retrieve
method now takes
start_date
as a keyword argument rather than a positional onenow takes
metrics=None
as “all metrics” rather thanmetrics="all"
now raises more specific errors, all of which subclasses of
InvalidRequest
- The
The
daily_analytics
,monthly_analytics
,regional_analytics
, andtop_videos
methods no longer exist
Reports#
The
YouTubeAnalyticsReport
class is now calledReport
The
Report
class is now imported asanalytix.reports.Report
The order of the
data
andtype
positional arguments to the constructor have been swappedProviding a tab as the delimiter in the
to_csv
method now automatically saves the file as a TSVThe
to_dataframe
method will now raise aDataFrameConversionError
if the data contains no rows
Beyond that, most of the backend functionality has been rewritten, and in some cases, completely redesigned.
New features#
Async support#
The
AsyncAnalytics
class provides an asynchonous interface forAnalytics
Report.ato_json
andReport.ato_csv
can be used to write files asynchonously
Typehinting#
analytix is now fully Mypy compliant (strict)
Token refreshing#
analytix is now capable of refreshing access tokens
This can be done manually, but is generally handles automatically
This means you no longer need to reauthorise analytix every hour
Update checks#
analytix now automatically checks for new versions once per session
100% test coverage#
analytix is now has 100% test coverage (about 15% more than version 2)