FyleSDK is a Python SDK for accessing Fyle APIs. It makes integration of Fyle very easy with Python Applications. It has a series of functions which can be used to access different APIs that we provide.
Here is a link to the GitHub repository:
Quickstart Tutorial -
Let’s see how FyleSDK can be used by creating a command-line application to export expenses into a CSV file.
Install FyleSDK using pip -
$ pip install fylesdk
Now create a new file quickstart.py and copy the following code -
Shows basic usage of fylesdk.
Exports details of up to 100 Expenses into a CSV.
from fylesdk import FyleSDK
""" Making a connection to our server with the credentials created on the web app. """
connection = FyleSDK(
base_url='<Your Base URL>',
client_id='<Your Client Id>',
client_secret='<Your Client Secret',
refresh_token='<Your Refresh Token>'
Making calls to different APIs in the pattern:
This will get up to 100 Expenses.
expenses = connection.Expenses.get(limit=100, offset=0)
""" Exporting the details to csv using DictWriter. """
with open('expenses_export.csv', 'w') as export_file:
keys = expenses['data'].keys()
dict_writer = csv.DictWriter(export_file, fieldnames=keys, delimiter=',')
Once you have copied and saved the code in a file named “quickstart.py”, run it by typing -
$ python quickstart.py
Your expenses will be exported to expenses_export.csv