Package: pyfleetio
Fleetio Python API WrapperTable of ContentsIntroductionInstallationFeaturesUsageGET Requests[Examples ofget()][Examples ofget(id, queryParams)]POST Requests[Examples ofcreate(body)]PATCH Requests[Examples ofupdate(id, body)]DELETE Requests[Examples ofdeleteOne(id)]ThrottlingResponsesFeedbackContributorsAcknowledgmentsIntroductionpyfleetioallows you to send HTTP requests extremely easily to the Fleetio APi. This library is mostly based on the Requests library.
Learn more about Fleetio's APIhere.Installationpip install pyfleetioFeaturesAn API key needs to be generated using the following procedurehere.Find your account specificToken.Provide those parameters to Fleetio class.UsageGET RequestsExample 1import os
from fleetio import Fleetio

api_key = os.environ.get('FLEETIO_API_KEY')
account_token = os.environ.get('FLEETIO_ACCOUNT_TOKEN')

f = Fleetio(api_key, account_token)
active_contacts = f.contacts.get()
all_contacts = f.contacts.get(queryParams={"include_archived":"1"})Example 2import os
from fleetio import Fleetio, NotFoundError

api_key = '123456'
account_token = 'ABC123'

f = Fleetio(api_key, account_token)
active_vehicles = f.vehicles.get()
all_vehicles =  f.vehicles.get(queryParams={"include_archived":"1"})

my_car_id = '911'
try:
    my_car = f.vehicles.get(id=my_car_id)
except NotFoundError:
    print('Car not in active cars!')POST RequestsExample 1import os
from fleetio import Fleetio

api_key = os.environ.get('FLEETIO_API_KEY')
account_token = os.environ.get('FLEETIO_ACCOUNT_TOKEN')

f = Fleetio(api_key, account_token)
best_car  = {
    'fuel_volume_units':'us_gallons',
    'meter_unit':'mi',
    'name':'Porsche 911',
    'ownership':'owned',
    'system_of_measurement':'imperial',
    'vehicle_type_id':'804609',
    'vehicle_status_id':'276263',
}

car_json = f.vehicles.create(body = best_car) # more fields are available https://developer.fleetio.com/docs/create-vehicleExample 2import os
from fleetio import Fleetio

api_key = os.environ.get('FLEETIO_API_KEY')
account_token = os.environ.get('FLEETIO_ACCOUNT_TOKEN')

car_id = '123456'
f.vehicles.archive(id=car_id)
#
f.vehicles.restore(id=car_id)PATCH RequestsExampleimport os
from fleetio import Fleetio

api_key = os.environ.get('FLEETIO_API_KEY')
account_token = os.environ.get('FLEETIO_ACCOUNT_TOKEN')

car_id = '123456'
f.vehicles.update(id=car_id, body = {'color':'Yellow', 'model':'Porsche'})DELETE RequestsExampleimport os
from fleetio import Fleetio

api_key = os.environ.get('FLEETIO_API_KEY')
account_token = os.environ.get('FLEETIO_ACCOUNT_TOKEN')

car_id = '123456'
f.vehicles.deleteOne(id=car_id)ThrottlingRate limiting is enforced by the API with a threshold of 20 requests per minute. Learn more about ithere. If more than 20 requests are sent within a minute, the requests go to sleep and wait as this ensures that every function invocation is successful at the cost of halting the thread.ResponsesActionEndpointHTTP VerbDescriptionResponse Data Typeget()/vehiclesGETReturns an array of all vehicles.Arraycreate/vehiclesPOSTCreates a new vehicle.No contentget(id)/vehicles/:idGETReturns the vehicle corresponding to the id parameter.Hashupdate(id)/vehicles/:idPATCHUpdates the vehicle corresponding to the id parameter.No contentdeleteOne(id)/vehicles/:idDELETEDeletes the vehicle corresponding to the id parameter.No contentFeedbackIf you have any questions, please reach out or by submitting an issuehere.
Feature requests are always welcome. If you wish to contribute, please take a quick look at theguidelines!AcknowledgmentsThis library was developed with the fundamentals adapted from this API WrapperpyonfleetNoteThis project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with Fleetio.com