| Title: | Load Data from 'tiktok Marketing API' |
|---|---|
| Description: | Loading data from 'tiktok Marketing API' <https://business-api.tiktok.com/portal> by business centers, advertisers, budgets and reports. |
| Authors: | Alexey Seleznev [aut, cre] (ORCID: <https://orcid.org/0000-0003-0410-7385>), Netpeak [cph] |
| Maintainer: | Alexey Seleznev <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.4 |
| Built: | 2026-05-25 08:18:44 UTC |
| Source: | https://github.com/selesnow/rtiktokads |
Authorization in 'TikTok Marketing API'
tik_auth(username = tik_get_username(), token_path = tik_get_token_path())tik_auth(username = tik_get_username(), token_path = tik_get_token_path())
username |
TikTok login |
token_path |
auth cache folder |
tik_access_token object
Get Ad Groups
tik_get_ad_groups(advertiser_id, fields = NULL)tik_get_ad_groups(advertiser_id, fields = NULL)
advertiser_id |
Advertiser ID. |
fields |
Fields that you want to get. |
tibble with AdGroup meta data
Get Ads
tik_get_ads(advertiser_id, fields = NULL)tik_get_ads(advertiser_id, fields = NULL)
advertiser_id |
Advertiser ID. |
fields |
Fields that you want to get. |
tibble with Ads metadata
Get Authorized Ad Accounts
tik_get_advertiser_accounts()tik_get_advertiser_accounts()
tibble with advertisers name and id
## Not run: advertisers <- tik_get_advertiser_accounts() ## End(Not run)## Not run: advertisers <- tik_get_advertiser_accounts() ## End(Not run)
Use this endpoint to obtain the balance of ad accounts in the Business Center. You can also use this endpoint to obtain the budget of the ad accounts owned by the Business Center in auto-allocation mode.
tik_get_advertiser_balance(bc_id, fields = NULL)tik_get_advertiser_balance(bc_id, fields = NULL)
bc_id |
Business Center ID. |
fields |
A list of additional fields to return in the response. Supported values:
|
tibble with balance and budget info
## Not run: bc <- tik_get_business_centers() acs_balance <- tik_get_advertiser_balance(bc$bc_id) ## End(Not run)## Not run: bc <- tik_get_business_centers() acs_balance <- tik_get_advertiser_balance(bc$bc_id) ## End(Not run)
Get Ad Account Details
tik_get_advertiser_info(advertiser_ids, fields = NULL)tik_get_advertiser_info(advertiser_ids, fields = NULL)
advertiser_ids |
List of advertiser IDs to query. You can obtain Advertiser IDs through the |
fields |
A list of information to be returned. Supported values:
|
tibble with advertisers onfo
## Not run: advertisers <- tik_get_advertiser_accounts() advertisers_info <- tik_get_advertiser_info(advertisers$advertiser_id) ## End(Not run)## Not run: advertisers <- tik_get_advertiser_accounts() advertisers_info <- tik_get_advertiser_info(advertisers$advertiser_id) ## End(Not run)
Get the Partners of a BC
tik_get_bc_partners(bc_id)tik_get_bc_partners(bc_id)
bc_id |
Business Center ID. |
tibble with list of partners
Get Business Centers
tik_get_business_centers()tik_get_business_centers()
tibble with business centers info
## Not run: bc <- tik_get_business_centers() ## End(Not run)## Not run: bc <- tik_get_business_centers() ## End(Not run)
Get Campaigns
tik_get_campaigns(advertiser_id, fields = NULL)tik_get_campaigns(advertiser_id, fields = NULL)
advertiser_id |
Advertiser ID. |
fields |
Fields that you want to get. |
tibble with campaigns metadata
Use this function to create a synchronous report task. This function can currently return the reporting data of up to 20,000 advertisements. If your number of advertisements exceeds 20,000, please use campaign_ids / adgroup_ids / ad_ids as a filter to obtain the reporting data of all advertisements in batches. If you use campaign_ids / adgroup_ids / ad_ids as a filter, you can pass in up to 100 IDs at a time.
tik_get_report( advertiser_id = NULL, advertiser_ids = NULL, bc_id = NULL, service_type = NULL, report_type = "BASIC", data_level = "AUCTION_ADVERTISER", dimensions = c("advertiser_id", "stat_time_day"), metrics = "spend", enable_total_metrics = FALSE, start_date = Sys.Date() - 7, end_date = Sys.Date() - 1, query_lifetime = FALSE, multi_adv_report_in_utc_time = FALSE, order_field = NULL, order_type = NULL )tik_get_report( advertiser_id = NULL, advertiser_ids = NULL, bc_id = NULL, service_type = NULL, report_type = "BASIC", data_level = "AUCTION_ADVERTISER", dimensions = c("advertiser_id", "stat_time_day"), metrics = "spend", enable_total_metrics = FALSE, start_date = Sys.Date() - 7, end_date = Sys.Date() - 1, query_lifetime = FALSE, multi_adv_report_in_utc_time = FALSE, order_field = NULL, order_type = NULL )
advertiser_id |
Advertiser ID. You need to pass in either advertiser_id/advertiser_ids or bc_id.
|
advertiser_ids |
A list of advertiser IDs. |
bc_id |
ID of a Business Center that you have access to. |
service_type |
Ad service type. Not supported when report_type is BC.
|
report_type |
Report type:
|
data_level |
The data level that you'd like to query in reports.
|
dimensions |
Grouping conditions. For example: ("campaign_id", "stat_time_day") indicates that both campaign_id and stat_time_day (days) are grouped. Different report types support different dimensions.
|
metrics |
Metrics to query. Different report types support different metrics. For supported metrics for each report type, see the corresponding articles under Report types. |
enable_total_metrics |
Whether to enable the total added-up data for your requested metrics. When enable_total_metrics is enabled, we will provide the aggregate data for all pages as you query different pages. Under this condition, you only need to specify this field when requesting data for the first page. |
start_date |
Query start date (closed interval) in the format of YYYY-MM-DD. The date is based on the ad account time zone. |
end_date |
Query end date (closed interval) in the format of YYYY-MM-DD. The date is based on the ad account time zone. |
query_lifetime |
Whether to request the lifetime metrics. Default value: False. If query_lifetime = True, the start_date and end_date parameters will be ignored. The lifetime metric name is the same as the normal one. |
multi_adv_report_in_utc_time |
Whether to set the returned metrics in the local timezone of each respective advertiser. |
order_field |
Sorting field. |
order_type |
Sorting order. ASC or DESC. |
To take more details see API documentation
tibble with report data
## Not run: report <- tik_get_report(advertiser_id = '7499750467069771792') ## End(Not run)## Not run: report <- tik_get_report(advertiser_id = '7499750467069771792') ## End(Not run)
Get Auth Cache Folder
tik_get_token_path()tik_get_token_path()
character, cache folder path
Get Auth Username
tik_get_username()tik_get_username()
character, current auth username
Change Session Token Path
tik_set_token_path( token_path = ifelse(getOption("tiktok.auth_cache_mode") == "global", rappdirs::site_data_dir("rtiktokads"), rappdirs::user_cache_dir("rtiktokads")) )tik_set_token_path( token_path = ifelse(getOption("tiktok.auth_cache_mode") == "global", rappdirs::site_data_dir("rtiktokads"), rappdirs::user_cache_dir("rtiktokads")) )
token_path |
auth cache folder |
using for side effect, no return value
Set Session Auth Username
tik_set_username(username)tik_set_username(username)
username |
TikTok login |
using for side effect, no return value