Git Product home page Git Product logo

leboncoin-api's Introduction

leboncoin-api Build Status Coverage Status

NPM

Documentation

The documentation of the library is available here: https://durieux.me/projects/leboncoin.html.

Install

npm install leboncoin-api

Features

  • Search on leboncoin.fr with all functionality available leboncoin.fr
  • Get the detailed page of an item
  • Get the phone number of the seller (convert the image to string) /!\ This API have an unknown usage limit

Usage

const leboncoin = require('leboncoin-api');
var search = new leboncoin.Search()
    .setPage(1)
    .setQuery("renove")
    .setFilter(leboncoin.FILTERS.PARTICULIER)
    .setCategory("locations")
    .setRegion("ile_de_france")
    .setDepartment("yvelines")
    .setLocation([
                 {"zipcode": "78100"},
                 {"zipcode": "78000"},
                 ])
//Search around you with latitude and longitude of your position and a radius in meters. Doing so you don't need to set Region, Department and Location
//Exemple for 30km around Lyon
//.setArea({"lat": 45.7679705, "lng": 4.8637901999999995, "radius": 30000})

    //Add sort, two kind date or price and two ways asc or desc
    //Exemple for a sort by date asc (older the first)
    //.setSort({sort_by:"date",sort_order:"asc"})

    .addSearchExtra("price", {min: 1500, max: 2000}) // will add a range of price
    .addSearchExtra('furnished', ["1", "Non meublé"]); // will add enums for Meublé and Non meublé

// Please check into categories & sub categories constants to know which are the sub categories to add into "addSearchExtra"

search.run().then(function (data) {
    console.log(data.page); // the current page
    console.log(data.pages); // the number of pages
    console.log(data.nbResult); // the number of results for this search
    console.log(data.results); // the array of results
    data.results[0].getDetails().then(function (details) {
        console.log(details); // the item 0 with more data such as description, all images, author, ...
    }, function (err) {
        console.error(err);
    });
    data.results[0].getPhoneNumber().then(function (phoneNumer) {
        console.log(phoneNumer); // the phone number of the author if available
    }, function (err) {
        console.error(err); // if the phone number is not available or not parsable (image -> string) 
    });
}, function (err) {
    console.error(err);
});

License MIT

leboncoin-api's People

Contributors

deepsilence avatar dragma avatar gnn06 avatar julienmalige avatar myrevers avatar othke avatar rodolphegohard avatar sylvain-d avatar tdurieux avatar tucsky avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.