Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Node.js) Faire - Get All ProductsSee more Faire ExamplesRetrieves a list of products, ordered ascending by updated_at. By default, it only returns non-deleted products. For more information, see https://faire.github.io/external-api-docs/#get-all-products
var os = require('os'); if (os.platform() == 'win32') { if (os.arch() == 'ia32') { var chilkat = require('@chilkat/ck-node21-win-ia32'); } else { var chilkat = require('@chilkat/ck-node21-win64'); } } else if (os.platform() == 'linux') { if (os.arch() == 'arm') { var chilkat = require('@chilkat/ck-node21-arm'); } else if (os.arch() == 'x86') { var chilkat = require('@chilkat/ck-node21-linux32'); } else { var chilkat = require('@chilkat/ck-node21-linux64'); } } else if (os.platform() == 'darwin') { if (os.arch() == 'arm64') { var chilkat = require('@chilkat/ck-node21-mac-m1'); } else { var chilkat = require('@chilkat/ck-node21-macosx'); } } function chilkatExample() { // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. var http = new chilkat.Http(); var success; // Implements the following CURL command: // curl -X GET -H "X-FAIRE-ACCESS-TOKEN: <access_token>" -d "limit=50" -d "page=1" https://www.faire.com/api/v1/products // Use the following online tool to generate HTTP code from a CURL command // Convert a cURL Command to HTTP Source Code var queryParams = new chilkat.JsonObject(); queryParams.UpdateInt("limit",50); queryParams.UpdateInt("page",1); http.SetRequestHeader("X-FAIRE-ACCESS-TOKEN","<access_token>"); // resp: HttpResponse var resp = http.QuickRequestParams("GET","https://www.faire.com/api/v1/products",queryParams); if (http.LastMethodSuccess == false) { console.log(http.LastErrorText); return; } var sbResponseBody = new chilkat.StringBuilder(); resp.GetBodySb(sbResponseBody); var jResp = new chilkat.JsonObject(); jResp.LoadSb(sbResponseBody); jResp.EmitCompact = false; console.log("Response Body:"); console.log(jResp.Emit()); var respStatusCode = resp.StatusCode; console.log("Response Status Code = " + respStatusCode); if (respStatusCode >= 400) { console.log("Response Header:"); console.log(resp.Header); console.log("Failed."); return; } // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "page": 1, // "limit": 50, // "products": [ // { // "id": "p_123", // "brand_id": "b_abc", // "short_description": "Our candles smell fantastic. Want to know how good? Read our description!", // "description": "Glad you decided to read our description! We have significantly more characters to describe to you just how good our candles smell.", // "wholesale_price_cents": 500, // "retail_price_cents": 1000, // "sale_state": "FOR_SALE", // "active": true, // "deleted": false, // "name": "Faire's fantastic candle", // "unit_multiplier": 8, // "taxonomy_type": { // "id": "tt_23nl3bzl00", // "name": "Votive Candle" // }, // "options": [ // ], // "created_at": "20190314T000915.000Z", // "updated_at": "20190315T000915.000Z" // } // ] // } // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON var id; var brand_id; var short_description; var description; var wholesale_price_cents; var retail_price_cents; var sale_state; var active; var deleted; var name; var unit_multiplier; var taxonomy_typeId; var taxonomy_typeName; var created_at; var updated_at; var j; var count_j; var page = jResp.IntOf("page"); var limit = jResp.IntOf("limit"); var i = 0; var count_i = jResp.SizeOfArray("products"); while (i < count_i) { jResp.I = i; id = jResp.StringOf("products[i].id"); brand_id = jResp.StringOf("products[i].brand_id"); short_description = jResp.StringOf("products[i].short_description"); description = jResp.StringOf("products[i].description"); wholesale_price_cents = jResp.IntOf("products[i].wholesale_price_cents"); retail_price_cents = jResp.IntOf("products[i].retail_price_cents"); sale_state = jResp.StringOf("products[i].sale_state"); active = jResp.BoolOf("products[i].active"); deleted = jResp.BoolOf("products[i].deleted"); name = jResp.StringOf("products[i].name"); unit_multiplier = jResp.IntOf("products[i].unit_multiplier"); taxonomy_typeId = jResp.StringOf("products[i].taxonomy_type.id"); taxonomy_typeName = jResp.StringOf("products[i].taxonomy_type.name"); created_at = jResp.StringOf("products[i].created_at"); updated_at = jResp.StringOf("products[i].updated_at"); j = 0; count_j = jResp.SizeOfArray("products[i].options"); while (j < count_j) { jResp.J = j; j = j+1; } i = i+1; } } chilkatExample(); |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.