Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Tcl Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Tcl) Faire - Get All Products

See more Faire Examples

Retrieves 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

Chilkat Tcl Extension Downloads

Chilkat Tcl Extension Downloads

load ./chilkat.dll

# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

set http [new_CkHttp]

# 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

set queryParams [new_CkJsonObject]

CkJsonObject_UpdateInt $queryParams "limit" 50
CkJsonObject_UpdateInt $queryParams "page" 1

CkHttp_SetRequestHeader $http "X-FAIRE-ACCESS-TOKEN" "<access_token>"

# resp is a CkHttpResponse
set resp [CkHttp_QuickRequestParams $http "GET" "https://www.faire.com/api/v1/products" $queryParams]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkJsonObject $queryParams
    exit
}

set sbResponseBody [new_CkStringBuilder]

CkHttpResponse_GetBodySb $resp $sbResponseBody

set jResp [new_CkJsonObject]

CkJsonObject_LoadSb $jResp $sbResponseBody
CkJsonObject_put_EmitCompact $jResp 0

puts "Response Body:"
puts [CkJsonObject_emit $jResp]

set respStatusCode [CkHttpResponse_get_StatusCode $resp]
puts "Response Status Code = $respStatusCode"
if {$respStatusCode >= 400} then {
    puts "Response Header:"
    puts [CkHttpResponse_header $resp]
    puts "Failed."
    delete_CkHttpResponse $resp

    delete_CkHttp $http
    delete_CkJsonObject $queryParams
    delete_CkStringBuilder $sbResponseBody
    delete_CkJsonObject $jResp
    exit
}

delete_CkHttpResponse $resp

# 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

set page [CkJsonObject_IntOf $jResp "page"]
set limit [CkJsonObject_IntOf $jResp "limit"]
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "products"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set id [CkJsonObject_stringOf $jResp "products[i].id"]
    set brand_id [CkJsonObject_stringOf $jResp "products[i].brand_id"]
    set short_description [CkJsonObject_stringOf $jResp "products[i].short_description"]
    set description [CkJsonObject_stringOf $jResp "products[i].description"]
    set wholesale_price_cents [CkJsonObject_IntOf $jResp "products[i].wholesale_price_cents"]
    set retail_price_cents [CkJsonObject_IntOf $jResp "products[i].retail_price_cents"]
    set sale_state [CkJsonObject_stringOf $jResp "products[i].sale_state"]
    set active [CkJsonObject_BoolOf $jResp "products[i].active"]
    set deleted [CkJsonObject_BoolOf $jResp "products[i].deleted"]
    set name [CkJsonObject_stringOf $jResp "products[i].name"]
    set unit_multiplier [CkJsonObject_IntOf $jResp "products[i].unit_multiplier"]
    set taxonomy_typeId [CkJsonObject_stringOf $jResp "products[i].taxonomy_type.id"]
    set taxonomy_typeName [CkJsonObject_stringOf $jResp "products[i].taxonomy_type.name"]
    set created_at [CkJsonObject_stringOf $jResp "products[i].created_at"]
    set updated_at [CkJsonObject_stringOf $jResp "products[i].updated_at"]
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "products[i].options"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set j [expr $j + 1]
    }
    set i [expr $i + 1]
}

delete_CkHttp $http
delete_CkJsonObject $queryParams
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.