Get data from Salesforce reports with python

python, salesforce, com
pip install salesforce-reporting==0.1.2


Salesforce Reporting

Build Status

Get data straight from your Salesforce reports via python using the Analytics API.


Install via pip - pip install salesforce-reporting


Connect to the Salesforce Analytics API using password authentication:

from salesforce_reporting import Connection

sf = Connection(username='your_username', password='your_password', security_token='your_token')

Get records from a report

Use the Connection.get_report() method to request report data and then use ReportParser to access all the records included in a report (in list format if you use the ReportParser.records() method):

from salesforce_reporting import Connection, ReportParser

sf = Connection(username='your_username', password='your_password', security_token='your_token')
report = sf.get_report('report_id', includeDetails=True)
parser = salesforce_reporting.ReportParser(report)


The ReportParser.records_dict() method can also be used to return records in the form of a list of dicts in {field: value, field: value} format.

Extract series from matrix report

For a matrix report you can return the values in a column grouping by using MatrixParser.series_down() which takes the column name as an argument. For example, given a matrix report grouped by Calendar Month:

report = my_sf.get_report('report_id')
matrix_parser = salesforce_reporting.MatrixParser(report)

matrix_parser.series_down('Jan 2016')

This will return all values for 'Jan 2016' as values in a dictionary with the row groupings as keys.

Similarly you can use MatrixParser.series_across() to get the values in a particular row.

Coming Soon

  • Access to Dashboards

Author & License

MIT License. Created by Chris Hall.