Skip to main content

marktplaats-py

A small Python package to request listings from marktplaats.nl. It supports python 3.10+.

Installing

pip install marktplaats

Example

This is an example on how to use the library:

from datetime import datetime, timedelta

from marktplaats import Condition, SearchQuery, SortBy, SortOrder, category_from_name

search = SearchQuery(
    query="gazelle",  # Search query. Can be left out, but then category must be specified.
    zip_code="1016LV",  # Zip code to base distance from
    distance_km=100,  # Max distance in kilometers from the zip code for listings
    price_from=0,  # Lowest price to search for
    price_to=100,  # Highest price to search for
    limit=5,  # Max listings (page size, max 100)
    offset=0,  # Offset for listings (page * limit)
    sort_by=SortBy.OPTIMIZED,  # DATE, PRICE, LOCATION, OPTIMIZED
    sort_order=SortOrder.ASC,  # ASCending or DESCending
    condition=Condition.NEW,  # NEW, AS_GOOD_AS_NEW, USED or category-specific
    offered_since=datetime.now() - timedelta(days=7),  # Filter listings since a point in time
    category=category_from_name("Fietsen en Brommers"),  # Filter in specific category (L1) or subcategory (L2)
)

listings = search.get_listings()

for listing in listings:
    print(listing.title)
    print(listing.description)
    print(listing.price)
    print(listing.price_as_string(lang="nl"))
    print(listing.price_type)
    print(listing.link)

    # the location object
    print(listing.location)

    # the seller object
    print(listing.seller)

    # the date object
    print(listing.date)

    # the full seller object (another request)
    print(listing.seller.get_seller())

    # medium-sized cover image
    print(listing.first_image.medium)

    # image urls for all the listing's image
    # (this sends another HTTP request)
    for image in listing.get_images():
        print(image)

    print("-----------------------------")

Seller

Query a seller by their ID. This allows fetching the seller's details and all their listings. The seller ID can be obtained from the Marktplaats website: copy it from a seller's profile URL, e.g. https://www.marktplaats.nl/u/johndoe/12345678/.

import pprint
from marktplaats import SellerQuery

seller = SellerQuery(seller_id=12345678)

details = seller.fetch_details()
pprint.pprint(details)

listings = seller.fetch_listings()
for listing in listings["items"]:
    pprint.pprint(listing)
    print("-" * 80)

Categories

Filtering by Marktplaats category is possible. Please refer to the categories index at CATEGORIES.md

The categories can also be used programmatically. Some usage examples:

from marktplaats import L1Category, category_from_name, get_l1_categories, get_l2_categories, get_l2_categories_by_parent, get_subcategories

# List all level 1 categories.
for cat in get_l1_categories():
    print(cat.name, cat.id)  # E.g. `Antiek en Kunst 1`

# List all level 2 categories.
for cat in get_l2_categories():
    print(cat.name, cat.id, cat.parent)  # E.g. `Antiek | Bestek 2 Antiek en Kunst`

# Get a level 1 or 2 category by name.
vacation = category_from_name("Vakantie")
print(vacation.name, vacation.id)  # E.g. `Vakantie 856`

# List level 2 categories for a specific level 1 category.
books = L1Category(201, "Boeken")
for cat in get_subcategories(books):
    print(cat.name, cat.id, cat.parent)  # E.g. `Biografieën 205 Boeken`

# Map level 1 categories to their level 2 subcategories.
l1_to_l2_mapping = get_l2_categories_by_parent()
for l1_cat in l1_to_l2_mapping:
    print(l1_cat.name, l1_cat.id, "-" * 60)  # E.g. `Diversen 428 ------`
    for l2_cat in l1_to_l2_mapping[l1_cat]:
        print(l2_cat.name, l2_cat.id, l2_cat.parent)  # E.g. `Kerst 436 Diversen`

Metadata

Release files for marktplaats 0.6.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 marktplaats 0.6.0
File Size Uploaded
marktplaats-0.6.0.tar.gz 50.0 kB Details

Built distribution (wheel)

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

Total release size: 104.0 kB

Release files / marktplaats-0.6.0.tar.gz

Download URL marktplaats-0.6.0.tar.gz
Size 50.0 kB
Tags Source
SHA-256 checksum
How to use checksums
062e4660bd6a5b332856ba5b2517234d712b6131d914cabc09cf12cf35327906
BLAKE2b-256 checksum
How to use checksums
c571072367b99b09a2372ddd101428651117a3cd64ca9a7ab47176e7359adacd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / marktplaats-0.6.0-py3-none-any.whl

Download URL marktplaats-0.6.0-py3-none-any.whl
Size 54.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e54bed4619247633793921153715275374268f34fc8a7b2178bc8cc91b030b43
BLAKE2b-256 checksum
How to use checksums
7433c511eea5fa4b4071bbe4726a43b81cfe5c0322751ea264e933778412e5d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.6.1

2 release files

This release

0.6.0 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

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