Skip to main content

lbc

Latest version PyPI - Downloads GitHub license

Unofficial client for Leboncoin API

import lbc

client = lbc.Client()

location = lbc.City(
    lat=48.85994982004764,
    lng=2.33801967847424,
    radius=10_000,  # 10 km
    city="Paris",
)

result = client.search(
    text="maison",
    locations=[location],
    page=1,
    limit=35,
    sort=lbc.Sort.NEWEST,
    ad_type=lbc.AdType.OFFER,
    category=lbc.Category.IMMOBILIER,
    square=[200, 400],
    price=[300_000, 700_000],
)

for ad in result.ads:
    print(ad.url, ad.subject, ad.price)

lbc is not affiliated with, endorsed by, or in any way associated with Leboncoin or its services. Use at your own risk.

Installation

Required Python 3.10+

pip install lbc

Usage

Start with the examples to quickly understand how to use the library in real-world scenarios.

Client

To create client you need to use lbc.Client class

import lbc

client = lbc.Client()

Proxy

You can also configure the client to use a proxy by providing a Proxy object:

# Setup proxy1
proxy1 = lbc.Proxy(
    host="127.0.0.1",
    port=12345,
    username="username",
    password="password",
    scheme="http",
)

# Initialize client with proxy1
client = lbc.Client(proxy=proxy1)

# Setup proxy2
proxy2 = lbc.Proxy(
    host="127.0.0.1",
    port=23456,
)

# Change client proxy to proxy2
client.proxy = proxy2

# Remove proxy
client.proxy = None

To perform a search, use the client.search method.

This function accepts keyword arguments (**kwargs) to customize your query. For example, if you're looking for houses that include both land and parking, you can specify:

real_estate_type = ["3", "4"]

These values correspond to what you’d find in a typical Leboncoin URL, like:

https://www.leboncoin.fr/recherche?category=9&text=maison&...&real_estate_type=3,4

Here's a complete example of a search query:

client.search(
    text="maison",
    locations=[location],
    page=1,
    limit=35,
    limit_alu=0,
    sort=lbc.Sort.NEWEST,
    ad_type=lbc.AdType.OFFER,
    category=lbc.Category.IMMOBILIER,
    owner_type=lbc.OwnerType.ALL,
    search_in_title_only=True,
    square=[200, 400],
    price=[300_000, 700_000],
)

Alternatively

You can also perform search using a full Leboncoin URL:

client.search(
    url="https://www.leboncoin.fr/recherche?category=9&text=maison&locations=Paris__48.86023250788424_2.339006433295173_9256&square=100-200price=500000-1000000&rooms=1-6&bedrooms=3-6&outside_access=garden,terrace&orientation=south_west&owner_type=private",
    page=1,
    limit=35,
)

If url is provided, it overrides other keyword parameters such as text, category, locations, etc. However, pagination parameters like page, limit, and limit_alu are still applied.

You can pass a list of values to search for multiple terms at once.

The values are converted into a Leboncoin OR query. For example:

client.search(text=["Laptop", "Desktop"])

This generates a search equivalent to:

Laptop OR Desktop

This can be useful for combining multiple keywords into a single search query without having to perform separate requests.

Location

The locations parameter accepts a list of one or more location objects. You can use one of the following:

  • lbc.Region(...)
  • lbc.Department(...)
  • lbc.City(...)

Each one corresponds to a different level of geographic granularity.

City example

location = lbc.City(
    lat=48.85994982004764,
    lng=2.33801967847424,
    radius=10_000,  # in meters
    city="Paris",
)

Region / Department example

from lbc import Region, Department

region = Region.ILE_DE_FRANCE
department = Department.PARIS

403 Error

If you encounter a 403 Forbidden error, it usually means your requests are being blocked by Datadome. To resolve this:

  • Try reducing the request frequency (add delays between requests).
  • If you're using a proxy, make sure it is clean and preferably located in France.

Using residential or mobile proxies can also help avoid detection.

License

This project is licensed under the MIT License.

Support

Buy Me A Coffee

You can contact me via Telegram or Discord if you need help with scraping services or want to write a library.

Metadata

Release files for lbc 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lbc 1.2.0
File Size Uploaded Provenance Actions
lbc-1.2.0.tar.gz 17.8 kB With provenance Details for lbc-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lbc 1.2.0
File Interpreter ABI Platform Actions
lbc-1.2.0-py3-none-any.whl Python 3 none any Details for lbc-1.2.0-py3-none-any.whl

Total release size: 39.0 kB

Release files / lbc-1.2.0.tar.gz

Download URL lbc-1.2.0.tar.gz
Size 17.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9ec329e4967bc2cb1639a143e4c9c4d6305a420f33648707186c9952e9388227
BLAKE2b-256 checksum
How to use checksums
5a8c062d9fa500f83ed6cb1cdb4d428c3510b8c10bba1bfd353d807cbddd1e5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / lbc-1.2.0-py3-none-any.whl

Download URL lbc-1.2.0-py3-none-any.whl
Size 21.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
334e0d5b68e125b1c55434e85246fd06753d44a8a31b9ad29538359cab362819
BLAKE2b-256 checksum
How to use checksums
6ff93b301317de19cec8d10d1c01aca1736d923f5f97f54778e7c159634ce3c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for lbc 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lbc-1.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page