Cmdlets for ShipStation

Build 24.0.9060

Establishing a Connection

With the CData Cmdlets users can install a data module, set the connection properties, and start scripting. This section provides examples of using our ShipStation Cmdlets with native PowerShell cmdlets, like the CSV import and export cmdlets.

Installing and Connecting

If you have PSGet, installing the cmdlets can be accomplished from the PowerShell Gallery with the following command. You can also obtain a setup from the CData site.

Install-Module ShipStationCmdlets

The following line is then added to your profile, loading the cmdlets on the next session:

Import-Module ShipStationCmdlets;

You can then use the Connect-ShipStation cmdlet to create a connection object that can be passed to other cmdlets:

$conn = Connect-ShipStation -APIKey "YourAPIKey" -APISecret "YourAPISecret"

Use the BASIC Authentication standard to connect to ShipStation.

Connecting to ShipStation

  1. Login to your ShipStation account: ShipStation Login.
  2. Click on the settings icon in the upper right corner. A column menu will show up on the left.
  3. Click Account -> API Settings.
  4. On the API Settings page, note the API Key and API Secret.

Authenticating to ShipStation

  • APIKey: Set this to the API key from the API settings page.
  • APISecret: Set this to the Secret key from the API settings page.

Retrieving Data

The Select-ShipStation cmdlet provides a native PowerShell interface for retrieving data:

$results = Select-ShipStation -Connection $conn -Table "Tags" -Columns @("Id, Color") -Where "CustomerId='1368175'"
The Invoke-ShipStation cmdlet provides an SQL interface. This cmdlet can be used to execute an SQL query via the Query parameter.

Piping Cmdlet Output

The cmdlets return row objects to the pipeline one row at a time. The following line exports results to a CSV file:

Select-ShipStation -Connection $conn -Table Tags -Where "CustomerId = '1368175'" | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myTagsData.csv -NoTypeInformation

You will notice that we piped the results from Select-ShipStation into a Select-Object cmdlet and excluded some properties before piping them into an Export-CSV cmdlet. We do this because the CData Cmdlets append Connection, Table, and Columns information onto each row object in the result set, and we do not necessarily want that information in our CSV file.

However, this makes it easy to pipe the output of one cmdlet to another. The following is an example of converting a result set to JSON:

 
PS C:\> $conn  = Connect-ShipStation -APIKey "YourAPIKey" -APISecret "YourAPISecret"
PS C:\> $row = Select-ShipStation -Connection $conn -Table "Tags" -Columns (Id, Color) -Where "CustomerId = '1368175'" | select -first 1
PS C:\> $row | ConvertTo-Json
{
  "Connection":  {

  },
  "Table":  "Tags",
  "Columns":  [

  ],
  "Id":  "MyId",
  "Color":  "MyColor"
} 

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9060