node-bptf-classifieds
A Node.js wrapper for the Backpack.tf Classifieds Web API.
Installation
Using npm:
$ npm install bptf-classifieds
Using yarn:
$ yarn add bptf-classifieds
Testing
Note: Make sure you've supplied a valid user token
and API key
in the test files.
Using npm:
$ npm test
Using yarn:
$ yarn test
Examples
CommonJS
Importing with const { Classifieds } = require('bptf-classifieds');
ES6's import
statement
or with import { Classifieds } from 'bptf-classifieds';
token
and apiKey
options
Instantiating with the const classifieds = new Classifieds({
token: 'XXXXXXXXXXXXXXXXXXXXXXXX',
apiKey: 'XXXXXXXXXXXXXXXXXXXXXXXX'
});
callbacks
Asynchronous requests with classifieds.getListings({
sku: 'Fizzy Pharmacist',
callback: (err, data) => {
if (err) throw err;
console.log(data.listings);
}
});
async
/await
Asynchronous requests with (async () => {
try {
const data = await classifieds.getListings({
sku: 'The Bird-Man of Aberdeen'
});
console.log(data.listings);
} catch (error) {
console.error('An error occurred: ', error);
}
})();
There are some more examples available in the test directory.
Documentation
See the Wiki pages for further documentation.
License
Copyright 2023, Simon Sørensen