# Try it out!

# API Console

The API Console offers a simple way to try the API directly.

(opens new window)

API Console

The console accepts API method calls using the same syntax as in this documentation.

Input the unique identifier of your webshop in the appropriate place in the Context parameters and then try the following.

    Unless an error occurred, you should be logged in. Now, try listing some articles in your shop.

      # Using API calls in an existing Textalk Webshop

      A JavaScript console offers a simple way to try the API directly within your shop. JavaScript console is available in, e.g., Chromium (opens new window) (using F12) or Firefox Developer Tools (opens new window).

      WARNING

      These examples work in older versions of our responsive themes and the Textalk Webshop Admin:

      • aficionado <= 1.7
      • fabrikk <= 1.3

      For newer themes see below In newer themes.

      Go to any page in your shop or Textalk Webshop Admin, start the console and try the following example.

      tws.api.call(
        "Article.list",
        [
          [
            "uid",
            "articleNumber",
            "articlegroup"
          ],
          {
            limit: 5
          }
        ],
        tws.debug
      );
      

      This will produce something like

      [
        {
          uid: 12565483,
          articleNumber: "4220",
          articlegroup: 1347891
        },
        {
          uid: 12565484,
          articleNumber: "4227",
          articlegroup: 1347891
        },
        {
          uid: 12565485,
          articleNumber: "4232",
          articlegroup: 1347891
        },
        {
          uid: 12565502,
          articleNumber: "4233",
          articlegroup: 1347897
        },
        {
          uid: 12565503,
          articleNumber: "4235",
          articlegroup: 1347897
        }
      ]
      

      This will normally show only things that available to a visitor of your shop. However, if you are logged in as a shop administrator and preview your shop, then you will have the authentication as a webshop administrator, available through an encrypted cookie, and could do something like this:

      tws.api.call("Order.getSchema", [ 30259825 ], tws.debug);
      

      INFO

      Use the unique identifier of an order from your own shop.

      This will return an object with the order's schema.

      With tws.api you can call any API method. The second argument in the parameters to the call and the third is the callback. tws.debug is a callback that will just display the gotten data in the console.

      # In newer themes

      WARNING

      These examples work in newer versions of our responsive themes:

      • aficionado > 1.7
      • fabrikk > 1.3
      • azalea >= 1.0
      • bountiful >= 1.0

      Go to any page in your shop, start the console and try the following example.

      twsCore.twapiFromState(store.getState())("Article.list")(
        [
          "uid",
          "articleNumber",
          "articlegroup"
        ],
        {
          limit: 5
        }
      ).then(function (result) {
        console.log(result);
      });