Python Examples
File: partner_org_report.py
Utilities for the PartnerTap Analytics API — export matched accounts to CSV and discover available report columns.
Prerequisites
Section titled “Prerequisites”Generate an API key in PartnerTap: Admin Center > Data > API Keys.
1. Install dependencies
Section titled “1. Install dependencies”pip3 install -r requirements.txt2. Set your API key
Section titled “2. Set your API key”export PARTNERTAP_API_KEY="<your api key>"3. (Optional) Custom base URL
Section titled “3. (Optional) Custom base URL”By default the script targets the production API (https://reports.partnertap.com). To point at a different environment, pass --base-url before the subcommand:
python partner_org_report.py --base-url https://test-reports.partnertap.com export "Example Pharma Inc."Export Matched Accounts
Section titled “Export Matched Accounts”Exports the list of accounts you share with a given partner org to CSV, filtered to rows where account country matches partner country (normalized via country_converter).
Customize exported columns
Section titled “Customize exported columns”Before running an export, open partner_org_report.py and edit the two column lists to include the columns you want in your CSV. The columns are split into two variables because the API returns them in different places in the response:
EXPORT_STANDARD_COLUMNS— Your own account fields, read from the top level of each record.EXPORT_PARTNER_COLUMNS— Partner-shared fields, read from the nestedpartnerFieldsobject in each record.
The defaults are:
EXPORT_STANDARD_COLUMNS = ["accountName", "crmAccountId"]EXPORT_PARTNER_COLUMNS = ["partnerAccountName", "partnerAccountId"]Use the columns command (described below) to discover available column keys for your partner. Columns where the “Partner?” indicator is Yes belong in EXPORT_PARTNER_COLUMNS; all others belong in EXPORT_STANDARD_COLUMNS. For example:
EXPORT_STANDARD_COLUMNS = ["accountName", "crmAccountId", "country"]EXPORT_PARTNER_COLUMNS = ["partnerAccountName", "partnerAccountId", "partnerCountry"]Both lists are combined in order to produce the CSV header and rows.
Run the export
Section titled “Run the export”python partner_org_report.py export "Example Pharma Inc."Optional output path:
python partner_org_report.py export "Example Pharma Inc." -o example-pharma.csvList Available Columns
Section titled “List Available Columns”Retrieve and display the columns available on a Partner Org Matched Accounts report. Columns are grouped into three categories:
- Standard — Built-in fields (e.g., Account Name, City, Country).
- Custom — Fields imported from your CRM (
CUSTOM_CRM_FIELD/CUSTOM_CRM_OBJECT). - Partner Shared — Fields shared by the partner organization.
Show all columns
Section titled “Show all columns”python partner_org_report.py columns "Example Pharma Inc."Show only standard columns
Section titled “Show only standard columns”python partner_org_report.py columns "Example Pharma Inc." --type standardShow only your custom CRM columns
Section titled “Show only your custom CRM columns”python partner_org_report.py columns "Example Pharma Inc." --type customShow only partner shared columns
Section titled “Show only partner shared columns”python partner_org_report.py columns "Example Pharma Inc." --type partnerShow each category in its own section
Section titled “Show each category in its own section”python partner_org_report.py columns "Example Pharma Inc." --type all-separateSource Code
Section titled “Source Code”The full source code is available in the repository at examples/python/.