npm.io
1.156.1 • Published 2d agoCLI

@dimension-studios/ttk-proxy

Licence
ISC
Version
1.156.1
Deps
6
Size
12 kB
Vulns
0
Weekly
3.0K

@dimension-studios/ttk-proxy

CLI tool for TikTok Proxy API - A simple command-line interface to interact with the TikTok proxy service.

Installation

npm install -g @dimension-studios/ttk-proxy

Configuration

The CLI uses conf to store your API credentials. You can configure it in two ways:

Set the following environment variables:

export TTK_FETCH_API_URL="https://your-api-url.com"
export TTK_FETCH_API_KEY="your-api-key"
export TTK_FETCH_API_SECRET="your-api-secret"

Then run the config command to save them:

ttk-proxy config
2. Using the CLI
ttk-proxy config:set apiUrl "https://your-api-url.com"
ttk-proxy config:set apiKey "your-api-key"
ttk-proxy config:set apiSecret "your-api-secret"
View Current Configuration
ttk-proxy config --show
Clear Configuration
ttk-proxy config --clear

Usage

List TikTok Proxy Tokens

List all available TikTok proxy tokens:

ttk-proxy list
Search shops (by name or slug)

Search shops your API token can access (requires GET /ttk-proxy/shops/search on the Node API):

ttk-proxy shops coffee
Call the TikTok Proxy API

Make a call to the TikTok proxy API with a JSON body:

ttk-proxy call '{"shopId":"your-shop-id","url":"https://api.tiktok.com/endpoint","method":"GET"}'

Example with more complex body:

ttk-proxy call '{
  "shopId": "shop-123",
  "url": "https://api.tiktok.com/v1/shops/products",
  "method": "GET",
  "headers": {
    "Content-Type": "application/json"
  },
  "unofficialApi": {
    "addCookieToHeaders": true,
    "signUrl": true
  }
}'
Base64 Support

You can also pass the JSON body as a base64-encoded string. The CLI will automatically detect and decode it:

# First encode your JSON to base64
echo -n '{"shopId":"shop-123","url":"https://api.tiktok.com/endpoint","method":"GET"}' | base64

# Then pass it directly to the CLI
ttk-proxy call "eyJzaG9wSWQiOiJzaG9wLTEyMyIsInVybCI6Imh0dHBzOi8vYXBpLnRpa3Rvay5jb20vZW5kcG9pbnQiLCJtZXRob2QiOiJHRVQifQ=="

This is useful when copying request bodies from logs or other sources where the JSON is already base64-encoded.

Output

The CLI provides beautiful, color-coded output using @rharkor/logger:

  • Success messages in green
  • Error messages in red
  • Info messages in blue
  • Warning messages in yellow

Example output:

🚀 Calling TikTok Proxy API...
✅ Status: 200 OK

📦 Response:
{
  "code": 0,
  "data": {
    "products": [...]
  },
  "message": "success"
}

API Reference

Commands
ttk-proxy call <body>

Call the TikTok proxy API with a JSON body.

  • Arguments:
    • body (string): Stringified JSON body for the request (can be raw JSON or base64-encoded JSON)
ttk-proxy list

List all TikTok proxy tokens.

ttk-proxy shops <query>

Search shops authorized for your API token (GET /ttk-proxy/shops/search on your Node API). Use at least 2 characters in query.

ttk-proxy get-cookies

Fetch cookies JSON for the given shop ID (calls POST /ttk-proxy/get-cookies).

Manage configuration.

  • Options:
    • -s, --show: Show current configuration
    • -c, --clear: Clear all configuration
ttk-proxy config:set <key> <value>

Set a configuration value.

  • Arguments:
    • key (string): Configuration key (apiUrl, apiKey, or apiSecret)
    • value (string): Configuration value

Development

Setup
# Install dependencies
npm install

# Build the package
npm run build

# Run type checking
npm run type-check

# Development mode (watch)
npm run dev
Testing Locally
# Link the package globally
npm link

# Now you can use ttk-proxy command
ttk-proxy --help

License

ISC

Author

Dimension Studios

Support

For issues and questions, please open an issue on the GitHub repository.

Keywords