### Product API Example Source: https://developers.lightspeedhq.com/ecom/index This example shows how to fetch products from Lightspeed eCom using a cURL command. ```APIDOC ## GET /products.json ### Description Fetches a list of products from the Lightspeed eCom store. ### Method GET ### Endpoint `{cluster}/products.json` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash curl {cluster}/products.json -u {key}:{secret} ``` ### Response #### Success Response (200) - **products** (array) - An array of product objects. #### Response Example ```json { "products": [ { "id": 1, "name": "Sample Product", "price": {"amount": "19.99", "currency": "USD"} } ] } ``` ``` -------------------------------- ### App Installation Source: https://developers.lightspeedhq.com/ecom/tutorials/installing-an-app This endpoint handles the installation of an app, validating the signature and storing shop credentials. ```APIDOC ## POST /websites/developers_lightspeedhq_ecom/install ### Description Handles the installation of an application on Lightspeed eCom. It validates the incoming request signature, stores the shop's ID, API token, and language for future use, and then redirects the user to the application. ### Method GET ### Endpoint /websites/developers_lightspeedhq_ecom/install ### Parameters #### Query Parameters - **language** (string) - Required - The language of the shop. - **shop_id** (string) - Required - The unique identifier for the shop. - **signature** (string) - Required - A unique signature for validating the request. - **timestamp** (string) - Required - The timestamp of the request. - **token** (string) - Required - The API token for the shop. - **cluster_id** (string) - Required - The identifier for the shop's cluster (e.g., 'us1', 'eu1'). ### Request Example ```php $_GET['language'], 'shop_id' => $_GET['shop_id'], 'timestamp' => $_GET['timestamp'], 'token' => $_GET['token'] ]; ksort($params); $signature_string = ''; foreach ($params as $key => $value) { $signature_string .= $key.'='.$value; } $signature = md5($signature_string.APP_SECRET); if ($signature == $_GET['signature']) { $sql = "INSERT INTO `shops` (`shop_id`, `token`, `language`, `clusterId`) VALUES (?,?,?,?)"; $stmt = $pdo->prepare($sql); $stmt->execute([ $_GET['shop_id'], $_GET['token'], $_GET['language'], $_GET['cluster_id'] // cluster_id is not part of the signature ]); header('Location: http://www.yourdomain.com/'); exit; } } ?> ``` ### Response #### Success Response (302 Found) - Redirects the user to the specified success URL. #### Response Example ``` HTTP/1.1 302 Found Location: http://www.yourdomain.com/ ``` ### Error Handling - If the signature validation fails, no data is stored, and the user is not redirected. ``` -------------------------------- ### Retrieve All Types (Specifications) Source: https://developers.lightspeedhq.com/ecom/introduction/images/Lightspeed_eCom.postman_collection Fetches all available product types, also known as specifications, from the shop. These types define product features like Camera or Color for example. No specific input parameters are required for this GET request. ```json { "description": "Retrieve all the types from this shop. Types are referred to as Specifications in the Lightspeed backoffice, these are used interchangeably. Specifications provide an overview of certain product features. For example a specification could be a Phone with the attributes like Camera, Color, and Dimensions." } ``` -------------------------------- ### Create Order Credit (API Request Examples) Source: https://developers.lightspeedhq.com/ecom/endpoints/ordercredit Demonstrates how to create an OrderCredit for an existing invoice via API. Includes cURL and PHP examples for making the POST request. The request requires authentication and specifies credit details and order products to be credited. Dependencies include the API endpoint and authentication credentials. ```curl curl -X POST https://api.shoplightspeed.com/en/orders/{order_id}/credit.json \ -u {key}:{secret} \ -d credit[creditPayment]=true \ -d credit[creditShipment]=true \ -d credit[notifyNew]=true \ -d credit[updateStock]=true \ -d orderProducts[quantity]=1 \ -d orderProducts[id]=1354 ``` ```php ordersCredit->create($order_id, [ "creditPayment" => true, "creditShipment" => true, "notifyNew" => true, "updateStock" => true, "orderProducts" => [ [ "quantity" => 1, "id" => {orderProductId} ] ] ]); ?> ``` -------------------------------- ### Retrieve Product - cURL Request Example Source: https://developers.lightspeedhq.com/ecom/endpoints/product An example of how to retrieve a product using cURL. This command sends a GET request to the Lightspeed API and requires authentication using your API key and secret. ```curl curl https://api.shoplightspeed.com/us/products/{product_id}.json \ -u {key}:{secret} ``` -------------------------------- ### Count Product Relations (Shell and PHP) Source: https://developers.lightspeedhq.com/ecom/endpoints/productrelation This snippet shows how to get the total number of product relations associated with a product. It provides a curl example for direct API requests and a PHP example for using the API client. ```shell curl https://api.shoplightspeed.com/en/products/{product_id}/relations/count.json \ -u {key}:{secret} ``` ```php productsRelations->count($product_id); ``` -------------------------------- ### POST /en/theme/products.json Source: https://developers.lightspeedhq.com/ecom/introduction/images/Lightspeed_eCom.postman_collection Create a new theme product based on the given parameters. ```APIDOC ## POST /en/theme/products.json ### Description Create a new theme product based on the given parameters. ### Method POST ### Endpoint `/en/theme/products.json` ### Parameters #### Request Body - **themeProduct** (object) - Required - Contains the details of the theme product to be created. - **productId** (integer) - Required - The ID of the product to be featured. ### Request Example ```json { "themeProduct": { "productId": 101 } } ``` ### Response #### Success Response (200) - **themeProduct** (object) - Information about the newly created theme product. #### Response Example ```json { "example": "" } ``` ``` -------------------------------- ### GET All Invoices - PHP Source: https://developers.lightspeedhq.com/ecom/endpoints/invoice Retrieves a list of all invoices for the shop using PHP. This example assumes the use of a hypothetical API client library. ```php invoices()->get(); // Process the $invoices array print_r($invoices); } catch (ApiException $e) { // Handle API exceptions echo 'Error fetching invoices: ' . $e->getMessage(); } ?> ``` -------------------------------- ### Create Discount (HTTP) Source: https://developers.lightspeedhq.com/ecom/introduction/images/Lightspeed_eCom.postman_collection Creates a new discount with specified parameters such as discount percentage, activation status, minimum amount, applicable categories/products, dates, type, code, and usage limits. Requires API key, secret, and cluster. Returns the created discount details. ```HTTP POST https://{{api_key}}:{{api_secret}}@api.{{cluster}}.com/en/discounts.json { "discount" : { "discount": 10, "isActive": true, "minumumAmount": 10, "categories": "1,2,3", "applyTo": "productscategories", "endDate": "2020-01-01", "type": "percentage", "code": "coupon_code", "timesUsed": 0, "products": "4,5,6", "startDate": "2014-01-01", "shipment": "default", "usageLimit": 1 } } ``` -------------------------------- ### GET Retrieve a category using cURL and PHP Source: https://developers.lightspeedhq.com/ecom/endpoints/category This snippet demonstrates how to retrieve a single category using its unique identifier. It shows an example request using cURL and a corresponding PHP code example utilizing a Lightspeed API client. The response includes detailed information about the category. ```curl curl https://api.shoplightspeed.com/en/categories/{category_id}.json \ -u {key}:{secret} ``` ```php categories->get($category_id); ``` -------------------------------- ### Create Customer using cURL Source: https://developers.lightspeedhq.com/ecom/endpoints/customer Demonstrates how to create a new customer using a cURL command. This method requires authentication and provides customer details as POST data. It's useful for scripting and direct API interaction. ```shell curl -X POST https://api.shoplightspeed.com/en/customers.json \ -u {key}:{secret} \ -d customer[isConfirmed]=true, \ -d customer[nationalId]="", \ -d customer[email]="info@lightspeedhq.com", \ -d customer[password]="lightspeedhq" \ -d customer[firstname]="Lightspeed", \ -d customer[middlename]= "", \ -d customer[lastname]="Test", \ -d customer[phone]="", \ -d customer[mobile]="", \ -d customer[companyName]="", \ -d customer[companyCoCNumber]="", \ -d customer[companyVatNumber]="", \ -d customer[addressBillingName]="", \ -d customer[addressBillingStreet]="", \ -d customer[addressBillingStreet2]="", \ -d customer[addressBillingNumber]="", \ -d customer[addressBillingExtension]="", \ -d customer[addressBillingZipcode]="", \ -d customer[addressBillingCity]="", \ -d customer[addressBillingRegion]="", \ -d customer[addressBillingCountry]="nl", \ -d customer[addressShippingName]="", \ -d customer[addressShippingStreet]="", \ -d customer[addressShippingStreet2]="", \ -d customer[addressShippingNumber]="", \ -d customer[addressShippingExtension]="", \ -d customer[addressShippingZipcode]="", \ -d customer[addressShippingCity]="", \ -d customer[addressShippingRegion]="", \ -d customer[addressShippingCountry]="nl", \ -d customer[memo]=null, \ -d customer[doNotifyRegistered]=true ``` -------------------------------- ### GET Number of Invoices - PHP Source: https://developers.lightspeedhq.com/ecom/endpoints/invoice Retrieves the total count of invoices for the shop using PHP. This example assumes the use of a hypothetical API client library. ```php invoices()->count(); echo 'Total invoices: ' . $invoiceCount; } catch (ApiException $e) { // Handle API exceptions echo 'Error fetching invoice count: ' . $e->getMessage(); } ?> ``` -------------------------------- ### Create Theme Product API Request Source: https://developers.lightspeedhq.com/ecom/introduction/images/Lightspeed_eCom.postman_collection Creates a new theme product with specified details. This POST request includes authentication and a raw JSON body containing the product information. The response is empty. ```json { "name": "Create a new theme product", "request": { "auth": { "type": "noauth" }, "method": "POST", "header": [], "body": { "mode": "raw", "raw": "{\n \"themeProduct\": {\n \"productId\": 101\n }\n}" }, "url": { "raw": "https://{{api_key}}:{{api_secret}}@api.{{cluster}}.com/en/theme/products.json", "protocol": "https", "host": [ "api", "{{cluster}}", "com" ], "auth": { "user": "{{api_key}}", "password": "{{api_secret}}" }, "path": [ "en", "theme", "products.json" ] }, "description": "Create a new theme product based on the given parameters." }, "response": [] } ``` -------------------------------- ### Install App: Validate Signature and Store Shop Details (PHP) Source: https://developers.lightspeedhq.com/ecom/tutorials/installing-an-app This script handles the installation process for a Lightspeed eCom app. It validates the incoming request signature using provided credentials and stores essential shop information (shop_id, token, language, clusterId) in a MySQL database. Dependencies include PDO for database interaction. It expects GET parameters for language, shop_id, signature, timestamp, and token. ```php $_GET['language'], 'shop_id' => $_GET['shop_id'], 'timestamp' => $_GET['timestamp'], 'token' => $_GET['token'] // in between token ]; ksort($params); $signature = ''; foreach ($params as $key => $value) { $signature .= $key.'='.$value; } $signature = md5($signature.APP_SECRET); // Validate the signature if ($signature == $_GET['signature']) { // Store the store identifier (ID), API token and store language for later use // Each API token represents a single store $sql = " INSERT INTO `shops` ( `shop_id`, `token`, `language`, `clusterId` ) VALUES (?,?,?,?)"; $stmt = $pdo->prepare($sql); $stmt->execute([ $_GET['shop_id'], $_GET['token'], $_GET['language'], $_GET['cluster_id'] ]); // Redirect the user to your app header('Location: http://www.yourdomain.com/'); exit; } } ``` -------------------------------- ### GET Retrieve an Invoice - PHP Source: https://developers.lightspeedhq.com/ecom/endpoints/invoice Fetches details for a specific invoice using its unique identifier in PHP. This example assumes the use of a hypothetical API client library. ```php invoices()->get($invoiceId); // Process the $invoice object print_r($invoice); } catch (ApiException $e) { // Handle API exceptions echo 'Error fetching invoice ' . $invoiceId . ': ' . $e->getMessage(); } ?> ``` -------------------------------- ### POST /en/products.json Source: https://developers.lightspeedhq.com/ecom/introduction/images/Lightspeed_eCom.postman_collection Creates a new product in the store. Requires product details in the request body. ```APIDOC ## POST /en/products.json ### Description Create a new product. ### Method POST ### Endpoint /en/products.json ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **product** (object) - Required - Contains the details of the product to be created. - **visibility** (string) - Optional - The visibility of the product (e.g., "hidden"). - **title** (string) - Required - The title of the product. - **fulltitle** (string) - Optional - The full title of the product. - **description** (string) - Optional - The description of the product. - **content** (string) - Optional - The content of the product. - **deliverydate** (integer) - Optional - The delivery date indicator. - **supplier** (integer) - Optional - The supplier ID. - ... (other product fields) ### Request Example ```json { "product": { "visibility": "hidden", "title": "Wade Crewneck Navyblue", "description": "De Wade Crewneck Navyblue van Wemoto." } } ``` ### Response #### Success Response (201 Created) - **product** (object) - Contains the details of the newly created product. - **id** (integer) - The product ID. - **title** (string) - The product title. - ... (other product fields) #### Response Example ```json { "product": { "id": 124, "title": "Wade Crewneck Navyblue" } } ``` ``` -------------------------------- ### Create Product (Shell) Source: https://developers.lightspeedhq.com/ecom/introduction/resources Creates a new product in Lightspeed via the API using a POST request. This example sets the `title` and `fulltitle` for the new product. Authentication and data payload are required. ```shell curl https://api.shoplightspeed.com/en/products.json \ -u {key}:{secret} \ -d product[title]="My product" \ -d product[fulltitle]="My first product" ``` -------------------------------- ### GET Blog Count - Curl and PHP Source: https://developers.lightspeedhq.com/ecom/endpoints/blog Retrieves the total number of blog objects available in the shop. This endpoint does not accept any arguments or filters. Example requests are provided for Curl and PHP. ```curl curl https://api.shoplightspeed.com/en/blogs/count.json \ -u {key}:{secret} ``` ```php blogs->count(); ``` -------------------------------- ### POST /en/products/{product_id}/images.json Source: https://developers.lightspeedhq.com/ecom/introduction/images/Lightspeed_eCom.postman_collection Create a new image for a product. ```APIDOC ## POST /en/products/{product_id}/images.json ### Description Create a new image for a product. ### Method POST ### Endpoint /en/products/{product_id}/images.json ### Parameters #### Path Parameters - **product_id** (integer) - Required - The unique identifier of the product. #### Request Body - **productImage** (object) - Required - The image details. - **attachment** (string) - Required - Base64 encoded image data. - **filename** (string) - Required - The filename of the image with extension. ### Request Example ```json { "example": "{\n \"productImage\": {\n \"attachment\": \"base64-encoded-image-body-goes-here\",\n \"filename\": \"the-filename-with-extension-goes-here.jpg\"\n }\n}" } ``` ### Response #### Success Response (201) - **productImage** (object) - The created image object. - **id** (integer) - The image ID. - **src** (string) - The URL of the image. - **alt** (string) - The alternative text for the image. #### Response Example ```json { "example": "{\n \"productImage\": {\n \"id\": 456,\n \"src\": \"https://example.com/images/new_product.jpg\",\n \"alt\": \"New Product Image\"\n }\n}" } ``` ``` -------------------------------- ### Filter Products (Shell) Source: https://developers.lightspeedhq.com/ecom/introduction/resources Retrieves a filtered list of products from the Lightspeed API using GET parameters for pagination and limiting results. This example requests page 2 with 100 products per page. Authentication is required. ```shell $ curl https://api.shoplightspeed.com/en/products.json?page=2&limit=100 -u {key}:{secret} ``` -------------------------------- ### Webshopapp API Client Source: https://developers.lightspeedhq.com/ecom/tutorials/installing-an-app Demonstrates how to establish a connection with the Webshopapp API for a specific shop. ```APIDOC ## Making Calls with the API ### Description Once shop information is stored, this section shows how to instantiate the `WebshopappApiClient` to interact with the Lightspeed eCom API for a specific shop. ### Method N/A (This is a client-side setup example) ### Endpoint N/A ### Parameters #### Request Body (Not applicable for client instantiation) ### Request Example ```php query("SELECT * FROM shops WHERE shop_id = {$shopId}")->fetch(PDO::FETCH_ASSOC); // Create authentication token $userSecret = md5($shop['token'].APP_SECRET); // Connect to the Webshopapp API using the cluster, stored API token and store language $cluster = 'eu1'; // Or 'us1' based on the shop's cluster_id $api = new WebshopappApiClient($cluster, APP_KEY, $userSecret, $shop['language']); // Now you can use the $api object to make calls to the Webshopapp API // Example: $products = $api->products()->get(); ?> ``` ### Response #### Success Response (N/A for instantiation) - The `WebshopappApiClient` object is successfully created. #### Response Example (Not applicable for instantiation) ### Clusters Lightspeed eCom uses multiple clusters. The `cluster_id` parameter received during installation identifies which cluster a shop is hosted on. Current clusters include `us1` and `eu1`. ``` -------------------------------- ### Retrieve All Discount Rules (HTTP) Source: https://developers.lightspeedhq.com/ecom/introduction/images/Lightspeed_eCom.postman_collection Fetches a list of all discount rules configured in the shop. Requires API key, secret, and cluster. No specific discount rule ID is needed. Returns a list of discount rules. ```HTTP GET https://{{api_key}}:{{api_secret}}@api.{{cluster}}.com/en/discount_rules.json ``` -------------------------------- ### Retrieve All Shipments (PHP) Source: https://developers.lightspeedhq.com/ecom/endpoints/shipment Retrieves all shipment records using PHP and the cURL library to interact with the Lightspeed HQ E-commerce API. This example demonstrates making a GET request to the shipments endpoint, including necessary authentication headers. ```php ``` -------------------------------- ### Retrieve All Category Products (GET) Source: https://developers.lightspeedhq.com/ecom/introduction/images/Lightspeed_eCom.postman_collection Fetches all category products available in the shop. Requires authentication. ```json { "method": "GET", "url": { "raw": "https://{{api_key}}:{{api_secret}}@api.{{cluster}}.com/en/categories/products.json", "protocol": "https", "host": [ "api", "{{cluster}}", "com" ], "auth": { "user": "{{api_key}}", "password": "{{api_secret}}" }, "path": [ "en", "categories", "products.json" ] }, "description": "Retrieve all categorie products available in the shop." } ``` -------------------------------- ### GET Single Blog by ID - Curl and PHP Source: https://developers.lightspeedhq.com/ecom/endpoints/blog Fetches a single blog resource using its unique identifier. You can optionally filter the results using parameters like `limit`, `page`, `created_at_min`, etc. Example requests are provided for Curl and PHP. ```curl curl https://api.shoplightspeed.com/en/blogs/{blog_id}.json \ -u {key}:{secret} ``` ```php blogs->get($blog_id); ``` -------------------------------- ### Get All Shipping Method Values (PHP) Source: https://developers.lightspeedhq.com/ecom/endpoints/shippingmethodvalue A PHP example demonstrating how to fetch all shipping method values for a given shipping method using the Lightspeed API client. This function is part of the webhooks or a similar API interaction module. ```php webhooks->get(); ``` -------------------------------- ### Create Customer using PHP Source: https://developers.lightspeedhq.com/ecom/endpoints/customer Provides a PHP code snippet for creating a customer using the Lightspeed HQ API. This example utilizes a hypothetical $api object and its customers->create method, passing customer data as an associative array. It's suitable for server-side integrations. ```php customers->create([ "isConfirmed" => true, "nationalId" => "", "email" => "info@lightspeedhq.com", "password" => "lightspeedhq", "firstname" => "Lightspeed", "middlename" => "", "lastname" => "Test", "phone" => "", "mobile" => "", "companyName" => "", "companyCoCNumber" => "", "companyVatNumber" => "", "addressBillingName" => "", "addressBillingStreet" => "", "addressBillingStreet2" => "", "addressBillingNumber" => "", "addressBillingExtension" => "", "addressBillingZipcode" => "", "addressBillingCity" => "", "addressBillingRegion" => "", "addressBillingCountry" => "nl", "addressShippingName" => "", "addressShippingStreet" => "", "addressShippingStreet2" => "", "addressShippingNumber" => "", "addressShippingExtension" => "", "addressShippingZipcode" => "", "addressShippingCity" => "", "addressShippingRegion" => "", "addressShippingCountry" => "nl", "memo" => null, "doNotifyRegistered" => true ]); ``` -------------------------------- ### Retrieve Shop Limits (PHP) Source: https://developers.lightspeedhq.com/ecom/endpoints/shoplimits This PHP snippet illustrates how to fetch shop limits via an API request. It utilizes the cURL library to make a GET request to the relevant endpoint and handles the JSON response. Ensure you have the cURL extension enabled in your PHP installation. ```php ``` -------------------------------- ### POST /customers.json Source: https://developers.lightspeedhq.com/ecom/endpoints/customer Create a new customer by providing the necessary details in the request body. ```APIDOC ## POST /customers.json ### Description Create a new customer based on the given parameters. ### Method POST ### Endpoint /customers.json ### Parameters #### Request Body - **customer** (object) - Required - The customer object containing customer details. - **isConfirmed** (boolean) - Optional - Indicates if the customer is confirmed. - **nationalId** (string) - Optional - The national ID of the customer. - **email** (string) - Required - The email address of the customer. - **password** (string) - Required - The password for the customer account. - **firstname** (string) - Required - The first name of the customer. - **middlename** (string) - Optional - The middle name of the customer. - **lastname** (string) - Required - The last name of the customer. - **phone** (string) - Optional - The phone number of the customer. - **mobile** (string) - Optional - The mobile number of the customer. - **companyName** (string) - Optional - The name of the company the customer is associated with. - **companyCoCNumber** (string) - Optional - The Chamber of Commerce number for the company. - **companyVatNumber** (string) - Optional - The VAT number for the company. - **addressBillingName** (string) - Optional - The name for the billing address. - **addressBillingStreet** (string) - Optional - The street for the billing address. - **addressBillingStreet2** (string) - Optional - The second line of the billing street address. - **addressBillingNumber** (string) - Optional - The street number for the billing address. - **addressBillingExtension** (string) - Optional - The extension for the billing street number. - **addressBillingZipcode** (string) - Optional - The zip code for the billing address. - **addressBillingCity** (string) - Optional - The city for the billing address. - **addressBillingRegion** (string) - Optional - The region for the billing address. - **addressBillingCountry** (string) - Optional - The country code for the billing address (e.g., 'nl'). - **addressShippingName** (string) - Optional - The name for the shipping address. - **addressShippingStreet** (string) - Optional - The street for the shipping address. - **addressShippingStreet2** (string) - Optional - The second line of the shipping street address. - **addressShippingNumber** (string) - Optional - The street number for the shipping address. - **addressShippingExtension** (string) - Optional - The extension for the shipping street number. - **addressShippingZipcode** (string) - Optional - The zip code for the shipping address. - **addressShippingCity** (string) - Optional - The city for the shipping address. - **addressShippingRegion** (string) - Optional - The region for the shipping address. - **addressShippingCountry** (string) - Optional - The country code for the shipping address (e.g., 'nl'). - **memo** (string) - Optional - A memo associated with the customer. - **doNotifyRegistered** (boolean) - Optional - Indicates if the customer should be notified upon registration. ### Request Example ```json { "customer": { "isConfirmed": true, "nationalId": "", "email": "info@lightspeedhq.com", "password": "lightspeedhq", "firstname": "Lightspeed", "middlename": "", "lastname": "Test", "phone": "", "mobile": "", "companyName": "", "companyCoCNumber": "", "companyVatNumber": "", "addressBillingName": "", "addressBillingStreet": "", "addressBillingStreet2": "", "addressBillingNumber": "", "addressBillingExtension": "", "addressBillingZipcode": "", "addressBillingCity": "", "addressBillingRegion": "", "addressBillingCountry": "nl", "addressShippingName": "", "addressShippingStreet": "", "addressShippingStreet2": "", "addressShippingNumber": "", "addressShippingExtension": "", "addressShippingZipcode": "", "addressShippingCity": "", "addressShippingRegion": "", "addressShippingCountry": "nl", "memo": null, "doNotifyRegistered": true } } ``` ### Response #### Success Response (200) - **customer** (object) - The created customer object. - **id** (integer) - The unique identifier of the customer. - **createdAt** (string) - The timestamp when the customer was created. - **updatedAt** (string) - The timestamp when the customer was last updated. - **isConfirmed** (boolean) - Indicates if the customer is confirmed. - **type** (string) - The type of customer. - **lastOnlineAt** (string) - The timestamp of the customer's last online activity. - **remoteIp** (string) - The IP address from which the customer last connected. - **userAgent** (string) - The user agent string of the customer's last connection. - **referralId** (string) - The referral ID associated with the customer. - **gender** (string) - The gender of the customer. - **birthDate** (string) - The birth date of the customer. - **nationalId** (string) - The national ID of the customer. - **email** (string) - The email address of the customer. - **firstname** (string) - The first name of the customer. - **middlename** (string) - The middle name of the customer. - **lastname** (string) - The last name of the customer. - **phone** (string) - The phone number of the customer. - **mobile** (string) - The mobile number of the customer. - **isCompany** (boolean) - Indicates if the customer is a company. - **companyName** (string) - The name of the company the customer is associated with. - **companyCoCNumber** (string) - The Chamber of Commerce number for the company. - **companyVatNumber** (string) - The VAT number for the company. - **addressBillingName** (string) - The name for the billing address. - **addressBillingStreet** (string) - The street for the billing address. - **addressBillingStreet2** (string) - The second line of the billing street address. - **addressBillingNumber** (string) - The street number for the billing address. - **addressBillingExtension** (string) - The extension for the billing street number. - **addressBillingZipcode** (string) - The zip code for the billing address. - **addressBillingCity** (string) - The city for the billing address. - **addressBillingRegion** (string) - The region for the billing address. - **addressBillingCountry** (object) - The billing country details. - **id** (integer) - The country ID. - **countryId** (string) - The country code. - **name** (string) - The country name. - **continent** (string) - The continent the country belongs to. - **iso2** (string) - The ISO 3166-1 alpha-2 country code. - **iso3** (string) - The ISO 3166-1 alpha-3 country code. - **currencyId** (integer) - The ID of the currency used in the country. - **currencyCode** (string) - The currency code. - **currencySymbol** (string) - The currency symbol. - **currencyName** (string) - The currency name. - **callingCodes** (array) - An array of calling codes for the country. - **region** (string) - The region the country belongs to. - **subregion** (string) - The subregion the country belongs to. - **translations** (object) - Translations of the country name. - **de** (string) - German translation. - **es** (string) - Spanish translation. - **fr** (string) - French translation. - **ja** (string) - Japanese translation. - **it** (string) - Italian translation. - **pt-BR** (string) - Brazilian Portuguese translation. - **zh-CN** (string) - Simplified Chinese translation. - **zh-TW** (string) - Traditional Chinese translation. - **ko** (string) - Korean translation. - **ru** (string) - Russian translation. - **pt** (string) - Portuguese translation. - **createdAt** (string) - The timestamp when the country record was created. - **updatedAt** (string) - The timestamp when the country record was last updated. #### Response Example ```json { "customer": { "id": 2179248, "createdAt": "2019-09-06T20:22:56+00:00", "updatedAt": "2019-09-06T20:22:56+00:00", "isConfirmed": true, "type": "registered", "lastOnlineAt": null, "remoteIp": false, "userAgent": false, "referralId": false, "gender": false, "birthDate": false, "nationalId": "", "email": "info@lightspeedhq.com", "firstname": "Lightspeed", "middlename": "", "lastname": "Test", "phone": "", "mobile": "", "isCompany": false, "companyName": "", "companyCoCNumber": "", "companyVatNumber": "", "addressBillingName": "", "addressBillingStreet": "", "addressBillingStreet2": "", "addressBillingNumber": "", "addressBillingExtension": "", "addressBillingZipcode": "", "addressBillingCity": "", "addressBillingRegion": "", "addressBillingCountry": { "id": 161, "countryId": "NL", "name": "Netherlands", "continent": "Europe", "iso2": "NL", "iso3": "NLD", "currencyId": 12, "currencyCode": "EUR", "currencySymbol": "€", "currencyName": "Euro", "callingCodes": [ "31" ], "region": "Europe", "subregion": "Western Europe", "translations": { "de": "Niederlande", "es": "Países Bajos", "fr": "Pays-Bas", "ja": "オランダ", "it": "Paesi Bassi", "pt-BR": "Países Baixos", "zh-CN": "荷兰", "zh-TW": "荷蘭", "ko": "네덜란드", "ru": "Нидерланды", "pt": "Países Baixos" }, "createdAt": "2017-07-18T09:31:52+00:00", "updatedAt": "2017-07-18T09:31:52+00:00" }, "addressShippingName": "", "addressShippingStreet": "", "addressShippingStreet2": "", "addressShippingNumber": "", "addressShippingExtension": "", "addressShippingZipcode": "", "addressShippingCity": "", "addressShippingRegion": "", "addressShippingCountry": { "id": 161, "countryId": "NL", "name": "Netherlands", "continent": "Europe", "iso2": "NL", "iso3": "NLD", "currencyId": 12, "currencyCode": "EUR", "currencySymbol": "€", "currencyName": "Euro", "callingCodes": [ "31" ], "region": "Europe", "subregion": "Western Europe", "translations": { "de": "Niederlande", "es": "Países Bajos", "fr": "Pays-Bas", "ja": "オランダ", "it": "Paesi Bassi", "pt-BR": "Países Baixos", "zh-CN": "荷兰", "zh-TW": "荷蘭", "ko": "네덜란드", "ru": "Нидерланды", "pt": "Países Baixos" }, "createdAt": "2017-07-18T09:31:52+00:00", "updatedAt": "2017-07-18T09:31:52+00:00" }, "memo": null, "doNotifyRegistered": true } } ``` ``` -------------------------------- ### Get Single Shipping Method Value (PHP) Source: https://developers.lightspeedhq.com/ecom/endpoints/shippingmethodvalue A PHP example for retrieving a single shipping method value by its ID, within the context of a specific shipping method. This method allows direct access to the configuration of a particular shipping price tier. ```php shippingmethodsValues->get($shippingmethodValue_id); ``` -------------------------------- ### Create Customer via API Source: https://developers.lightspeedhq.com/ecom/introduction/images/Lightspeed_eCom.postman_collection Creates a new customer profile in the system. This POST request requires authentication and a JSON payload containing the customer's details, including contact and address information. It returns the newly created customer object. ```shell curl -X POST "https://{{api_key}}:{{api_secret}}@api.{{cluster}}.com/en/customers.json" \ -H "Content-Type: application/json" \ -d '{ "customer": { "isConfirmed": true, "nationalId": "", "email": "info@lightspeedhq.com", "firstname": "John", "middlename": "", "lastname": "Doe", "phone": "", "mobile": "", "companyName": "", "companyCoCNumber": "", "companyVatNumber": "", "addressBillingName": "", "addressBillingStreet": "", "addressBillingStreet2": "", "addressBillingNumber": "", "addressBillingExtension": "", "addressBillingZipcode": "", "addressBillingCity": "", "addressBillingRegion": "", "addressBillingCountry": "nl", "addressShippingName": "", "addressShippingStreet": "", "addressShippingStreet2": "", "addressShippingNumber": "", "addressShippingExtension": "", "addressShippingZipcode": "", "addressShippingCity": "", "addressShippingRegion": "", "addressShippingCountry": "nl", "memo": null, "doNotifyRegistered": true } }' ``` -------------------------------- ### Create a new set (JSON) Source: https://developers.lightspeedhq.com/ecom/introduction/images/Lightspeed_eCom.postman_collection This snippet demonstrates how to create a new product option set. It includes defining values for options like 'Color' and 'Size'. The request body is in JSON format. ```json { "set" : { "options" : [ { "values" : [ { "sortOrder" : 1, "id" : 168, "name" : "Black" }, { "sortOrder" : 2, "id" : 169, "name" : "White" } ], "sortOrder" : 1, "id" : 76, "name" : "Color" }, { "values" : [ { "sortOrder" : 1, "id" : 170, "name" : "S" }, { "sortOrder" : 2, "id" : 171, "name" : "M" }, { "sortOrder" : 3, "id" : 172, "name" : "L" } ], "sortOrder" : 2, "id" : 77, "name" : "Size" } ], "name" : "Clothing" } } ``` -------------------------------- ### GET /types/attributes/count - Get Number of Attributes Source: https://developers.lightspeedhq.com/ecom/endpoints/typesattribute Retrieves the total number of typesAttribute objects. Use this endpoint to get a count of all attribute type associations. ```APIDOC ## GET /types/attributes/count ### Description Retrieve the total number of typesAttribute objects. ### Method GET ### Endpoint /types/attributes/count.json ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Request Example ```json { "example": "curl https://api.shoplightspeed.com/en/types/attributes/count.json -u {key}:{secret}" } ``` ### Response #### Success Response (200) - **count** (integer) - The total number of typesAttribute objects. #### Response Example ```json { "count": 3 } ``` ``` -------------------------------- ### Retrieve Product - PHP SDK Example Source: https://developers.lightspeedhq.com/ecom/endpoints/product An example of how to retrieve a product using the Lightspeed PHP SDK. This code assumes you have initialized the API client and have the `$product_id` variable set. ```php products->get($product_id); ``` -------------------------------- ### Get Checkout Count (GET Request) Source: https://developers.lightspeedhq.com/ecom/introduction/images/Lightspeed_eCom.postman_collection This snippet shows how to retrieve the total number of checkouts using a GET request. The endpoint is simple and does not require a request body. It returns a count of all existing checkouts. ```HTTP GET /en/checkouts/count.json Host: api.{{cluster}}.com Authorization: Basic {{api_key}}:{{api_secret}} ``` -------------------------------- ### Fetch Products using cURL (Lightspeed eCom API) Source: https://developers.lightspeedhq.com/ecom/index Example demonstrating how to fetch products from Lightspeed eCom using a cURL command. This requires specifying the correct API cluster URL and authentication credentials (key and secret). ```shell $ curl {cluster}/products.json -u {key}:{secret} ``` -------------------------------- ### GET All Blog Articles (API & PHP) Source: https://developers.lightspeedhq.com/ecom/endpoints/blogarticle Retrieves a list of all blogArticle objects. This can be done via a GET request to the API endpoint or by calling the get() method on the blogsArticles property of the API client. ```http GET /blogs/articles.json curl https://api.shoplightspeed.com/en/blogs/articles.json \ -u {key}:{secret} ``` ```php $api->blogsArticles->get(); ```