Zero-capital automation: running a business from Termux
Zero-Capital Automation: Running a Business from Termux Okay, let's be real. The dream of starting a business often comes with a hefty price tag: office space, employees, marketing budgets⦠it can be paralyzing. But wh
Zero-Capital Automation: Running a Business from Termux
Okay, let's be real. The dream of starting a business often comes with a hefty price tag: office space, employees, marketing budgetsβ¦ it can be paralyzing. But what if I told you you could bootstrap a surprisingly capable business, powered by automation, all from the terminal on your phone? Sounds crazy? Maybe. But Iβm doing it, and this article will show you how.
Iβm running a small data aggregation and alert service β FractalMesh β that monitors specific cryptocurrency price action and sends alerts via Telegram. Itβs not making me a millionaire (yet!), but itβs self-funded, largely automated, and runs almost entirely from Termux on my Android phone. And the best part? The initial investment was essentially zero.
What is Termux?
For those unfamiliar, Termux is an Android terminal emulator and Linux environment. It allows you to run a full Linux distribution (albeit a limited one) directly on your phone. Think of it as having a mini-server in your pocket. You can install packages with pkg, write scripts, and even run full-blown web servers.
Why Termux for Business?
- Cost: Free. Seriously.
- Portability: Your business is literally in your pocket.
- Low Overhead: No need for expensive servers initially.
- Privacy: You control your data.
- Learning Opportunity: Forces you to understand the fundamentals of system administration and automation.
The Tech Stack: A Minimalist Approach
My setup revolves around these core components:
- Termux: The foundation.
- Python 3: The scripting language of choice. Versatile, readable, and tons of libraries.
-
requestslibrary: For fetching data from APIs (like KuCoin, Binance, etc.). -
schedulelibrary: For scheduling tasks β crucial for automation. -
python-telegram-botlibrary: For sending alerts via Telegram. -
jq: A lightweight and flexible command-line JSON processor (install viapkg install jq). - Text Editor (Nano/Vim): For writing and editing scripts directly on the phone.
-
Tmux (optional but highly recommended): A terminal multiplexer. Allows you to run multiple terminal sessions within Termux, detach them, and reattach later β perfect for long-running scripts. Install via
pkg install tmux.
The Core Logic: Python & Scheduling
The heart of my operation is a Python script that periodically checks cryptocurrency prices, compares them to pre-defined thresholds, and sends Telegram alerts if necessary.
Hereβs a simplified example:
import requests
import schedule
import time
import telegram
# Replace with your Telegram bot token
TOKEN = "YOUR_TELEGRAM_BOT_TOKEN"
CHAT_ID = "YOUR_TELEGRAM_CHAT_ID"
def check_kucoin_price(symbol):
try:
url = f"https://api.kucoin.com/api/v1/ticker/price?symbol={symbol}"
response = requests.get(url)
response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
data = response.json()
price = float(data['data']['price'])
if symbol == "BTC-USDT":
threshold = 28000
elif symbol == "ETH-USDT":
threshold = 1700
else:
threshold = 0 # Default to no alert
if price < threshold:
message = f"π¨ ALERT: {symbol} price is below ${threshold}! Current Price: ${price}"
bot = telegram.Bot(token=TOKEN)
bot.sendMessage(chat_id=CHAT_ID, text=message)
print(f"Alert sent for {symbol} at {price}")
except requests.exceptions.RequestException as e:
print(f"Error fetching data for {symbol}: {e}")
except KeyError:
print(f"Error parsing JSON for {symbol}")
schedule.every(5).minutes.do(check_kucoin_price, symbol="BTC-USDT")
schedule.every(5).minutes.do(check_kucoin_price, symbol="ETH-USDT")
while True:
schedule.run_pending()
time.sleep(1)
Explanation:
- Imports: Necessary libraries.
-
TOKEN&CHAT_ID: Important: Replace these placeholders with your actual Telegram bot token and chat ID. (See below for setup instructions). -
check_kucoin_price(symbol): This function fetches the current price of a given cryptocurrency pair from the KuCoin API. It checks if the price falls below a predefined threshold and sends a Telegram alert if it does. Error handling is included to catch network issues and API changes. -
schedule: Theschedulelibrary allows you to schedule thecheck_kucoin_pricefunction to run every 5 minutes for both BTC and ETH. -
while Trueloop: Continuously runs the scheduler.
Telegram Bot Setup
- Talk to BotFather: In Telegram, search for "BotFather".
-
Create a New Bot: Use the
/newbotcommand and follow the instructions. BotFather will provide you with a token. Keep this secure! -
Get Chat ID: Send a message to your newly created bot. Then, use a tool like https://api.telegram.org/bot/getUpdates (replace
<YOUR_TOKEN>with your bot token) in your browser. The JSON response will contain yourchat_id.
Running It All in Termux
-
Install Python:
pkg install python -
Install required libraries:
pip install requests schedule python-telegram-bot -
Create the Python script: Use Nano (
nano your_script.py) or Vim (vim your_script.py) to create and save the script above. -
Run the script:
python your_script.py
Keeping It Running (Tmux to the Rescue!)
Simply running the script in Termux wonβt work if you close the app or your phone goes to sleep. This is where Tmux comes in.
-
Start a Tmux session:
tmux new -s my_session -
Run your script inside the Tmux session:
python your_script.py -
Detach from the session: Press
Ctrl+b, thend.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.