Skip to content

Repository files navigation

node-bptf-classifieds

A Node.js wrapper for the Backpack.tf Classifieds Web API.

npm version node version npm test dependencies npm downloads license paypal

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

Importing with CommonJS

const { Classifieds } = require('bptf-classifieds');

or with ES6's import statement

import { Classifieds } from 'bptf-classifieds';

Instantiating with the token and apiKey options

const classifieds = new Classifieds({ 
    token: 'XXXXXXXXXXXXXXXXXXXXXXXX',
    apiKey: 'XXXXXXXXXXXXXXXXXXXXXXXX'  
});

Asynchronous requests with callbacks

classifieds.getListings({
    sku: 'Fizzy Pharmacist',
    callback: (err, data) => {
        if (err) throw err;

        console.log(data.listings);
    }
});

Asynchronous requests with async/await

(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

MIT

Copyright 2024, Simon Sørensen

Releases

Sponsor this project

Used by

Contributors

Languages