Skip to content
Simon Sørensen edited this page May 15, 2023 · 8 revisions

bptf-classifieds

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

Documentation

When you require() the module, the Classifieds class is returned. This page lists all methods (properties are private) available from that class.

However, you must first instantiate a new instance of the module and supply it with your Backpack.tf developer API key and User token.

Below is a CommonJS example:

// Require the module 
const { Classifieds } = require('bptf-classifieds');
// and supplying your options
const classifieds = new Classifieds({ 
    token: 'XXXXXXXXXXXXXXXXXXXXXXXX',
    apiKey: 'XXXXXXXXXXXXXXXXXXXXXXXX'  
});

Methods

All methods support both callbacks and async/await.

Also, please note: Function parameters are all supplied in a single object. If one or more are omitted, the function resorts to its default values.

constructor (options)

  • options - An object containing valid bptf-classifieds constructor options.
    • token - Your Backpack.tf user token (This option is required for performing most requests).
    • apiKey - Your Backpack.tf API key (This option is required for performing premium requests).

Constructs a new Classifieds instance.

search ({ intent, page_size, fold, item, callback })

Search the Backpack.tf Classifieds programmatically.

  • intent - Filter listings by intent, defaults to dual.
  • page_size - Modify the page size used to paginate, defaults to 10.
  • fold - If set to 0, disables listing folding.
  • item - Item name to search for, defaults to The Team Captain.
  • steamid - Only show listings created by the user whose Steam ID is passed.
  • callback - Optional, called when a response is available. If omitted the function returns a promise.
    • error - An Error object on failure, or null on success.
    • response - The response object.

Returns a SearchResponse object with Backpack.tf Classified listings matching the search parameters.

getMyListings ({ intent, inactive, callback })

Get your own Backpack.tf Classifieds listings.

  • intent - Filter listings by intent, defaults to dual.
  • inactive - If 0, hides your inactive listings.
  • callback - Optional, called when a response is available. If omitted the function returns a promise.
    • error - An Error object on failure, or null on success.
    • response - The response object.

Returns a GetMyListingsResponse object with your Backpack.tf Classified listings.

deleteListings ({ ids, callback })

Delete multiple Classifieds listings.

  • ids - An array of Classifieds listing ids.
  • callback - Optional, called when a response is available. If omitted the function returns a promise.
    • error - An Error object on failure, or null on success.
    • response - The response object.

Returns a DeleteListingsResponse object with the number of listings that were deleted or skipped.

createListings ({ listings, callback })

Create multiple Classifieds listings.

  • listings - An array of Classifieds listings.
  • callback - Optional, called when a response is available. If omitted the function returns a promise.
    • error - An Error object on failure, or null on success.
    • response - The response object.

Returns a CreateListingsResponse object with a list of objects that represents the listings that were created.

getListing ({ id, callback })

Get a Classifieds listing by its ID.

  • id - The listing id.
  • callback - Optional, called when a response is available. If omitted the function returns a promise.
    • error - An Error object on failure, or null on success.
    • response - The response object.

Returns a GetListingResponse object with the listing object or an error if not found.

deleteListing ({ id, callback })

Delete a Classifieds listing by its ID.

  • id - The listing id.
  • callback - Optional, called when a response is available. If omitted the function returns a promise.
    • error - An Error object on failure, or null on success.
    • response - The response object.

Returns a DeleteListingResponse object with a status code that indicates if the listing was successfully deleted.

getUserLimits ({ callback })

Get the listing limits of the session user.

  • callback - Optional, called when a response is available. If omitted the function returns a promise.
    • error - An Error object on failure, or null on success.
    • response - The response object.

Returns a UserLimitsResponse object with the listing limits of the session user.

createListing ({ listing, callback })

Creates a new Classifieds listing.

  • listing - A Classifieds listing.
  • callback - Optional, called when a response is available. If omitted the function returns a promise.
    • error - An Error object on failure, or null on success.
    • response - The response object.

Returns a CreateListingResponse object that represents the listing that was created.

deleteAllListings ({ callback })

Delete all Backpack.tf Classifieds listings associated with the token.

  • callback - Optional, called when a response is available. If omitted the function returns a promise.
    • error - An Error object on failure, or null on success.
    • response - The response object.

Returns a DeleteAllListingsResponse with a status code of 501 Not Implemented.

getUserListings ({ skip, limit, callback })

Get the listings for the current session user.

  • skip - The offset at which to return listings.
  • limit - The listing limit.
  • callback - Optional, called when a response is available. If omitted the function returns a promise.
    • error - An Error object on failure, or null on success.
    • response - The response object.

Returns a GetUserListingsResponse object with the listings for the current session user.

getListings

Get an array of relevant listings for an item SKU.

  • appid - The appid of the item, defaults to Team Fortress 2 = 440.
  • sku - The SKU is considered to be what you see items being sold as on the Backpack.tf listings.
  • callback - Optional, called when a response is available. If omitted the function returns a promise.
    • error - An Error object on failure, or null on success.
    • response - The response object.

Returns a GetListingsResponse object with the first fifteen buy and sell orders for the item.

Examples

For now, there are some examples available in the test directory.

Support

Feel free to create an issue if you happen to encounter any bugs or have a suggestion for a new feature.