No announcement yet.

Calling Advanced API with Javascript

  • Filter
  • Time
  • Show
Clear All
new posts

  • Calling Advanced API with Javascript

    Does anyone have a working sample of html/javascript making an SQL call via the advanced API? Mine doesn't seem to work.


  • #2
    Thats a bad idea no matter how you do it.

    Anyone that loads the client can read the javascript that comes with it. Your api key would then be accessible because you are trying to make the call from client side.

    Advanced api is DIRECT database manipulation. Someone could waltz right in and tear your store apart like its nothing. Your customers, products, sales, and everything else will be fully exposed.

    Do the smart thing and set up a REST service somewhere and make calls to that service through ajax (which then does the API calls from behind some security).


    • #3
      I fully agree.
      But I have two requirements: 1) allow resellers to automatically setup their own reseller code(promotion code) and 2) print periodic reports on sales by reseller.

      For my company - it's just me on a shoestring budget trying to get an ecommerce site setup and I don't want to maintain two web sites if I can help it.

      For 1) I agree API/javascript is not good. I've been discussing this with tech support and would like to write my own ASP page but tech support states no ASP pages allowed. So I'm stuck right now on that one other than second site.
      For 2) I can write a page where the URL is not obvious and only I will use it to generate periodic reports.

      So I'd still like to get an example of javascript/API that works. I've read that even though it's SOAP the server has to allow SOAP requests via javascript before it will work but I'm not certain that is my problem yet; thus, the post.


      • #4
        The SOAP service doesn't care what language is used to access it. You should probably stop thinking about javascript. If I were you I would set up a $5/month VPS on DigitalOcean and write some scripts in Python or PHP to make the API calls, and then hit those scripts as necessary via a simple web call.

        You could even do something for free using Google's Apps Script platform (which uses javascript, but running on the host), and copy the code from my API Spreadsheet to figure out how to call the API.


        • #5
          if you really like javascript, you can host node just as easily on a droplet in digital ocean. thats my server side language of choice. and yes, there is a module for soap and its super easy to use.

          your requirements can easily be met while doing the right thing at the same time. I apologize but I'm going to stick to my guns and say the client side idea shouldn't even be an option for you.

          This is as simple as one file hosted on a vps somewhere, not an entire site.

          1)allow resellers to automatically setup their own reseller code(promotion code)

          - set up a form using an extra page on your 3dcart site. However you want to make the form available the concept is the same. The code they choose can be sent via $.post() to your rest service and from there sent on to the 3dcart api. They provide callback hooks so you can get a return message going as well.

          2) print periodic reports on sales by reseller.

          - this sounds like a simple form as well. could put it directly on your vps or an extra page as well. select the reseller you want and init the request to your service. Return the results as a html response and set up a CSS sheet for print.

          mission accomplished and your store information has no risk for compromise from crawlers. Just because you don't think a human could figure out your url, doesn't mean your page won't get traffic.
          Last edited by jleclair; 12-31-2013, 11:26 AM.


          • #6
            Heroku is a free service you could try as well. We use it to run a/b testing software for our store and it works out great. It starts free, but you can upgrade it for a fee. I highly recommend it.

            JES Restaurant Equipment