Skip to content

Web2Labs/shortcut-api-example-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Shortcut API Python Example

Welcome to the Shortcut API Python example! This project demonstrates how to programmatically access Shortcut's video editing automation features using Python.

πŸš€ Features

  • Upload Videos: seamless multipart upload handling.
  • Real-time Progress: Beautiful progress bar tracking the AI processing stages.
  • Result Retrieval: Automatically fetches download URLs for your edited video, shorts, and subtitles.

πŸ“‹ Prerequisites

  • Python 3.7+ installed on your machine.
  • API Key: You need a Web2Labs Shortcut API key.
    • Go to Web2Labs Shortcut
    • Switch to API Mode in the dashboard.
    • Generate your API key.

πŸ› οΈ Installation

  1. Clone the repository (or download these files).

  2. Install dependencies:

    pip install -r requirements.txt
  3. Set up your API Key: Create a .env file in this directory and add your key:

    SHORTCUT_API_KEY=sk_live_YOUR_ACTUAL_API_KEY_HERE

    (Alternatively, you can set it as a system environment variable)

πŸƒ Usage

Run the script with your video file:

python main.py path/to/your/video.mp4

What happens next?

  1. Upload: The script uploads your video to the Shortcut secure worker cloud.
  2. Processing: You'll see a progress bar as our AI analyzes, cuts, and edits your video.
    Tracking progress for project proj_abc123...
    Processing:  60%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ    | Status: Editing | Stage: AI processing...
    
  3. Results: Once finished, the script prints direct download links for all generated assets.

🧩 Code Overview

  • main.py: The core script.
    • upload_video(): Handles the multipart file upload.
    • poll_status(): Implements smart polling with rate limit handling.
    • get_results(): Fetches the final asset URLs.

πŸ”Œ Library Integration

Want to use this in your own existing Python script? You can import the ShortcutClient class!

  1. Copy main.py to your project (you might want to rename it to shortcut_client.py).
  2. Import and use it:
from shortcut_client import ShortcutClient

# Initialize
client = ShortcutClient(api_key="YOUR_API_KEY")

# Upload
project = client.upload_video("my_video.mp4")

# Poll (blocks until done)
client.poll_status(project['projectId'])

# Get Results
results = client.get_results(project['projectId'])
print(results['mainVideo']['url'])

Check lib_example.py for a complete example.

πŸ“š API Documentation

For complete API reference, including all available configuration options (like generating shorts, subtitles, or using premium cuts), visit our Official API Docs.

🀝 Contributing & Support

Found a bug? Have a feature request?

  • Issues: Please open an issue in this repository.
  • Pull Requests: PRs are welcome! Please make sure your code follows the existing style.

Built with ❀️ by Web2Labs

About

Get started with the shortcut-api using python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages