Skip to main content

Lightweight asynchronous Python client library for accessing Vinted API and scraping item data.

Project description

Vinted Api Kit logo

Lightweight asynchronous Python client library for accessing Vinted API and scraping item data.

Package Version Python Version codecov Downloads Code style: ruff Typed License

โœจ Features

  • ๐Ÿš€ Asynchronous - Built with asyncio for high performance
  • ๐ŸŒ Auto-locale Detection - Automatically detects locale from URL
  • ๐Ÿ” Item Search - Search catalog with filters, sorting and pagination
  • ๐Ÿ“ฆ Item Details - Get complete item information with rich metadata
  • ๐Ÿช Cookie Persistence - Automatic session management with multiple storage formats
  • ๐Ÿ” Proxy Support - Simple string-based proxy configuration
  • ๐Ÿ“Š Type Hints - Full typing support with Literal types for better IDE experience
  • ๐ŸŽฏ Dataclass Models - Fast and efficient data models (15% performance boost)
  • ๐Ÿ›ก๏ธ Custom Exceptions - Detailed error hierarchy for precise error handling
  • ๐Ÿ’พ Flexible Storage - Choose between pickle, JSON, or Mozilla cookie formats

๐Ÿ“š Table of Contents

Installation

Install via pip:

pip install vinted-api-kit

Or using poetry:

poetry add vinted-api-kit

Usage

Basic Example

import asyncio
from vinted import VintedClient

async def main():
    async with VintedClient() as client:
        items = await client.search_items(
            url="https://www.vinted.com/catalog?search_text=nike",
            per_page=5
        )

        for item in items:
            print(f"โ€ข {item.title} - {item.price} {item.currency}")

asyncio.run(main())

Configuration

๐Ÿ” Proxy Support

Use a proxy by passing a simple connection string:

async with VintedClient(
    proxy="user:pass@proxy.example.com:8080"  # Format: [user:pass@]host:port
) as client:
    items = await client.search_items(url)

๐Ÿ’พ Cookie Persistence

Save cookies between sessions to avoid repeated authentication:

from pathlib import Path

async with VintedClient(
    persist_cookies=True,              # Enable persistence
    cookies_dir=Path("./cookies"),     # Storage directory
    storage_format="json"              # Format: pickle | json | mozilla
) as client:
    items = await client.search_items(url)

Storage formats:

  • "json" (default) - Human-readable, portable across platforms
  • "pickle" - Fastest, Python-native binary format
  • "mozilla" - Browser-compatible Netscape format

๐Ÿ” Search Options

Use type-safe sorting and pagination:

from vinted import SortOrder

items = await client.search_items(
    url="https://www.vinted.de/catalog?brand_ids[]=53",
    per_page=20,                      # Items per page (1-96)
    page=1,                           # Page number
    order="price_low_to_high"         # Sort order (IDE auto-complete)
)

Available sort orders:

  • newest_first - Most recent items
  • relevance - Best match
  • price_low_to_high - Cheapest first
  • price_high_to_low - Most expensive first

๐Ÿ“ฆ Raw Data

Get raw JSON dictionaries instead of parsed models:

raw_items = await client.search_items(
    url="https://www.vinted.com/catalog?search_text=shoes",
    raw_data=True  # Returns list[dict] instead of list[CatalogItem]
)

Item Details

Fetch detailed information about a specific item:

item = await client.item_details(
    url="https://www.vinted.com/items/1234567890"
)

print(f"Title: {item.title}")
print(f"Brand: {item.brand_title}")
print(f"Size: {item.size_title}")
print(f"Price: {item.price} {item.currency}")
print(f"Total: {item.total_item_price}")
print(f"Description: {item.description}")

# Or get raw JSON
raw_item = await client.item_details(url, raw_data=True)

Parameters

Parameter Type Default Description
proxy str | None None Proxy string: "user:pass@host:port" or "host:port"
cookies_dir Path | None Path(".") Directory for cookie storage
persist_cookies bool False Enable cookie persistence between sessions
storage_format "json" | "pickle" | "mozilla" "json" Cookie storage format

Storage formats: json (default), pickle, mozilla. See Storage Formats for details.

Exception Handling

from vinted import (
    VintedClient,
    VintedError,           # Base exception
    VintedAPIError,        # API errors (4xx, 5xx)
    VintedAuthError,       # Authentication failures
    VintedNetworkError,    # Network/connection errors
    VintedConfigError,     # Invalid configuration
    VintedValidationError, # Input validation errors
    VintedRateLimitError,  # Rate limiting (429)
)

try:
    async with VintedClient(proxy="invalid://proxy") as client:
        items = await client.search_items(url)
except VintedConfigError as e:
    print(f"Configuration error: {e}")
except VintedValidationError as e:
    print(f"Invalid input: {e}")
except VintedRateLimitError as e:
    print(f"Rate limited: {e.status_code}")
except VintedAuthError as e:
    print(f"Auth failed: {e}")
except VintedNetworkError as e:
    print(f"Network error: {e.original_error}")
except VintedAPIError as e:
    print(f"API error: {e.status_code}")

Migration Guide

(v0.x โ†’ v1.0)

Breaking Changes

If you're upgrading from version 0.x, here are the key changes:

1. Import Path Changed

# โŒ Old (v0.x)
from vinted_api_kit import VintedApi

# โœ… New (v1.0)
from vinted import VintedClient

2. Class Renamed

# โŒ Old
async with VintedApi() as api:
    pass

# โœ… New
async with VintedClient() as client:
    pass

3. Locale Parameter Removed

# โŒ Old (manual locale)
async with VintedApi(locale="fr") as api:
    items = await api.search_items(url)

# โœ… New (auto-detected from URL)
async with VintedClient() as client:
    items = await client.search_items(url)  # Locale detected from URL

4. Proxy Configuration Changed

# โŒ Old (dict format)
async with VintedApi(
    proxies={"http": "http://user:pass@proxy:8080"}
) as api:
    pass

# โœ… New (simple string)
async with VintedClient(
    proxy="user:pass@proxy:8080"  # โ† Without "http://"
) as client:
    pass

5. New Storage Format Option

# โœ… New feature in v1.0
async with VintedClient(
    persist_cookies=True,
    storage_format="json"  # Choose: "json", "pickle", "mozilla"
) as client:
    pass

Quick Migration Checklist

  • Change import: vinted_api_kit โ†’ vinted
  • Rename class: VintedApi โ†’ VintedClient
  • Remove locale parameter (auto-detected)
  • Update proxy format: dict โ†’ string
  • Optional: Choose storage format

Full Example

Before (v0.x):

from vinted_api_kit import VintedApi

async with VintedApi(
    locale="fr",
    proxies={"http": "http://proxy:8080"},
    persist_cookies=True
) as api:
    items = await api.search_items(
        url="https://www.vinted.fr/catalog?search_text=nike"
    )

After (v1.0):

from vinted import VintedClient

async with VintedClient(
    proxy="proxy:8080",
    persist_cookies=True,
    storage_format="pickle"  # New option!
) as client:
    items = await client.search_items(
        url="https://www.vinted.fr/catalog?search_text=nike"
    )

Development

Setup

git clone https://github.com/vlymar1/vinted-api-kit.git
cd vinted-api-kit

pip install hatch
hatch shell

Project Structure

vinted-api-kit/
โ”œโ”€โ”€ vinted/             # Main package
โ”‚   โ”œโ”€โ”€ api/            # API endpoint handlers
โ”‚   โ”œโ”€โ”€ models/         # Data models (dataclasses)
โ”‚   โ”œโ”€โ”€ storage/        # Cookie storage strategies
โ”‚   โ”œโ”€โ”€ client.py       # Main client (VintedClient)
โ”‚   โ”œโ”€โ”€ session.py      # HTTP session management
โ”‚   โ”œโ”€โ”€ auth.py         # Authentication logic
โ”‚   โ”œโ”€โ”€ constants.py    # Constants and type definitions
โ”‚   โ”œโ”€โ”€ exceptions.py   # Custom exceptions
โ”‚   โ””โ”€โ”€ utils.py        # Utility functions
โ”œโ”€โ”€ tests/              # Test suite
โ””โ”€โ”€ examples/           # Usage examples

Testing

make test-coverage      # Run tests with coverage
make test-coverage-view # View coverage report in browser

Code Quality

make lint-check         # Check code with ruff and mypy
make lint-reformat      # Format and fix code with ruff

Cleanup

make clean              # Remove cache files and build artifacts

Development Guidelines

  • Follow PEP 8 style guidelines
  • Use type hints for all functions
  • Write tests for new features
  • Update CHANGELOG.md for notable changes
  • Run make lint-check before committing
  • Contributions welcome! Open issues or pull requests

Changelog

See CHANGELOG.md for the list of notable changes per version.

How to create and maintain changelog?

  • Start a CHANGELOG.md file at the root of your repo.
  • Follow Keep a Changelog format for consistent structure.
  • For each release version, record:
    • Added โ€” new features
    • Changed โ€” updates/improvements
    • Fixed โ€” bug fixes
    • Removed โ€” deprecated or removed features
  • Update changelog before tagging a new release (e.g., v1.0.0).
  • Automate changelog generation optionally by tools such as:

License

This project is licensed under the MIT License - see the LICENSE file for details.

โš  Disclaimer

This library is intended for personal and lawful use only. The author is not responsible for any misuse, including but not limited to:

  • Violations of applicable laws or regulations
  • Breaches of terms of service of third-party websites

By using this library, you agree that you are solely responsible for your actions.


Maintainers / Contacts

Feel free to open issues or contact for support and collaborations.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vinted_api_kit-1.0.1.tar.gz (59.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vinted_api_kit-1.0.1-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file vinted_api_kit-1.0.1.tar.gz.

File metadata

  • Download URL: vinted_api_kit-1.0.1.tar.gz
  • Upload date:
  • Size: 59.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.2 cpython/3.10.17 HTTPX/0.28.1

File hashes

Hashes for vinted_api_kit-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1949e3f66524d05acbfb23ee71bb13274b044c52db56c5ac402b85d2430c7e68
MD5 00aedbd35aa3a51a271b0eee2f6fff0c
BLAKE2b-256 618c9bcec0e694b94763cd648fba48cacda5f32590e850780b21e7ede715714a

See more details on using hashes here.

File details

Details for the file vinted_api_kit-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: vinted_api_kit-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 25.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.2 cpython/3.10.17 HTTPX/0.28.1

File hashes

Hashes for vinted_api_kit-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b87f7e20c02c37ccf88ef0dfd1f55ddce4f3bae6732f19cf634f06290299fcd2
MD5 666ca5bbc36bbcf9115a35cbc2b2d69e
BLAKE2b-256 abd46d46a182a05ec687c139e8e011f33c8536746fa83feaa7f5f68da7a1fe9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page