Passing Data After a Retail & E commerce Sale?

2>

37 comments

  • gregaricangregarican Posts: 227Member 
    You can definitely get to the images by loading that relation. See https://developers.lightspeedhq.com/retail/endpoints/Item/ for details. Below is an example where I pull an item and include a few different relations in my query. So the results include images, tags, categoties, notes, custom fields, etc.

    I know that a print preview of a sale receipt in the web client is an URL which includes the sale ID in the URL itself. So you might be able to pull an HTML form of this via the API by toying around a bit. I'll maybe look at that in a moment!

    GET https://api.merchantos.com/API/Account/{AccountId}/Item/55.json?load_relations=[%22CustomFieldValues%22,%20%22CustomFieldValues.value%22,%22ItemShops%22,

    %20%22Images%22,%20%22TagRelations.Tag%22,%20%22ItemECommerce%22,%20%22Category%22,%20%22Note%22] HTTP/1.1
    cache-control: no-cache
    Postman-Token: 6e56448f-c815-44e1-81a2-fc2eabdc61b8
    Authorization: Bearer {authToken}
    User-Agent: PostmanRuntime/7.4.0
    Accept: */*
    Host: api.merchantos.com
    cookie: __cfduid=dc92c208fe990511a3e7b3f1c7a60be141540561895
    accept-encoding: gzip, deflate
    Connection: close


    HTTP/1.1 200 OK
    Date: Wed, 26 Dec 2018 18:48:19 GMT
    Content-Type: application/json
    Content-Length: 5235
    Connection: close
    x-frame-options: SAMEORIGIN
    X-XSS-Protection: 1; mode=block
    X-Content-Type-Options: nosniff
    X-LS-Acct-Id: 164019
    X-LS-OAuth-Client-Id: 64577
    X-LS-API-Bucket-Level: 1/100
    X-LS-Shard-Id: 18
    X-LS-API-Drip-Rate: 5
    X-LS-Master-System: true
    X-LS-Master-Account: true
    X-LS-Master-Catalog: false
    Vary: Accept-Encoding
    Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
    Server: cloudflare
    CF-RAY: 48f5b8918ba12519-ORD

    {"@attributes":{"count":"1"},"Item":

    {"itemID":"55","systemSku":"210000000055","defaultCost":"100","avgCost":"100","discountable":"true","tax":"true","archived":"true","itemType":"default","serialized":"f

    alse","description":"Samsung 40\" tv (Sample API Upload).","modelYear":"0","upc":"","ean":"","customSku":"12341234","manufacturerSku":"43214321","createTime":"2018-02

    -16T15:54:18+00:00","timeStamp":"2018-10-

    08T13:14:47+00:00","publishToEcom":"true","categoryID":"36","taxClassID":"1","departmentID":"0","itemMatrixID":"0","manufacturerID":"0","seasonID":"0","defaultVendorID

    ":"200","Category":{"categoryID":"36","name":"Accessories","nodeDepth":"0","fullPathName":"Accessories","leftNode":"1","rightNode":"12","createTime":"2018-02-

    10T16:30:23+00:00","timeStamp":"2018-06-09T21:07:02+00:00","parentID":"0"},"Note":{"note":"This is a newly-updated note.","isPublic":"false","timeStamp":"2018-10-

    08T13:14:32+00:00"},"ItemECommerce":{"itemECommerceID":"4361","longDescription":"<p>This is the web store long description.<\/p>","shortDescription":"<p>This is the 

    web store short description.<\/p>","weight":"0","width":"0","height":"0","length":"0","listOnStore":"false"},"Images":{"Image":{"imageID":"31","description":"Test 

    Image","filename":"cd1a6cbd-3b30-4d42-8d06-

    0cc6822ab667_1.ce3f985d0ce5b858291bdd202a24b448.jpeg","ordering":"0","publicID":"ef1bwqdftbh8sxmi5uru","baseImageURL":"https:\/\/res.cloudinary.com\/lightspeed-retail

    \/image\/upload\/","size":"801123","createTime":"2018-02-16T15:54:21+00:00","timeStamp":"2018-02-16T15:54:21+00:00","itemID":"55","itemMatrixID":"0"}},"ItemShops":

    {"ItemShop":[{"itemShopID":"164","qoh":"0","backorder":"0","componentQoh":"0","componentBackorder":"0","reorderPoint":"0","reorderLevel":"0","timeStamp":"2018-02-

    16T20:31:38+00:00","itemID":"55","shopID":"1","m":{"layaways":"0","specialorders":"0","workorders":"0"}},

    {"itemShopID":"165","qoh":"0","backorder":"0","componentQoh":"0","componentBackorder":"0","reorderPoint":"0","reorderLevel":"0","timeStamp":"2018-02-

    16T20:31:38+00:00","itemID":"55","shopID":"2","m":{"layaways":"0","specialorders":"0","workorders":"0"}},

    {"itemShopID":"1408","qoh":"0","backorder":"0","componentQoh":"0","componentBackorder":"0","reorderPoint":"0","reorderLevel":"0","timeStamp":"2018-04-

    30T15:26:23+00:00","itemID":"55","shopID":"3","m":{"layaways":"0","specialorders":"0","workorders":"0"}},

    {"itemShopID":"1919","qoh":"0","backorder":"0","componentQoh":"0","componentBackorder":"0","reorderPoint":"0","reorderLevel":"0","timeStamp":"2018-04-

    30T15:29:46+00:00","itemID":"55","shopID":"4","m":{"layaways":"0","specialorders":"0","workorders":"0"}},

    {"itemShopID":"2430","qoh":"0","backorder":"0","componentQoh":"0","componentBackorder":"0","reorderPoint":"0","reorderLevel":"0","timeStamp":"2018-04-

    30T15:32:04+00:00","itemID":"55","shopID":"5","m":{"layaways":"0","specialorders":"0","workorders":"0"}},

    {"itemShopID":"163","qoh":"0","backorder":"0","componentQoh":"0","componentBackorder":"0","reorderPoint":"0","reorderLevel":"0","timeStamp":"2018-02-

    16T20:31:38+00:00","itemID":"55","shopID":"0","m":{"layaways":"0","specialorders":"0","workorders":"0"}}]},"CustomFieldValues":{"CustomFieldValue":

    [{"customFieldValueID":"430","customFieldID":"13","name":"Stone 2","type":"single_choice","value":

    {"customFieldChoiceID":"194","value":"","name":"Agate","canBeDeleted":"false","customFieldID":"13"}},{"customFieldValueID":"431","customFieldID":"15","name":"Stone 2 

    Attributes","type":"text","value":"These are the Accent Stone 2 Attributes."},

    {"customFieldValueID":"432","customFieldID":"5","name":"Includes","type":"multi_choice","value":

    {"customFieldChoiceID":"60","value":"","name":"Box","canBeDeleted":"false","customFieldID":"5"}},

    {"customFieldValueID":"433","customFieldID":"5","name":"Includes","type":"multi_choice","value":{"customFieldChoiceID":"64","value":"","name":"Warranty 

    Card","canBeDeleted":"false","customFieldID":"5"}},{"customFieldValueID":"434","customFieldID":"17","name":"Stone 3 Attributes","type":"text","value":""},

    {"customFieldValueID":"435","customFieldID":"19","name":"Stone 4 Attributes","type":"text","value":""},

    {"customFieldValueID":"436","customFieldID":"24","name":"Accessory Dimensions","type":"text","value":""},

    {"customFieldValueID":"437","customFieldID":"29","name":"Year","type":"string","value":""},

    {"customFieldValueID":"438","customFieldID":"26","name":"Condition","type":"text","value":""},{"customFieldValueID":"439","customFieldID":"9","name":"Main Stone 

    Attributes","type":"text","value":""},{"customFieldValueID":"77689","customFieldID":"39","name":"Cert\/Serial Number","type":"string","value":""},

    {"customFieldValueID":"77690","customFieldID":"46","name":"Watch Caliber","type":"string","value":""},{"customFieldValueID":"77691","customFieldID":"37","name":"Watch 

    Case Size","type":"string","value":""},{"customFieldValueID":"77692","customFieldID":"34","name":"Watch Model Number","type":"string","value":""},

    {"customFieldValueID":"78479","customFieldID":"47","name":"Publish to Shopify","type":"boolean","value":"false"}]},"Prices":{"ItemPrice":

    [{"amount":"220","useTypeID":"1","useType":"Default"},{"amount":"550","useTypeID":"2","useType":"MSRP"},{"amount":"220","useTypeID":"3","useType":"Online"}]}}}
  • gregaricangregarican Posts: 227Member 
    edited December 2018
    If you issue a GET method against the URL that appears in the web client for a print-preview sale receipt, then as long as you include the auth token you can get a response with the HTML receipt itself. Just tried this out successfully on my end as a test. In short, you'd issue a GET with an URL like ---

    https://us.merchantos.com/API/Account/{AccountId}/DisplayTemplate/Sale/{SaleId}.html?template=SaleReceipt&print=1&page_width=auto&page_height=2000mm

    Hope this helps!
  • scott74scott74 Posts: 35Member
    I think API throttling pertains to API call counts, not necessarily the amount of data being returned in the HTTP response. So if you make a single API call to just retrieve the base sale reccord, or if you make a single API call to retrieve the base sale record and a half-dozen relations, either scenario is just a single API call against your bucket count. Although the more relations you load (esp. those with custom fields and their corresponding values) will certain slow down the response time dramatically.

    And you can definitely pull sales by a specified date range. You provide that as a URL query parameter. See https://developers.lightspeedhq.com/retail/introduction/parameters/ for details. Here is specifics in terms of querying the Sale endpoint by date --> https://community.lightspeedhq.com/en/discussion/comment/5596#Comment_5596.

    And as an FYI to @jamesratcliffe and crew, there appears to be an impacting systems issue aside from degradation in the LS Retail web client. Even my API client was getting the following HTTP response back when testing out the timeStamp scenario listed above. Just a heads-up!

    {
        "httpCode": "500",
        "httpMessage": "Internal Server Error",
        "message": "An exception occured in driver: SQLSTATE[HY000] [1040] Too many connections",
        "errorClass": "DriverException"
    }

    And also getting this...

    <html>
        <head>
            <title>524 Origin Time-out</title>
        </head>
        <body bgcolor="white">
            <center>
                <h1>524 Origin Time-out</h1>
            </center>
            <hr>
            <center>cloudflare-nginx</center>
        </body>
    </html>
    Thanks Greg. I need the date to be dynamic so like I have my Request set to pull at 9pm each night when the store closes but just want todays date to run each day. Would  you have an example of how that timestamp= would look combined with the URL I am using now?

    Wish I could combine the Employee too instead of returning an ID , otherwise I have to run the Employee URL separate Note them, then swap out the name for the ID in each bundle. Little maintenance if they hire and fire new ones to have to redo all that instead of it just passing the contact info of the employee when you pull the sale but I think they said there is not way to do that.

    https://api.lightspeedapp.com/API/Account/{{Account_ID}}/Sale.json?load_relations=["Customer","Customer.Contact"]
  • gregaricangregarican Posts: 227Member 
    If you're talking about pulling LS Retail sales by timestamp, here's an example:

    https://api.merchantos.com/API/Account/{AccountID}/Sale.json?archived=false&load_relations=["SaleLines","SaleLines.Discount","SaleLines.Note","SaleLines.Item","SalePayments","SalePayments.PaymentType","SalePayments.SaleAccounts","Customer","Customer.Contact","Discount"]&offset=0&limit=100&timeStamp=><,2018-12-27T11:00:00-5:00,2018-12-27T12:00:00-5:00

    This is pulling all 12/27/2018 sales between 11 AM and 12 PM ET. You can reference the various query parameters and their syntax here --> https://developers.lightspeedhq.com/retail/introduction/parameters/

    One thing I would suggest if you are looking to perform a fair amount of reporting, data analysis, triggered dependencies, etc. is just doing a big daily dump to a local SQL resource. For example, pull all products, customers, employees, etc. created that day. Then if you wanted more real-time transactional details for sales, refunds, returns, transfers, etc. you could run those hourly based on timestamps. Once you have all of the data in a local SQL resource, you can perform all the table joins that are lacking in LS Retail API's load_relations. And the performance will be a lot quicker than relying on the API for everything.

    These daily data dumps might take awhile to complete, depending on the recordset sizes and whatnot. But once they are done you have the pot of data to slice and dice as you wish. We had to resort to that, and haven't regretted it!
  • scott74scott74 Posts: 35Member
    I think API throttling pertains to API call counts, not necessarily the amount of data being returned in the HTTP response. So if you make a single API call to just retrieve the base sale reccord, or if you make a single API call to retrieve the base sale record and a half-dozen relations, either scenario is just a single API call against your bucket count. Although the more relations you load (esp. those with custom fields and their corresponding values) will certain slow down the response time dramatically.

    And you can definitely pull sales by a specified date range. You provide that as a URL query parameter. See https://developers.lightspeedhq.com/retail/introduction/parameters/ for details. Here is specifics in terms of querying the Sale endpoint by date --> https://community.lightspeedhq.com/en/discussion/comment/5596#Comment_5596.

    And as an FYI to @jamesratcliffe and crew, there appears to be an impacting systems issue aside from degradation in the LS Retail web client. Even my API client was getting the following HTTP response back when testing out the timeStamp scenario listed above. Just a heads-up!

    {
        "httpCode": "500",
        "httpMessage": "Internal Server Error",
        "message": "An exception occured in driver: SQLSTATE[HY000] [1040] Too many connections",
        "errorClass": "DriverException"
    }

    And also getting this...

    <html>
        <head>
            <title>524 Origin Time-out</title>
        </head>
        <body bgcolor="white">
            <center>
                <h1>524 Origin Time-out</h1>
            </center>
            <hr>
            <center>cloudflare-nginx</center>
        </body>
    </html>
    Thanks Greg. I need the date to be dynamic so like I have my Request set to pull at 9pm each night when the store closes but just want todays date to run each day. Would  you have an example of how that timestamp= would look combined with the URL I am using now?


    https://api.lightspeedapp.com/API/Account/{{Account_ID}}/Sale.json?load_relations=["Customer","Customer.Contact"]
  • scott74scott74 Posts: 35Member
    I think API throttling pertains to API call counts, not necessarily the amount of data being returned in the HTTP response. So if you make a single API call to just retrieve the base sale reccord, or if you make a single API call to retrieve the base sale record and a half-dozen relations, either scenario is just a single API call against your bucket count. Although the more relations you load (esp. those with custom fields and their corresponding values) will certain slow down the response time dramatically.

    And you can definitely pull sales by a specified date range. You provide that as a URL query parameter. See https://developers.lightspeedhq.com/retail/introduction/parameters/ for details. Here is specifics in terms of querying the Sale endpoint by date --> https://community.lightspeedhq.com/en/discussion/comment/5596#Comment_5596.

    And as an FYI to @jamesratcliffe and crew, there appears to be an impacting systems issue aside from degradation in the LS Retail web client. Even my API client was getting the following HTTP response back when testing out the timeStamp scenario listed above. Just a heads-up!

    {
        "httpCode": "500",
        "httpMessage": "Internal Server Error",
        "message": "An exception occured in driver: SQLSTATE[HY000] [1040] Too many connections",
        "errorClass": "DriverException"
    }

    And also getting this...

    <html>
        <head>
            <title>524 Origin Time-out</title>
        </head>
        <body bgcolor="white">
            <center>
                <h1>524 Origin Time-out</h1>
            </center>
            <hr>
            <center>cloudflare-nginx</center>
        </body>
    </html>
    Thanks Greg. I need the date to be dynamic so like I have my Request set to pull at 9pm each night when the store closes but just want todays date to run each day. Would  you have an example of how that timestamp= would look combined with the URL I am using now?


    https://api.lightspeedapp.com/API/Account/{{Account_ID}}/Sale.json?load_relations=["Customer","Customer.Contact"]
  • scott74scott74 Posts: 35Member
    I think API throttling pertains to API call counts, not necessarily the amount of data being returned in the HTTP response. So if you make a single API call to just retrieve the base sale reccord, or if you make a single API call to retrieve the base sale record and a half-dozen relations, either scenario is just a single API call against your bucket count. Although the more relations you load (esp. those with custom fields and their corresponding values) will certain slow down the response time dramatically.

    And you can definitely pull sales by a specified date range. You provide that as a URL query parameter. See https://developers.lightspeedhq.com/retail/introduction/parameters/ for details. Here is specifics in terms of querying the Sale endpoint by date --> https://community.lightspeedhq.com/en/discussion/comment/5596#Comment_5596.

    And as an FYI to @jamesratcliffe and crew, there appears to be an impacting systems issue aside from degradation in the LS Retail web client. Even my API client was getting the following HTTP response back when testing out the timeStamp scenario listed above. Just a heads-up!

    {
        "httpCode": "500",
        "httpMessage": "Internal Server Error",
        "message": "An exception occured in driver: SQLSTATE[HY000] [1040] Too many connections",
        "errorClass": "DriverException"
    }

    And also getting this...

    <html>
        <head>
            <title>524 Origin Time-out</title>
        </head>
        <body bgcolor="white">
            <center>
                <h1>524 Origin Time-out</h1>
            </center>
            <hr>
            <center>cloudflare-nginx</center>
        </body>
    </html>
    Thanks Greg. I need the date to be dynamic so like I have my Request set to pull at 9pm each night when the store closes but just want todays date to run each day. Would  you have an example of how that timestamp= would look combined with the URL I am using now?


    https://api.lightspeedapp.com/API/Account/{{Account_ID}}/Sale.json?load_relations=["Customer","Customer.Contact"]
Sign In or Register to comment.