Integrations
Integrate pbar.io seamlessly with your favorite tools and languages.
Python Package
The pbar-io Python package provides drop-in replacements for tqdm and rich progress bars, automatically syncing progress to the cloud.
Installation
pip install pbar-io
Usage Examples
Drop-in tqdm Replacement
# Simply change your import - everything else stays the same!from pbar_io import tqdm # Instead of: from tqdm import tqdm
# Use exactly like tqdmfor item in tqdm(range(1000), desc="Processing data"): process(item) # Works with all tqdm featureswith tqdm(total=100, desc="Downloading", unit="MB", unit_scale=True) as pbar: for chunk in download(): pbar.update(len(chunk))
# Nested progress bars (automatic parent-child tracking)for i in tqdm(range(10), desc="Outer"): for j in tqdm(range(100), desc="Inner", leave=False): do_work(i, j)
# Note: Progress bars auto-complete when current >= total# No need to call complete() - it happens automatically!
Track Existing tqdm Instances
from tqdm import tqdm # Your existing tqdm importfrom pbar_io import track_tqdm
# Track an existing tqdm instancepbar = tqdm(range(100), desc="Processing")track_tqdm(pbar) # Now it syncs to pbar.io!
for item in pbar: do_work(item)
# Or use the register function for any progress barfrom pbar_io import register
for item in register(tqdm(range(100))): process(item)
Direct API Client
from pbar_io import ProgressBar
# Create and manage progress bars directlybar = ProgressBar(title="Custom Task", total=500)print(f"Track progress at: {bar.url}")
# Update progressfor i in range(500): do_work(i) bar.increment() # or bar.update(i)
# Set custom metadatabar.metadata = {"stage": "processing", "user": "alice"}
# Cancel if needed (completion is automatic at 100%)bar.cancel() # Mark as cancelled
# Note: No need to call complete() - bars auto-complete# when current >= total
Configuration
import pbar_io
# Configure the clientpbar_io.configure( api_url="https://pbar.io/api", # Default API endpoint api_key="your_api_key", # Optional: for authenticated access batch_updates=True, # Batch updates for performance update_interval=0.5, # Update frequency in seconds)
# Or use environment variables# PBAR_API_URL=https://pbar.io/api# PBAR_API_KEY=your_api_key
JavaScript/TypeScript
🚧 Coming Soon
The JavaScript/TypeScript client library is currently in development. In the meantime, you can use the REST API directly with fetch or axios.
REST API Usage (Available Now)
Using Fetch API
// Create a progress barconst response = await fetch('https://pbar.io/api/bars', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title: "Processing files", total: files.length })})
const bar = await response.json()console.log(`Track progress at: ${bar.url}`)
// Update progressfor (const [index, file] of files.entries()) { await processFile(file) await fetch(`https://pbar.io/api/bars/${bar.slug}`, { method: 'PATCH', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ increment: 1 }) })}
Using Axios
import axios from 'axios'
// Create a progress barconst { data: bar } = await axios.post('https://pbar.io/api/bars', { title: "Uploading", total: 100})
console.log(`Track progress at: ${bar.url}`)
// Update progress during file uploadconst formData = new FormData()formData.append('file', file)
await axios.post('/upload', formData, { onUploadProgress: async (progressEvent) => { const percentCompleted = Math.round( (progressEvent.loaded * 100) / progressEvent.total ) // Update pbar.io await axios.patch(`https://pbar.io/api/bars/${bar.slug}`, { current: percentCompleted }) }})
Shell Scripts & CLI
Bash Functions
# Add to ~/.bashrc or ~/.zshrc
# Create a progress bar and return the slugpbar_create() { local title="${1:-Progress}" local total="${2:-100}" curl -s -X POST https://pbar.io/api/bars \ -H "Content-Type: application/json" \ -d "{\"title\": \"$title\", \"total\": $total}" | \ jq -r '.slug'}
# Update progress barpbar_update() { local slug="$1" local increment="${2:-1}" curl -s -X PATCH "https://pbar.io/api/bars/$slug" \ -H "Content-Type: application/json" \ -d "{\"increment\": $increment}" > /dev/null}
# Usage exampleSLUG=$(pbar_create "Backup" 100)echo "Progress: https://pbar.io/$SLUG"
for i in {1..10}; do # Do work sleep 1 pbar_update "$SLUG" 10done
Make Integration
# Makefile with progress tracking
PBAR_SLUG := $(shell curl -s -X POST https://pbar.io/api/bars \ -H "Content-Type: application/json" \ -d '{"title": "Build Progress", "total": 4}' | jq -r .slug)
.PHONY: all clean build test deploy
all: clean build test deploy @echo "Complete! View progress: https://pbar.io/$(PBAR_SLUG)"
clean: @echo "Cleaning..." @rm -rf dist/ @curl -s -X PATCH "https://pbar.io/api/bars/$(PBAR_SLUG)" \ -H "Content-Type: application/json" -d '{"increment": 1}' > /dev/null
build: @echo "Building..." @npm run build @curl -s -X PATCH "https://pbar.io/api/bars/$(PBAR_SLUG)" \ -H "Content-Type: application/json" -d '{"increment": 1}' > /dev/null
test: @echo "Testing..." @npm test @curl -s -X PATCH "https://pbar.io/api/bars/$(PBAR_SLUG)" \ -H "Content-Type: application/json" -d '{"increment": 1}' > /dev/null
deploy: @echo "Deploying..." @npm run deploy @curl -s -X PATCH "https://pbar.io/api/bars/$(PBAR_SLUG)" \ -H "Content-Type: application/json" -d '{"increment": 1}' > /dev/null
CI/CD Pipelines
GitLab CI
.gitlab-ci.yml
stages: - setup - build - test - deploy
variables: PBAR_TITLE: "Pipeline $CI_PIPELINE_ID"
before_script: - | export PBAR_SLUG=$(curl -s -X POST https://pbar.io/api/bars \ -H "Content-Type: application/json" \ -d "{\"title\": \"$PBAR_TITLE\", \"total\": 4}" | jq -r .slug) - echo "Progress: https://pbar.io/$PBAR_SLUG"
after_script: - | curl -s -X PATCH "https://pbar.io/api/bars/$PBAR_SLUG" \ -H "Content-Type: application/json" \ -d '{"increment": 1}'
build: stage: build script: - npm run build
test: stage: test script: - npm test
deploy: stage: deploy script: - npm run deploy
Best Practices
✅ DO: Batch Updates
When updating frequently, batch updates to reduce API calls. The Python and JS clients do this automatically.
⚡ DO: Use Increment for Performance
Use increment
instead of current
when possible - it's more efficient and handles concurrent updates better.
🔄 DO: Handle Failures Gracefully
Progress tracking should never break your application. Wrap API calls in try-catch blocks or use the client libraries that handle errors automatically.
❌ DON'T: Update Too Frequently
Avoid updating more than once per second unless necessary. Use batching or throttling for high-frequency updates.