What you need to be calling is the Reports and Dashboards Execute Sync endpoint.
You can call this endpoint in Python with simple_salesforce
like so:
import simple_salesforce
sf = simple_salesforce.Salesforce(username = ... )
report_id = '00O1R000007XXXXUAC' # However you're obtaining your Report Id
report_results = sf.restful('analytics/reports/{}'.format(report_id))
You'll get back a very complex result body, which is documented in the link above as well. The exact path to your detail lines will vary depending upon the structure of the report. If you're running a simple, non-grouped report, your rows will be in results['factMap']['T!T']['rows']
, and each row will have a 'dataCells'
key, whose value is a list of dicts with label
and value
pairs.
You can definitely digest that response body into CSV content, but it'll be a lot more straightforward if you're able to just run a SOQL query rather than executing the report.