Ready to get started?

Download a free trial of the eBay Analytics Data Provider to get started:

 Download Now

Learn more:

eBay Analytics Icon eBay Analytics ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with eBay Analytics.

Automate eBay Analytics Integration Tasks from PowerShell



Are you in search of a quick and easy way to access eBay Analytics data from PowerShell? This article demonstrates how to utilize the eBay Analytics Cmdlets for tasks like connecting to eBay Analytics data, automating operations, downloading data, and more.

The CData Cmdlets for eBay Analytics are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to eBay Analytics.

PowerShell Cmdlets or ADO.NET Provider?

The Cmdlets are not only a PowerShell interface to eBay Analytics, but also an SQL interface; this tutorial shows how to use both to retrieve eBay Analytics data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for eBay Analytics. To access eBay Analytics data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for eBay Analytics.

Once you have acquired the necessary connection properties, accessing eBay Analytics data in PowerShell can be enabled in three steps.

You can authenticate to eBay Analytics only via the OAuth 2 authentication method. The eBay Analytics API requires an access token created with the authorization code grant flow to authorize the requests.

You can follow the guide in the Help documentation for a step by step guide on how to authenticate using the OAuth 2 protocol.

PowerShell

  1. Install the module:

    Install-Module EbayAnalyticsCmdlets
  2. Connect:

    $ebayanalytics = Connect-EbayAnalytics -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -RuName "$RuName"
  3. Search for and retrieve data:

    $listingid = "201284405428" $trafficreportbylisting = Select-EbayAnalytics -Connection $ebayanalytics -Table "TrafficReportByListing" -Where "ListingId = `'$ListingId`'" $trafficreportbylisting

    You can also use the Invoke-EbayAnalytics cmdlet to execute SQL commands:

    $trafficreportbylisting = Invoke-EbayAnalytics -Connection $ebayanalytics -Query 'SELECT * FROM TrafficReportByListing WHERE ListingId = @ListingId' -Params @{'@ListingId'='201284405428'}

ADO.NET

  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for eBay Analytics\lib\System.Data.CData.EbayAnalytics.dll")
  2. Connect to eBay Analytics:

    $conn= New-Object System.Data.CData.EbayAnalytics.EbayAnalyticsConnection("OAuthClientId=MyAppID;OAuthClientSecret=MyCertID;RuName=MyRuName;InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the EbayAnalyticsDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT ListingName, ClickThroughRate from TrafficReportByListing" $da= New-Object System.Data.CData.EbayAnalytics.EbayAnalyticsDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.listingname $_.clickthroughrate }