Skip to content

cURL & Shell Scripts ​

Shell automation for Linux and macOS environments.


1. Setup Environment Variables ​

bash
export API_BASE="https://api.stackvid.dev/api"
export STACKVID_API_KEY="tk_live_YOUR_KEY"

2. Check Wallet Balance ​

bash
curl -s -X GET "${API_BASE}/credits/balance" \
  -H "X-API-Key: ${STACKVID_API_KEY}" | jq .

3. Automated Publish Script (publish.sh) ​

bash
#!/usr/bin/env bash
set -e

VIDEO_FILE="$1"
CAPTION="$2"

if [ -z "$VIDEO_FILE" ] || [ -z "$CAPTION" ]; then
  echo "Usage: ./publish.sh <video_path> <caption text>"
  exit 1
fi

FILE_SIZE=$(wc -c < "$VIDEO_FILE" | tr -d ' ')

# 1. Presigned URL
PRESIGNED=$(curl -s -X POST "${API_BASE}/uploads/presigned-url" \
  -H "X-API-Key: ${STACKVID_API_KEY}" \
  -H "Content-Type: application/json" \
  -d "{\"fileType\":\"VIDEO\",\"contentType\":\"video/mp4\",\"fileSizeBytes\":${FILE_SIZE}}")

UPLOAD_URL=$(echo "$PRESIGNED" | jq -r '.uploadUrl')
PUBLIC_URL=$(echo "$PRESIGNED" | jq -r '.publicUrl')

# 2. PUT binary to uploadUrl
curl -s -X PUT "$UPLOAD_URL" \
  -H "Content-Type: video/mp4" \
  --data-binary "@${VIDEO_FILE}"

# 3. Publish to TikTok
curl -s -X POST "${API_BASE}/tiktok/upload" \
  -H "X-API-Key: ${STACKVID_API_KEY}" \
  -H "Content-Type: application/json" \
  -d "{\"videoUrl\":\"${PUBLIC_URL}\",\"caption\":\"${CAPTION}\",\"privacyLevel\":0}" | jq .

StackVid - Multi-Platform Video & Social Commerce Automation Platform.