Work with USPS Data in MS Excel on Mac OS X

Ready to get started?

Download for a free trial:

Download Now

Learn more:


The USPS ODBC Driver is a powerful tool that allows you to connect with live data from USPS, directly from any applications that support ODBC connectivity.

Access USPS data like you would a database - read, write, and update USPS Packages, Shipments, Recipients, etc. through a standard ODBC Driver interface.

Create a Data Source Name in iODBC with the CData ODBC Driver for USPS and work with USPS data in Microsoft Excel on Mac OS X.

Microsoft Excel features calculations, graphing tools, pivot tables, and a macro programming language that allows users to work with data in many of the ways that suit their needs, whether on a Windows machine or a Macintosh machine. This article walks through creating a DSN for USPS data in iODBC and accessing USPS data in Microsoft Excel, all on a machine running Mac OS X.

Installing the CData ODBC Drivers on Mac OS X

The CData ODBC Driver for USPS is preconfigured for the iODBC driver manager, as are many other products like Microsoft Excel. This makes the driver easy to use with these tools.

Licensing the Driver

In a terminal run the following commands to license the driver. To activate a trial license, omit the key input.

cd "/Applications/CData ODBC Driver for USPS/bin"
sudo ./install-license <key>

Defining a DSN for iODBC with odbc.ini

You can define ODBC data sources in sections in the odbc.ini file. User data sources can only be accessed by the user account whose home folder the odbc.ini is located in. System data sources can be accessed by all users. You can find the correct odbc.ini in the following paths:

Privileges  Path

Modifying iODBC's system-wide settings requires elevated permissions; to do so, you can use following to open a text editor from the terminal:

sudo nano /Library/ODBC/odbc.ini

To authenticate with USPS, set the following connection properties.

  • PostageProvider: The postage provider to use to process requests. Available options are ENDICIA and STAMPS. If unspecified, this property will default to ENDICIA.
  • UseSandbox: This controls whether live or test requests are sent to the production or sandbox servers. If set to true, the Password, AccountNumber, and StampsUserId properties are ignored.
  • StampsUserId: This value is used for logging into authentication to the Stamps servers. This value is not applicable for Endicia and is optional if UseSandbox is true.
  • Password: This value is used for logging into Endicia and Stamps servers. If the postage provider is Endicia, this will be the pass phrase associated with your postage account. It is optional if UseSandbox is true.
  • AccountNumber: The shipper's account number. It is optional if UseSandbox is true.
  • PrintLabelLocation: This property is required to use the GenerateLabels or GenerateReturnLabels stored procedures. This should be set to the folder location where generated labels should be stored.

The Cache Database

Many of the useful task available from USPS require a lot of data. To ensure this data is easy to input and recall later, utilize a cache database to make requests. Set the cache connection properties in order to use the cache:

  • CacheLocation: The path to the cache location, for which a connection will be configured with the default cache provider. For example, C:\users\username\documents\uspscache

As an alternative to CacheLocation, set the combination of CacheConnection and CacheProvider to configure a cache connection using a provider separate from the default.

When you configure the DSN, you may also want to set the Max Rows connection property. This will limit the number of rows returned, which is especially helpful for improving performance when designing reports and visualizations.

In addition to the connection properties required to connect to USPS, the Driver property specifies either a driver definition in the odbcinst.ini file or the path to the driver library. Place your connection properties at the beginning of odbc.ini:

[CData USPS Sources]
Driver = CData ODBC Driver for USPS
PostageProvider = ENDICIA
 RequestId = 12345
 Password = 'abcdefghijklmnopqr'
 AccountNumber = '12A3B4C'

If you wish to authenticate using OAuth, you will need to add an additional connection property to ensure that the OAuth flow can execute properly:

Other = CheckPromptMode=False

Additionally, in the ODBC Data Sources section, the DSN must be set to a driver defined in the odbcinst.ini file. For example, below is the entry for the DSN created during the driver install:

[ODBC Data Sources]
CData USPS Source = CData ODBC Driver for USPS

Registering a DSN for iODBC with odbcinst.ini

You may need to modify the installed driver definition if you change the path to the driver library. To register an ODBC driver, modify the odbcinst.ini file. With iODBC, drivers can be available to only one user account or drivers can be available system wide. You can find the correct odbcinst.ini in the following paths:

Privileges  Path

Drivers are defined in sections in the odbcinst.ini file. The section name specifies the name of the driver. In this section, the Driver property specifies the path to the driver library. The driver library is the .dylib file located in the lib subfolder of the installation directory, by default in /Applications/CData ODBC Driver for USPS.

[CData ODBC Driver for USPS]
Driver = /Applications/CData ODBC Driver for CData/lib/libusps.odbc.dylib

The ODBC Drivers section must also contain a property with the driver name, set to "Installed".

[ODBC Drivers]
CData ODBC Driver for USPS = Installed

Testing the Connection

You can test your connection using the iODBC administrator.

  1. Open a terminal and enter the following command to start the iODBC Administrator with the necessary permissions:
    sudo /Applications/iODBC/iODBC\\ Administrator64
  2. On the Users tab, select CData USPS Source.
  3. Click the Test button.

Accessing USPS Data from Microsoft Excel

You can use the DSN configured above to access USPS data from Microsoft Excel.

  1. Open Microsoft Excel and open a spreadsheet (new or existing).
  2. Navigate to the data ribbon and select New Database Query From Database
  3. Select the User or System DSN that you previously configured and click OK.
  4. Build your SQL query in the Microsoft Query wizard:
  5. Click Return Data to execute the query and pull data into Excel.

Using the CData ODBC Driver for USPS, you can easily pull your USPS data directly into Excel. Once there, you can leverage all of the powerful features native to Excel to analyze, report, transform your USPS data, and more!