npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

leboncoin-client

v0.3.1

Published

HTTP client for leboncoin.fr french e-commerce website

Downloads

3

Readme

Leboncoin.fr HTTP client

This package allows to perform requests on the french e-commerce website "leboncoin.fr". At the moment, it contains 3 simple methods for retrieve items data from the website : search(), get() and watch().

Installation

npm install leboncoin-client

Usage examples

Perform a search :

const lbc = require('leboncoin-client');

const req = {
    category: 'informatique',
    type: 'offres',
    region_or_department: 'cantal',
    sellers: 'particuliers',
    query: 'ordinateur',
    sort: 'date',
    titles_only: false,
    urgent_only: false
};

lbc.search(req, 1, 5) // browse pages 1 to 5
.then(function(items) {
    console.log(items);
}, function(error) {
    console.error(error);
});

Second search example :

const lbc = require('leboncoin-client');

const req = {
   category: 'informatique',
   city_or_postal_code: '75001'
   filters: {
       'Prix min': 400,
       'Prix max': 'Plus de 1000'
   }
};

lbc.search(req) // only the first page
.then(function(items) {
    console.log(items);
}, function(error) {
    console.error(error);
});

Get data from a specific advertisement :

const lbc = require('leboncoin-client');

lbc.get(1159809960)
.then(function(item) {
    console.log(item);
}, function(error) {
    console.error(error);
});

Watch new objects from a specific category and location :

const lbc = require('leboncoin-client');

const req = {
    category: 'informatique',
    region_or_department: 'gers'
};

lbc.watch(req, 60, function(item) { // the request is performed every 60 seconds
    console.log(item);
});

Methods

search(request, minPage, maxPage)

Query a research of items specified by various criterias. Return a promise with an array of items in parameter.

Parameter | Type | Description | Default value -------- | --- | --- | --- request | object | object containing the query parameters (see request spec for more info) | {} minPage | integer | first page to browse | 1 maxPage | integer | last page to browse | 1


get(id)

Get specific item data by its id. Return a promise with the item data in parameter.

Parameter | Type | Description | Default value -------- | --- | --- | --- id | integer | 10-digit item id | required


watch(request, interval, action)

Watching loop for detect new objects added specified by various criterias. Each time a new object is spotted, the function "action" is called with its data in parameter.

Parameter | Type | Description | Default value -------- | --- | --- | --- request | object | object containing the query parameters (see request spec for more info) | {} interval | integer | number of seconds between each request | 60 action | function | action to execute for process the new object data | required


Request spec

Field | Type | Description | Default value -------- | --- | --- | --- category | string | category to look in (check out the parameters.json for the complete list of categories) | "tous" type | string | type of advertisement ("offres" or "demandes") | "offres" region_or_department | string | region or department of items (check out the parameters.json for the complete list of locations) | "toute la France" city_or_postal_code | string | city or postal code of items (return empty array if it does not exist) | none sellers | string | type of sellers ("tous" or "particuliers" or "professionnels" | "tous" query | string | matching keywords | none sort | string | sort criteria ("date" or "prix") | "date" titles_only | boolean | search only in ad titles | false urgent_only | boolean | search only for urgent ads | false filters: | object | object containing some filters depending on the category (check out the parameters.json for the complete list of filters) | {}


Filters not implemented yet :

  • Car models (depending on the brand)
  • Dates ("holidays" categories)
  • Clothes sizes (depending on the gender)

Feel free to contact me for any suggestion, issue, improvement...