Skip to content

About

Vinted-Wallapop-Subito markeplaces Telegram bot

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

Markeplace Agent

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.

Installation

  1. 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
  2. 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.

  3. 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>/getUpdates
    

    Find the latest message object in the response and copy the value from message.chat.id.

  4. Create a .env file from .env.example and set the uppercase variables:

    TOKEN=your_telegram_bot_token
    CHAT_ID=your_telegram_chat_id
    COUNTRY=IT
    DB_FILE=items.db

    COUNTRY selects the Vinted country and defaults to IT. DB_FILE selects the SQLite database file and defaults to items.db in the current working directory. Environment variables provided by the shell override values from .env. Keep the country setting: Vinted's .com catalog can return different listings from .it for 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.

  5. Start the bot from the project root.

    The project root matters because .env is read from the current working directory and items.db is created there unless DB_FILE is 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.

Usage

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

/monitor query=<query> price=<price> marketplace=<marketplace> [refresh_every=<seconds>]

Creates a monitor for new matching items.

  • query is required. Search text to send to the marketplace.
  • price is required. Maximum item price.
  • marketplace is required. Marketplace to search: vinted, wallapop, or subito.
  • refresh_every is optional. Refresh interval in seconds. Defaults to 60.

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

/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

/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

/delete id=<monitor_id>
/delete query=<query> marketplace=<marketplace>
/delete *

Deletes one or more monitors.

  • id deletes one monitor by id. Use the id returned by /monitor or shown by /list.
  • query and marketplace delete 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

/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

Automatic testing

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=testing

TELEGRAM_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 main

Then 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=vinted

Use /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 /list

On 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

About

Vinted-Wallapop-Subito markeplaces Telegram bot

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages