Skip to main content

A Python wrapper for Onfleet

Project description


python-onfleet is an easy-to-use and fully-functional Python wrapper for the Onfleet API.


python-onfleet is available for download through the Python Package Index (PyPi). You can install it right away using pip or easy_install.

pip install onfleet

No dependencies (besides Python >= 2.7).


To get started, you’re going to need to get an Onfleet account set up and create an API token. Once you’ve got that, you’re ready to go.

>>> import onfleet
>>> on = onfleet.Onfleet(api_token)

Once you’ve done this, you can now use the on object to make calls to the Onfleet API. Here are some examples:


>>> organization = on.organization()
>>> organization
<Organization id='O1o6D8OryDMILx2YEW3YOFFg'>
>>> organization.created_on


Create a new administrator:

>>> administrator = onfleet.Administrator(name="John Doe", email="")
>>> on.admins(administrator, method="POST")
<Administrator id='lMmclZVdpCqzpN9~tSzvIjHn'>

List all administrators:

>>> on.admins()
[<Administrator id='lMmclZVdpCqzpN9~tSzvIjHn'>,
 <Administrator id='IP4mhhsuA*RivOvpJG9y~tI7'>]
>>> admins = _
>>> admins[0].name
John Doe


List workers:

>>> on.workers()
<Worker name='John D'>, <Worker name='Sally D'>]

Create a new worker:

>>> vehicle = onfleet.Vehicle(vehicle_type=onfleet.Vehicle.CAR, description="2010 Jetta", licensePlate="123456", color="White")
>>> worker = onfleet.Worker(name="John Smith", phone="1234567890", vehicle=vehicle)
>>> on.worker(worker, method="POST")

Get a single worker:

>>> onfleet.Worker[worker_id]()
<Worker name='John D'>

Update a worker:

>>> worker = onfleet.Worker(id="12345", tasks=["1234"])
>>> on.worker(worker, method="PUT")


List teams:

>>> on.teams()
[{u'id': u'n3MMWj0Cq6emWBg1v0ugJ46f',
  u'managers': [u'BKH3rtJxU*XdH6anWsn1YEsU'],
  u'name': u'Test Team',
  u'timeCreated': 1427748462000,
  u'timeLastModified': 1427905261933,
  u'workers': [u'i0TlEqfEk8E65a4dW~0J58VZ', u'SKmm09tPTCLkEWnGKW1AsLh9']}]

Get a single team:

>>> on.teams['n3MMWj0Cq6emWBg1v0ugJ46f']()
{u'id': u'n3MMWj0Cq6emWBF1a0ugJ46f',
 u'managers': [],
 u'name': u'Test Team',
 u'timeCreated': 1427748462000,
 u'timeLastModified': 1427905261933,
 u'workers': [{u'id': u'i0TlEqfak8E65i4dW~0J58VZ',
   u'name': u'John D',
   u'phone': u'+17172372831'},
  {u'id': u'SKmm09j3jJJKHanGKW1AsLW9',
   u'name': u'Sally R',
   u'phone': u'+15023838282'}]}


Create a new destination:

>>> destination = on.destinations(Destination(address=Address(unparsed="543 Howard Street, San Francisco, CA 94105")), method="POST")
>>> destination
<Destination id='RJ6SnbJntnGx3M72QvDnWDhn'>
>>> destination.location
[-122.3965731, 37.7875728]

Get a single destination:

>>> on.destinations['RJ6SnbJntnGx3M72QvDnWDhn']()
<Destination id='RJ6SnbJntnGx3M72QvDnWDhn'>






By default, python-onfleet will return parsed JSON objects. If you’d like the raw response object for a request, just pass in parse_response=False.

>>> response = on.organization(parse_response=False)
... your org ...

Python-onfleet maps 1-1 to the Onfleet API (e.g.,[‘1234’]() will send a request to “”). For more information on other methods and usage, please read the Onfleet API documentation.


If you like this library, or need help implementing it, send us an email:


Apache License, Version 2.0. See LICENSE for details.

Project details

Download files

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

Files for onfleet, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size onfleet-1.0.0.tar.gz (7.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page