Square Inventory API v2 Client Node.js Code
// Node.js Square Inventory API v2 Fetch
const { Client, Environment } = require('square');
const client = new Client({
accessToken: process.env.SQUARE_ACCESS_TOKEN,
environment: Environment.Production,
});
async function getSquareStock(catalogObjectId) {
const response = await client.inventoryApi.retrieveInventoryCount(catalogObjectId);
return response.result.counts[0].quantity;
}
Suggested & Related Reading
Explore related engineering guides from Kenneth D'Silva:
-
Depop & Omnichannel Marketplace Synchronization
Multichannel web inventory deduplication.
-
Integrating Secure Payment Gateways for Ecommerce
Stripe and Square web checkout security.