Forum Discussion

RaphaelB's avatar
RaphaelB
Lithium Alumni (Retired)
10 years ago

(Python) script for the Bulk Data API

Hi all

 

Does anyone have any experience with using Python Request to query the Bulk data API ?

 

On this page there is an example using cURL only. Ideally we would need a script for Python Request, or more info on how to pass the user-id and token.

 

Thanks in advance !

2 Replies

  • Did you ever figure out how to add the user and password to the provided python example scripts?

    Thanks,

    Dan

  • Hi RaphaelB,

     

    Here is the code that i've used. The sample given is not working with me. just change to your url , client id and token

     

     

    import requests
    
    startdate = '20180810'
    enddate = '20180815'
    headers = { 'client-id': 'your client id', }
    params = (('fromDate', startdate),('toDate', enddate),)
    response = requests.get('https://api.lithium.com/lsi-data/v1/data/export/community/your url', headers=headers, params=params, auth=('token', ''))
    open('LSIBulkData'+startdate+'-'+enddate+'.csv', 'wb').write(response.content)