route1io_connectors.google.sa360 module
SA360 connectors
This module contains code for accessing data from Search Ads 360.
- class BaseColumn(name: str)
Bases:
abc.ABCAbstract base class for column subclasses
- abstract format_payload() dict
Return an appropriately formatted dictionary expected by SA360 API
- class Column(name: str)
Bases:
route1io_connectors.google.sa360.BaseColumnColumn provided by SA360
- format_payload() Dict[str, str]
Return an appropriately formatted dictionary for a normal column as expected by SA360 API
- class FloodlightColumn(name: str)
Bases:
route1io_connectors.google.sa360.BaseColumnCustom floodlight column defined by advertiser in SA360
- format_payload() Dict[str, str]
Return an appropriately formatted dictionary for a floodlight column as expected by SA360 API
- class SearchAds360(access_token: str)
Bases:
objectHigh level Python connection to Search Ads 360
- download_report(fpath: str, file_urls: list) None
Download report to a given local fpath given a list of file_urls
- classmethod from_refresh_token(refresh_token: str, cid: str, csc: str) route1io_connectors.google.sa360.SearchAds360
Returns an instance of SearchAds360 with a valid access token generated from a refresh token and client credentials
- get_request_report(report_id: str) dict
Return response from a given URL via GET request
- n_days(days: int, agency_id: str, report_type: str, advertiser_id: Optional[str] = None, columns: Optional[list] = None, verify_single_timezone: Optional[bool] = None, statistics_currency: str = 'agency', include_removed_entities: Optional[bool] = None, download_format: str = 'csv', pause: int = 5, max_requests: int = 50, silent: bool = True, tmp_directory: Optional[str] = None) None
Return a DataFrame with data going back n days
- post_request_report(agency_id: str, report_type: str, advertiser_id: Optional[str] = None, columns: Optional[list] = None, start_date: Optional[str] = None, end_date: Optional[str] = None, verify_single_timezone: Optional[bool] = None, statistics_currency: str = 'agency', include_removed_entities: Optional[bool] = None, max_rows_per_file: int = 1000000, download_format: str = 'csv') dict
Return response from a POST requested report
- request_and_download_report(fpath: str, agency_id: str, report_type: str, advertiser_id: Optional[str] = None, columns: Optional[list] = None, start_date: Optional[str] = None, end_date: Optional[str] = None, verify_single_timezone: Optional[bool] = None, statistics_currency: str = 'agency', include_removed_entities: Optional[bool] = None, max_rows_per_file: int = 1000000, download_format: str = 'csv', pause: int = 5, max_requests: int = 50, silent: bool = True)
Make a POST request for a report, wait for it to be created and then download it.
- wait_for_report(report_id: str, pause: int = 5, max_requests: int = 50, silent: bool = True) None
Wait until report is finished being created and return response with file URLs
- create_report_payload(agency_id: str, report_type: str, advertiser_id: Optional[str] = None, columns: Optional[list] = None, start_date: Optional[str] = None, end_date: Optional[str] = None, verify_single_time_zone: Optional[bool] = None, statistics_currency: str = 'agency', include_removed_entities: Optional[bool] = None, max_rows_per_file: int = 1000000, download_format: Optional[str] = None) str
Return a serialized JSON string containing how we want an SA360 report formatted
- filter_zero_rows(df: pandas.core.frame.DataFrame, columns: list) pandas.core.frame.DataFrame
Return a DataFrame that has had rows with zero values specified by columns filtered out