Telegram bot for monitoring new listings across second-hand marketplaces. The project contains marketplace clients for Vinted, Wallapop, and Subito. Listings are stored in a local database and new matches are sent to a configured Telegram chat.
-
Install the project dependencies, Python 3.12 or newer is required.
With uv:
uv sync
Without uv, create a virtual environment and install the runtime dependencies:
python -m venv .venv .\.venv\Scripts\Activate.ps1 python -m pip install -r requirements.txt
On macOS or Linux, activate the environment with:
source .venv/bin/activate -
Create a Telegram bot.
Open Telegram, start a chat with @BotFather, and send
/newbot. Follow the prompts to choose a display name and username. BotFather returns an API token when the bot is created. -
Find your Telegram chat ID.
Open a chat with the new bot and send
/start, then open the following URL in a browser, replacing<TOKEN>with the token from BotFather:https://api.telegram.org/bot<TOKEN>/getUpdatesFind the latest
messageobject in the response and copy the value frommessage.chat.id. -
Create a
.envfile from.env.exampleand set the uppercase variables:TOKEN=your_telegram_bot_token CHAT_ID=your_telegram_chat_id COUNTRY=IT DB_FILE=items.db
COUNTRYselects the Vinted country and defaults toIT.DB_FILEselects the SQLite database file and defaults toitems.dbin the current working directory. Environment variables provided by the shell override values from.env. Keep the country setting: Vinted's.comcatalog can return different listings from.itfor the same search.Vinted searches use one catalog page per poll. The first poll stores the returned listings as the baseline without notifying. Later polls consider an item new only when its numeric ID is greater than the largest Vinted ID already stored. This avoids item-page requests and upload-date parsing; it assumes larger IDs indicate newer listings. If more new listings appear between polls than fit on that page, some may be missed.
-
Start the bot from the project root.
The project root matters because
.envis read from the current working directory anditems.dbis created there unlessDB_FILEis set.With uv:
uv run main
The direct Python entry point also works with uv:
uv run python main.py
Without uv, activate your virtual environment and run:
python main.py
The bot stores monitor state and previously seen listings in the SQLite database
configured by DB_FILE.
After the bot starts, manage monitors from the configured Telegram chat. Every
message sent to the bot is a command and starts with /. Commands accept keyword arguments only, using name=value syntax. Use quotes when a value contains spaces. Supported marketplaces are vinted, wallapop,
and subito.
/monitor query=<query> price=<price> marketplace=<marketplace> [refresh_every=<seconds>]
Creates a monitor for new matching items.
queryis required. Search text to send to the marketplace.priceis required. Maximum item price.marketplaceis required. Marketplace to search:vinted,wallapop, orsubito.refresh_everyis optional. Refresh interval in seconds. Defaults to60.
Examples:
[me] /monitor query='fluent python' price=22 marketplace=vinted
[bot] Added monitor aca86222
[me] /monitor query='lego star wars' price=40 marketplace=wallapop refresh_every=120
[bot] Added monitor 00135228
[me] /monitor query='commodore 64' price=150 marketplace=subito
[bot] Added monitor 6ad7f81d
The bot answers with the generated monitor id. Each monitor is unique by query
and marketplace. You cannot add the same query to the same marketplace twice,
but you can monitor the same query on different marketplaces.
/list
Lists active monitors and their ids. This command has no parameters.
Example:
[me] /list
[bot] | ID | Query | Price | Refresh | Market |
|----------|----------------------|--------|---------|----------|
| aca86222 | fluent python | 22.00 | 60 | vinted |
| 00135228 | lego star wars | 40.00 | 120 | wallapop |
| 6ad7f81d | commodore 64 | 150.00 | 60 | subito |
/export
Exports active monitors as /monitor commands so they can be recreated later.
This command has no parameters.
Example:
[me] /export
[bot] /monitor query='nintendo 3ds' price=40.0 marketplace=vinted refresh_every=60.0
/monitor query='lego star wars' price=40.0 marketplace=wallapop refresh_every=120.0
/monitor query='commodore 64' price=150.0 marketplace=subito refresh_every=60.0
/delete id=<monitor_id>
/delete query=<query> marketplace=<marketplace>
/delete *
Deletes one or more monitors.
iddeletes one monitor by id. Use the id returned by/monitoror shown by/list.queryandmarketplacedelete one monitor by its search query and marketplace.*deletes all monitors.
Examples:
[me] /delete id=1a2b3c4d
[bot] Deleted monitor 00135228
[me] /delete query='fluent python' marketplace=vinted
[bot] Deleted monitor aca86222
[me] /delete *
[bot] Deleted 3 monitors.
/help
Shows available commands. This command has no parameters.
Example:
[me] /help
[bot] /monitor query=<query> price=<price> marketplace=<marketplace> [refresh_every=<seconds>]
Create a monitor for new matching items.
/list
List all active monitors with their ids.
/export
Export all monitors as /monitor commands.
/delete id=<id>
Delete a monitor by id.
/delete query=<query> marketplace=<marketplace>
Delete a monitor by query and marketplace.
/delete *
Delete all monitors.
/help
Show this help message.
Marketplaces: vinted, wallapop, subito
The project includes testing.py, a small end-to-end helper that sends one
Telegram command as the configured user, waits for the bot response, and prints
the response. The bot must be running separately.
testing.py reads .env and needs the normal bot variables plus Telegram API
credentials for the user session:
TOKEN=your_telegram_bot_token
CHAT_ID=your_telegram_chat_id
TELEGRAM_API_ID=your_telegram_api_id
TELEGRAM_API_HASH=your_telegram_api_hash
TELEGRAM_SESSION=testingTELEGRAM_SESSION is optional and defaults to testing. The first time you run
the helper, Telethon may ask you to log in and will create a local session file.
Use TELEGRAM_TARGET or --target when the helper cannot infer the target chat
from CHAT_ID or the bot username.
For safer local testing, use a separate database file so test monitors do not touch normal monitor state. Start the bot in one terminal:
$env:DB_FILE = "items.testing.db"
uv run mainThen send commands from another terminal:
uv run testing.py /list
uv run testing.py /monitor "query=fluent python" price=22 marketplace=vinted
uv run testing.py /delete "query=fluent python" marketplace=vintedUse /delete * to clean up test monitors before finishing:
uv run testing.py /delete *Use --timeout <seconds> for commands that may take longer:
uv run testing.py --timeout 60 /listOn Windows, if a response contains characters that the default console encoding cannot print, set UTF-8 output for the helper command:
$env:PYTHONIOENCODING = "utf-8"
uv run testing.py /list