Skip to main content

Fleetio's Python API Wrapper Package

Project description

Fleetio Python API Wrapper

Table of Contents

Introduction

pyfleetio allows 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 API here.

Installation

pip install pyfleetio

Features

  • An API key needs to be generated using the following procedure here.
  • Find your account specific Token.
  • Provide those parameters to Fleetio class.

Usage

GET Requests

Example 1
import 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 2
import 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 Requests

Example 1
import 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-vehicle
Example 2
import 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 Requests

Example
import 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 Requests

Example
import 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)

Throttling

Rate limiting is enforced by the API with a threshold of 20 requests per minute. Learn more about it here. 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.

Responses

Action Endpoint HTTP Verb Description Response Data Type
get() /vehicles GET Returns an array of all vehicles. Array
create /vehicles POST Creates a new vehicle. No content
get(id) /vehicles/:id GET Returns the vehicle corresponding to the id parameter. Hash
update(id) /vehicles/:id PATCH Updates the vehicle corresponding to the id parameter. No content
deleteOne(id) /vehicles/:id DELETE Deletes the vehicle corresponding to the id parameter. No content

Feedback

If you have any questions, please reach out or by submitting an issue here. Feature requests are always welcome. If you wish to contribute, please take a quick look at the guidelines!

Acknowledgments

This library was developed with the fundamentals adapted from this API Wrapper pyonfleet

Note This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with Fleetio.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfleetio-1.0.2.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyfleetio-1.0.2-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file pyfleetio-1.0.2.tar.gz.

File metadata

  • Download URL: pyfleetio-1.0.2.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for pyfleetio-1.0.2.tar.gz
Algorithm Hash digest
SHA256 3e5c48651e1ca37245f80696d0f5d128c59dcf0b3af10b2ccbe825f183d46f87
MD5 9544eaf4e148f606f69061260533252c
BLAKE2b-256 c7db84bdea6907c10f81b822d76c6e32303c48ac380e19a0736cec1669100c22

See more details on using hashes here.

File details

Details for the file pyfleetio-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pyfleetio-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for pyfleetio-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8ad6a52d032cad6967d33574b57e046822ea151c1340451e512bc72e75b0fe10
MD5 5334b9a165704f477296f2bdb0bf60fc
BLAKE2b-256 8eb9bdca07c3e672749cde4c38a0578dfc145f0447ebbddc3c2a292b65adc250

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page