Skip to content
stores-comPublic

About

A Node.js client for the Wayfair API.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

wayfair

Test Coverage Status npm version License: MIT

A Node.js client for the Wayfair API.

Installation

$ npm install @stores.com/wayfair

Usage

const Wayfair = require('@stores.com/wayfair');

const wayfair = new Wayfair({
    client_id: 'your_client_id',
    client_secret: 'your_client_secret'
});

Create an application in Wayfair's Developer Portal (Application Management) for a client ID and secret. By default the client targets the production endpoint (https://api.wayfair.com). A sandbox application uses the sandbox endpoint:

const wayfair = new Wayfair({
    client_id: 'your_sandbox_client_id',
    client_secret: 'your_sandbox_client_secret',
    url: 'https://sandbox.api.wayfair.com'
});

Wayfair unlocks each production permission only after it's used in the sandbox.

Errors are thrown as HttpError. That includes GraphQL errors, which Wayfair returns with a 200.

Documentation

Methods

getAccessToken(options)

Get an OAuth access token using the client_credentials grant. Tokens last 24 hours; each is cached in memory for 12, as Wayfair recommends. Every other method calls this for you.

See: https://developer.wayfair.io/posts/api-access-tokens

const accessToken = await wayfair.getAccessToken();

inventory.save(inventory, options)

Send a dropship inventory feed. A TRUE_UP feed is a complete listing and is required at least once every 24 hours. A DIFFERENTIAL feed (Wayfair's default) has only the products whose quantities changed, ideally every 30 minutes. The sandbox only takes TRUE_UP feeds, truncated at 500 rows.

Wayfair processes the feed after responding. Rows it rejects come back in errors, and it still saves the rest.

See: https://developer.wayfair.io/posts/dropship-inventory

const status = await wayfair.inventory.save([
    { quantityOnHand: 7, supplierId: 199492, supplierPartNumber: '272687' }
], { feedKind: 'TRUE_UP' });

Every method takes options.timeout to override the client's timeout (30 seconds by default).

Tests

The tests run against Wayfair's sandbox (https://sandbox.api.wayfair.com), never production. They need a sandbox application's WAYFAIR_CLIENT_ID and WAYFAIR_CLIENT_SECRET, and the sandbox WAYFAIR_SUPPLIER_ID.

$ WAYFAIR_CLIENT_ID=... WAYFAIR_CLIENT_SECRET=... WAYFAIR_SUPPLIER_ID=... npm test

About

A Node.js client for the Wayfair API.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages