allegro-rest-client
Allegro REST API client for managing allegro.pl auctions with ease using node.
Getting Started
This library provides simple wrapper for managing allegro rest api resources according to docs
Prerequisites
Registration new app here. You have to choose between two types of app:
- WEB: need authorization code from url: https://allegro.pl/auth/oauth/authorize?response_type=code&client_id=clientid&redirect_uri=https://url-redirect.daksamit.pl
- DEVICE: bind an app via allegro.pl with device_code and authorize app
Installation:
yarn add allegro-rest-client# or npm install allegro-rest-client
Usage
Following example shows, how to import and use library to fetch allegro categories
try catch err
config - holds registered app credentials options - comprises:
- account: allegro account name used by AllegroRestClient instance
- sandbox: boolean if use app from allegro sandbox
- logger: boolean if logging requests info
- storage: object with set and get methods for storing app credentials per account
Authorizing app via 'device' type is preffered way - after calling bindApp method, you need visit and authorize app from 'verification_uri_complete' url, and call authorize method with obtained device_code along with verification_uri_complete.
What library do:
- refresh tokens every 12 hours
- wraps client to call resources from docs
- passes default 'Authorization' header for all requests and 'Accept'
application/vnd.allegro.public.v1+json
(for some resources you need different Content-Type - check docs) - allows to call allegro.pl resources via request module
Examples:
// ...const categories = await allegroClientconst offers count totalCount = await allegroClientconst id: offerId validation ...offer = await allegroClient // draft offer, 'validation.errors' contains array of missing offer dataconst publishedOffer = await allegroClient // complete draft offer and publishconst rates = await allegroClient
Future plans
- replace deprecated request module (axios or bent)
- ...
License
This project is licensed under the MIT License - see the LICENSE file for details