logo
  • Contents

Getting Started with API Lite

Last updated 26/01/2017

API Lite has been superseded by API v1 - this information is for legacy users only.

This section will help you get started using API Lite and give you a basic overview of how it works.

General Information


Date Format

All dates are UTC and use the format "yyyy-MM-dd HH:mm:ss". Example: 2013-01-31 08:30:00

GET url Format

https://api.cin7.com/cloud/APILite/APILite.ashx?apiid={apiid}&apikey={apikey}&action={action}&fields={feilds}&where={where}&orderby={orderby}

POST url format

https://api.cin7.com/cloud/APILite/APILite.ashx?apiid={apiid}&apikey={apikey}&action={action}

Parameters

All parameters should be url encoded.

Parameter Description
apiid Your api id
apikey Your api key
action Action name
fields Example: OrderDetailId,OrderId
where Example: OrderRef LIKE 'test%' AND Active=1 AND ( CreatedDate < DATETIME('2013-01-31 01:00:00') OR CreatedDate IS NULL )
orderby Comma separated list of fields to order the returned records
Sort Direction: By default,fields are sorted lowest to highest. To reverse append "DESC" to the end of the field
Example: OrderDetailId,DESC,OrderId

GET Example


    GET https://api.cin7.com/cloud/APILite/APILite.ashx?apiid=123&apikey=12345&action=GetOrderDetails&fields=OrderDetailId%2COrderId&where=OrderRef%3D'test'&orderby=OrderDetailId
    

POST Example


The csv data must go in the body of the post request. The below steps can be used to insert an order.

Insert a Member

POST https://api.cin7.com/cloud/APILite/APILite.ashx?apiid=123&apikey=12345&action=UpdateMembers

FirstName,LastName,Company,Email,Phone,UserType,Address,Suburb,City,PostalCode,Country
John,Smith,Smith Inc,john@somewhere.com,091234567,Customer,42 Somewhere St,Albany,Auckland,0632,New Zealand
    
    

Insert an order

POST https://api.cin7.com/cloud/APILite/APILite.ashx?apiid=123&apikey=12345&action=UpdateOrders

OrderRef,CreatedDate,Active,MemberEmail,CurrencyRate,CurrencyName,CurrencySymbol,TaxStatus,TaxRate
Ref123,2013-01-31 08:30:00,1,john@somewhere.com,1.0,NZD,$,Incl,0.15
    

Insert an order detail

POST https://api.cin7.com/cloud/APILite/APILite.ashx?apiid=123&apikey=12345&action=UpdateOrderDetails

OrderRef,OrderDetailImportedRef,Code,Qty,Discount
Ref123,Ref456,ShirtRed123,1.0,0.00

Insert a Payment

POST https://api.cin7.com/cloud/APILite/APILite.ashx?apiid=123&apikey=12345&action=UpdatePayments

OrderRef,PaymentImportedRef,Active,Method,Direction,Amount,Date,TransactionAuthorized,TransactionRef
Ref123,Ref456,1,Direct Credit,1,123.50,2013-09-16 1:00:00,1,ABC123456789
    

Javascript JQuery POST Example


    $(function () {

        var requestURL = "https://api.cin7.com/cloud/APILite/APILite.ashx?apiid=123&apikey=123456789&action=UpdateOrders";

        var csvData = "OrderRef,CreatedDate,Active,MemberEmail,CurrencyRate,CurrencyName,CurrencySymbol,TaxStatus,TaxRate\n" +
                      "Ref123,2013-01-31 08:30:00,1,john@somewhere.com,1.0,NZD,$,Incl,0.15";

        var request = $.ajax({
            url: requestURL,
            type: "POST",
            contentType: "text/plain",
            dataType: "text",
            data: csvData,
            processData: false,
            timeout: 2 * 60 * 1000,
            success: function (data) {
                console.log(data);
            },
            error: function (data) {
                console.log(data.responseText);
            }
        });

    });    

ASP.Net C# POST Example


using System;
using System.IO;
using System.Net;

public partial class Test_APILite : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string requestURL = "https://api.cin7.com/cloud/APILite/APILite.ashx?apiid=123&apikey=123456789&action=UpdateOrders";

        string csvData = "OrderRef,CreatedDate,Active,MemberEmail,CurrencyRate,CurrencyName,CurrencySymbol,TaxStatus,TaxRate\n" +
                         "Ref123,2013-01-31 08:30:00,1,john@somewhere.com,1.0,NZD,$,Incl,0.15";

        HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(requestURL);
        httpWebRequest.ContentType = "text/plain";
        httpWebRequest.Method = "POST";
        
        using (StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
        {
            streamWriter.Write(csvData);
            streamWriter.Flush();
            streamWriter.Close();
        }

        try
        {
            HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                Response.Write(streamReader.ReadToEnd());
            }
        }
        catch (WebException ex)
        {
            using (StreamReader streamReader = new StreamReader(ex.Response.GetResponseStream()))
            {
                Response.Write(streamReader.ReadToEnd());
            }
        }

        Response.End();
    } 
}