npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tiktok-api-brkfst

v1.0.29

Published

Brkfst-made API for TikTok

Downloads

129

Readme

Introduction

NodeJS Wrapper for the Tik Tok Marketing API using Axios.

Getting Started

TypeScript types are provided for arguments and outputs. As of 1.0.15 the only methods available are the following:

Debug Mode

Enabling Debug mode on the TikTokApi object will log all Http Requests & Responses to the console.

const tikTokApi = new TikTokApi("<TOKEN>", true);
// or for OAuth
const tikTokApi = new TikTokApi(null, true);

Debug mode is false by default.

Auth

createAccessToken

Uses the Tik Tok Developer App Id, App Secret, and OAuth code to create an Access Token on behalf of the user.

example:

const tiktokApi = new TikTokApi(null);
const {
  data: { access_token },
} = await new TikTokAuth(tiktokApi).createAccessToken(
  "<SECRET>",
  "<APP_ID>",
  code
);

getAuthorizedAdAccounts

Uses the Tik Tok Developer App Id, App Secret, and Access Token to request all the Ad Accounts the token has access to.

example:

const tiktokApi = new TikTokApi("<ACCESS_TOKEN>");
const {
  data: { list },
} = await new TikTokAuth(tiktokApi).getAuthorizedAdAccounts(
  "<SECRET>",
  "<APP_ID>"
);

Video

uploadVideoByFile

Uses the Tik Tok Video API to upload a file to Tik Tok Creatives library.

example:

const tiktokApi = new TikTokApi("<ACCESS_TOKEN>");
const tiktokVideo = new TikTokVideo(tiktokApi); // or `new TikTokVideo()` if the API is already instantiated
const { data } = await tiktokVideo.uploadVideoByFile("<FILE_PATH>", {
  advertiser_id: "<ADVERTISER_ID>",
});

Report

getBasicSyncReport

Uses the Tik Tok Synchronous Report API to pull a Basic Report from Tik Tok API.

const tiktokApi = new TikTokApi("<ACCESS_TOKEN>");
const tiktokVideo = new TikTokReport(tiktokApi); // or `new TikTokReport()` if the API is already instantiated
const { data } = await tiktokVideo.getBasicSyncReport({
  advertiser_id: "<ADVERTISER_ID",
  data_level: "AUCTION_CAMPAIGN",
  dimensions: ["campaign_id"],
  metrics: ["spend", "impressions"],
  start_date: "2022-09-05",
  end_date: "2022-09-07",
  filtering: [
    {
      field_name: "campaign_ids",
      filter_type: "IN",
      filter_value: ["<CAMPAIGN_ID>"],
    },
  ],
});

Campaign

getCampaigns

Uses the Tik Tok Campaign API to retrieve Campaigns from Tik Tok API.

const tiktokApi = new TikTokApi("<ACCESS_TOKEN>");
const tiktokCampaign = new TikTokCampaign(tiktokApi); // or `new TikTokReport()` if the API is already instantiated
const { data } = await tiktokCampaign.getCampaigns("<ADVERTISER_ID>", [
  "campaign_id",
  "campaign_name",
  "advertiser_id",
]);

AdGroup

getAdGroups

Uses the Tik Tok AdGroup API to retrieve Ad Groups from Tik Tok API.

const tiktokApi = new TikTokApi("<ACCESS_TOKEN>");
const tiktokAdGroup = new TikTokAdGroup(tiktokApi); // or `new TikTokReport()` if the API is already instantiated
const { data } = await tiktokAdGroup.getAdGroups("<ADVERTISER_ID>", [
  "adgroup_id",
  "adgroup_name",
  "advertiser_id",
]);

Ad

getAds

Uses the Tik Tok Ad API to retrieve Ad from Tik Tok API.

const tiktokApi = new TikTokApi("<ACCESS_TOKEN>");
const tiktokVideo = new TikTokAd(tiktokApi); // or `new TikTokReport()` if the API is already instantiated
const { data } = await tiktokVideo.getAds("<ADVERTISER_ID>", [
  "ad_id",
  "ad_name",
  "advertiser_id",
]);

Ad Account

getAdAccountDetails

Uses the Tik Tok Ad Account API to retrieve Ad Accounts from Tik Tok API.

const tiktokApi = new TikTokApi("<ACCESS_TOKEN>");
const tiktokVideo = new TikTokAdAccount(tiktokApi); // or `new TikTokReport()` if the API is already instantiated
const { data } = await tiktokVideo.getAdDetails(
  ["<ADVERTISER_ID>"],
  ["status", "name"]
);

Build and Test

Run

npm run build

TODO: Automated Test Suite