OrderService.GetOrderList

Code samples provided here are generated by our clients and their developers. ChannelAdvisor cannot provide code for API development purposes.

Our documentation is meant to be the final format to be delivered to our API.

If you want to see other developer's code to execute calls, make a request of them on the ChannelAdvisor Google Forum.

C#

This example only retrieves shipped orders for a specific date range.

private void button1_Click(object sender, EventArgs e)
{
  WindowsApplication13.OrderRetriever getOrders = new OrderRetriever();
  List<string> genString = getOrders.GetSkuList();
  MessageBox.Show(genString.Count.ToString());
}

Visual Studio.Net

using System;
using System.Collections.Generic;
using System.Text;

namespace WindowsApplication13
{
  public class OrderRetriever
  {
    public List<string> GetSkuList()
    {
      //
      // 1. For this sample to work you will need create a web reference in
      // your VS.Net project by pointing to this URL:
      // https://api.channeladvisor.com/ChannelAdvisorAPI/v6/InventoryService.asmx?wsdl
      // Accept the default reference name of com.channeladvisor.api.OrderService
      //
      // 2. You will most likely need to change the namespace above (WindowsApplication13) to match
      // your projects default namespace so that it can see the web reference.
      // 3. Update the code to use your DeveloperKey, password, and AccountKey.

      const string developerApiGuid = "MyDeveloperKey";
      const string password = "myPassword";
      const string sellerAccountGuid = "MyAccountKey";
      com.channeladvisor.api.OrderService orderService = new com.channeladvisor.api.OrderService();
      com.channeladvisor.api.APICredentials apiCredentials = new com.channeladvisor.api.APICredentials();
      apiCredentials.DeveloperKey = developerApiGuid;
      apiCredentials.Password = password;
      orderService.APICredentialsValue = apiCredentials;

      com.channeladvisor.api.OrderCriteria orderCriteria = new com.channeladvisor.api.OrderCriteria();
      // Only grab items that are marked has Shipped
      orderCriteria.ShippingStatusFilter = "Shipped";
      //Only grab orders created from Mar 17, 2013 to Mar 18, 2013
      orderCriteria.OrderCreationFilterBeginTimeGMT = new System.DateTime(2013, 3, 17);
      orderCriteria.OrderCreationFilterEndTimeGMT = new DateTime(2013, 3, 18);
      // Set other properties required by call
      orderCriteria.DetailLevel = "High";
      orderCriteria.PageSize = 50; // Show 50 orders per page
      orderCriteria.PageNumberFilter = 0;

      List<string> skuList = new List<string>();
      bool moreResults = true;

      // Call the API several times to retrieve a list of all matches
      while (moreResults)
      {
        orderCriteria.PageNumberFilter += 1; // Get the next page each time through the loop
        com.channeladvisor.api.APIResultOfArrayOfOrderResponseItem orderResponse = orderService.GetOrderList(sellerAccountGuid, orderCriteria);
        if (orderResponse.Status == com.channeladvisor.api.ResultStatus.Success)
        {
          com.channeladvisor.api.OrderResponseItem[] orderResponseList = orderResponse.ResultData;
          if (orderResponseList.Length == 0 || orderResponseList.Length < orderCriteria.PageSize)
          {
            moreResults = false;
          }
          //step through each order in our returned array
          foreach (com.channeladvisor.api.OrderResponseDetailHigh order in orderResponseList)
          {
            System.Diagnostics.Debug.WriteLine("OrderID = " + order.OrderID.ToString());
            //step through each item in this Order
            foreach (com.channeladvisor.api.OrderLineItemItem invoiceLine in order.ShoppingCart.LineItemSKUList)
            {
              System.Diagnostics.Debug.WriteLine("LineItemID = " + invoiceLine.LineItemID.ToString());
              // Grab a list of all SKUs from invoices on this page
              skuList.Add(invoiceLine.SKU);
            }

            //step through each Promo.
            foreach (com.channeladvisor.api.OrderLineItemPromo promo in order.ShoppingCart.LineItemPromoList)
            {
              System.Diagnostics.Debug.WriteLine(string.Format("Promo code of {0} had a value of {1}", promo.PromoCode, promo.UnitPrice));
            }

            //step through each ItemInvoice in this Order.  These are subtotal categories
            foreach (com.channeladvisor.api.OrderLineItemInvoice line in order.ShoppingCart.LineItemInvoiceList)
            {
              if (line.LineItemType == "Shipping")
              {
                System.Diagnostics.Debug.WriteLine(string.Format("Shipping charge of {0}",line.UnitPrice));
              }
              else if (line.LineItemType == "VATShipping")
              {
                System.Diagnostics.Debug.WriteLine(string.Format("VAT Shipping charge of {0}", line.UnitPrice));
              }
              else if (line.LineItemType == "SalesTax")
              {
                System.Diagnostics.Debug.WriteLine(string.Format("Sales Tax charge of {0}", line.UnitPrice));
              }
              else if (line.LineItemType == "ShippingInsurance")
              {
                System.Diagnostics.Debug.WriteLine(string.Format("Shipping Insurance charge of {0}", line.UnitPrice));
              }
              else
              {
                System.Diagnostics.Debug.WriteLine("Unexpected line type of " + line.LineItemType);
              }
            }
          }
        }
        else
        {
          int errorCode = orderResponse.MessageCode;
          string errorMessage = orderResponse.Message;
          System.Diagnostics.Debug.WriteLine(string.Format("An unexpected error occured. ErrorCode={0}, ErrorMessage={1}", errorCode, errorMessage));
        }
      }
      return skuList;
    }
  }
}

Python

from suds.client import Client
import logging
 
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
 
# Specify Login Information
developer_key = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
password = 'xxxxxxxx'
account_guid = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
 
# Specify URLs
wsdl_url = 'https://api.channeladvisor.com/ChannelAdvisorAPI/v6/OrderService.asmx?WSDL'
service_url = 'https://api.channeladvisor.com/ChannelAdvisorAPI/v6/OrderService.asmx'
 
# Initialize client.
client = Client(wsdl_url, location = service_url)
 
login = client.factory.create('APICredentials')
login.DeveloperKey = developer_key
login.Password = password
client.set_options(soapheaders=login)
 
# Instantiate our GetOrderList Object
getOrderList = client.factory.create('GetOrderList')
getOrderList.orderCriteria.OrderCreationFilterBeginTimeGMT = '2000-01-01T00:00:00'
getOrderList.orderCriteria.OrderCreationFilterEndTimeGMT = '2012-09-05T00:00:00'
getOrderList.orderCriteria.StatusUpdateFilterBeginTimeGMT = None
getOrderList.orderCriteria.StatusUpdateFilterEndTimeGMT = None
getOrderList.orderCriteria.JoinDateFiltersWithOr = None
getOrderList.orderCriteria.DetailLevel = 'High'
getOrderList.orderCriteria.ExportState = None
getOrderList.orderCriteria.OrderIDList = None
getOrderList.orderCriteria.ClientOrderIdentifierList = None
getOrderList.orderCriteria.OrderStateFilter = 'Active'
getOrderList.orderCriteria.PaymentStatusFilter = 'Cleared'
getOrderList.orderCriteria.CheckoutStatusFilter = 'Completed'
getOrderList.orderCriteria.ShippingStatusFilter = 'Unshipped'
getOrderList.orderCriteria.RefundStatusFilter = None
getOrderList.orderCriteria.DistributionCenterCode = None
getOrderList.orderCriteria.PageSize = 20
getOrderList.orderCriteria.PageNumberFilter = 1
 
continueRequests = True
while continueRequests is True:
    print 'Page', getOrderList.orderCriteria.PageNumberFilter
    result = client.service.GetOrderList(account_guid, getOrderList.orderCriteria)
 
    ordersInResult = len(result.ResultData.OrderResponseItem)
    print '    Orders In Page:', ordersInResult
 
    for order in result.ResultData.OrderResponseItem:
        print '        ', order.OrderID

    if ordersInResult < 20:
        continueRequests = False
    else:
        getOrderList.orderCriteria.PageNumberFilter += 1

XML

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:tns="http://api.channeladvisor.com/webservices/" xmlns:ns0="http://api.channeladvisor.com/webservices/" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://api.channeladvisor.com/datacontracts/orders" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header>
      <tns:APICredentials>
         <tns:DeveloperKey>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</tns:DeveloperKey>
         <tns:Password>xxxxxxxx</tns:Password>
      </tns:APICredentials>
   </SOAP-ENV:Header>
   <ns1:Body>
      <ns0:GetOrderList>
         <ns0:accountID>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</ns0:accountID>
         <ns0:orderCriteria>
            <ns2:OrderCreationFilterBeginTimeGMT>2000-01-01T00:00:00</ns2:OrderCreationFilterBeginTimeGMT>
            <ns2:OrderCreationFilterEndTimeGMT>2012-09-05T00:00:00</ns2:OrderCreationFilterEndTimeGMT>
            <ns2:StatusUpdateFilterBeginTimeGMT xsi:nil="true"/>
            <ns2:StatusUpdateFilterEndTimeGMT xsi:nil="true"/>
            <ns2:JoinDateFiltersWithOr xsi:nil="true"/>
            <ns2:DetailLevel>High</ns2:DetailLevel>
            <ns2:OrderStateFilter>Active</ns2:OrderStateFilter>
            <ns2:PaymentStatusFilter>Cleared</ns2:PaymentStatusFilter>
            <ns2:CheckoutStatusFilter>Completed</ns2:CheckoutStatusFilter>
            <ns2:ShippingStatusFilter>Unshipped</ns2:ShippingStatusFilter>
            <ns2:PageNumberFilter>1</ns2:PageNumberFilter>
            <ns2:PageSize>20</ns2:PageSize>
         </ns0:orderCriteria>
      </ns0:GetOrderList>
   </ns1:Body>
</SOAP-ENV:Envelope>