Skip to content

mthenw/allegro.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

allegro.js

Allegro.pl WebAPI client for Node.js.

Build Status Version

Installation

npm install allegro

Usage

See examples/.

API

allegro

createClient(options, callback)

Creates API client. Available options:

  • key - required WebAPI key, can be generated in My Allegro,
  • login, passwords or passwordHash - required credentials are needed to call some of methods (I don't know why but even for those not related to My Allegro), so in general you should provide them. password can be replaced with passwordHash which is encoded in base64 sha-256 hash from password (base64(sha256(password))),
  • countryId - optional, country identifier, default: 1 (Poland).

Callback function gets two arguments:

  • error - Error instance if error occured,
  • client - Client instance.

Example:

var allegro = require('allegro');

var options = {
    key: 'your_webapi_key',
    login: 'foo',
    passwordHash: 'bar'
};

allegro.createClient(options, function (error, client) {
    ...
});

Client

getCategory(categoryId, callback)

Get Category instance. Example:

allegro.createClient({ … }, function (error, client) {
    client.getCategory(149, function (error, category) {
        console.log(category.name); // 'Samochody'
    });
});

getItem(itemId, callback)

Get Item instance. Example:

allegro.createClient({ … }, function (error, client) {
    client.getItem(3482560106, function (error, item) {
        console.log(item.name); // 'IGŁA BMW E90'
    });
});

getUser(userId, callback)

Get User instance. Example:

allegro.createClient({ … }, function (error, client) {
    client.getUser(26729811, function (error, user) {
        console.log(user.login); // 'stendi_pl'
    });
});

Events

  • buynow (itemId) - item is bought by 'Buy Now'. Example:
client.on('buynow', function (itemId) {
    console.log('Somebody just bought:' + itemId);
});

Category

Returned by client.getCategory.

Properties

  • id int,
  • name string,
  • parentId int.

Methods

  • getParent(callback) get Category instance of parent. Callback function gets Error and Category instance. Example:
allegro.createClient({ … }, function (err, client) {
    client.getCategory(122234, function (err, category) {
        category.getParent(function (err, category) {
            console.log(category.name);
        })
    });
});

Item

Returned by client.getItem.

Properties

  • id int,
  • name string,
  • location string,
  • mainImage string,
  • isNew boolean,
  • isUsed boolean.

Methods

  • getSeller(callback) get User instance of seller. Callback function gets Error and User instance. Example:
allegro.createClient({ … }, function (error, client) {
    client.getItem(3509260334, function (error, item) {
        item.getSeller(function(error, user) {
            console.log(user.login); // 'stendi_pl'
        })
    });
});

User

Returned by client.getUser.

Properties

  • id int,
  • login string,
  • rating int,
  • createdAt Date,
  • isAllegroStandard bool.

About

Allegro.pl WebAPI client for Node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published