Blog/Tutorials

How to post to TikTok via API in TypeScript

June 13, 2026·9 min readTutorials

Step-by-step guide to connecting TikTok accounts, uploading video files, and publishing posts via the Aether API in TypeScript — including video processing status polling.

Prerequisites

  • An Aether account with an API key (free tier covers 10,000 API calls/month)
  • A TikTok for Developers app (register at developers.tiktok.com)
  • Node.js 18+ and a TypeScript project
  • A video file — TikTok requires video; image posts are not supported via API

Install the SDK

npm install aether

Connect a TikTok account

TikTok uses OAuth 2.0. The easiest way to handle the OAuth flow in your product is a Connect Link — Aether generates a hosted authorization URL and stores the resulting tokens for you. Your user clicks the link, grants permissions, and is redirected back to your app.

import Aether from "aether";

const aether = new Aether({ apiKey: process.env.AETHER_API_KEY });

const link = await aether.connectLinks.create({
  platform: "tiktok",
  redirectUrl: "https://yourapp.com/oauth/tiktok/callback",
});

console.log(link.url); // Send this to your user

After the user completes the OAuth flow, Aether stores the access token and handles automatic token refresh. The connected account appears in your dashboard under Profiles, with a platform: "tiktok" type and a profileId you use in subsequent calls.

Upload a video

TikTok is a video-only platform — all posts require a video file. Upload the file to Aether's media storage first. You get back a mediaKey that references the stored file. Aether handles transcoding verification before passing the file to TikTok.

import fs from "fs";

// Upload the video file — returns a mediaKey you reference at publish time
const { mediaKey } = await aether.media.upload({
  file: fs.createReadStream("./video.mp4"),
  mimeType: "video/mp4",
});

console.log(mediaKey); // e.g. "org_abc123/f47ac10b.mp4"

TikTok accepts MP4 and MOV formats. Recommended specs: H.264 or H.265 codec, 9:16 aspect ratio (1080×1920), 15–60 seconds for standard accounts, up to 10 minutes for creator accounts with the long video feature enabled.

Publish the post

Pass the mediaKey and your caption text to posts.create(). TikTok processes video asynchronously, so the initial status is "publishing"— poll until it transitions to "published" or "failed".

const post = await aether.posts.create({
  profileId: "tiktok_profile_id",
  content: {
    text: "My first TikTok via API! #coding #developer",
  },
  mediaKeys: [mediaKey],
  platforms: { tiktok: {} },
});

// Poll until TikTok has finished processing the video
let status = post.status;
while (status === "publishing") {
  await new Promise((r) => setTimeout(r, 3000));
  const updated = await aether.posts.get(post.id);
  status = updated.status;
}

console.log(status); // "published"

Error handling

TikTok enforces stricter content rules than other platforms. The most common errors you'll hit in production:

// TikTok-specific errors to handle
// POST_LIMIT_REACHED — daily publish quota exceeded (10 posts/day on standard tier)
// VIDEO_TOO_SHORT — minimum 15 seconds for most accounts
// VIDEO_TOO_LONG — maximum varies: 60s standard, 10 min creator accounts
// CAPTION_TOO_LONG — max 2,200 characters including hashtags

try {
  const post = await aether.posts.create({ ... });
} catch (err) {
  if (err.code === "POST_LIMIT_REACHED") {
    // Queue for next day
  } else if (err.code === "VIDEO_TOO_SHORT") {
    // Reject on client side before upload
  }
}

TikTok-specific limits to know

  • Daily post limit: 10 posts/day per account on the standard Content Posting API tier
  • Caption length: 2,200 characters including hashtags (same as Instagram)
  • Hashtag limit: No hard limit, but TikTok recommends 3–5 hashtags
  • Privacy settings: Can be set to Public, Mutual Followers, or Self — defaults to Public
  • Duet and Stitch: Can be enabled/disabled per post via platform overrides

Next steps

Ready to build?

One API for Instagram, TikTok, LinkedIn, Facebook, YouTube, Threads, and Reddit. Free tier, no credit card required.

Get started free →