Module Index¶
Quick Start¶
Quick start guide
Install¶
Probably, the best and simplest way — use PIP:
$ pip install route4me-sdk
See also
The full installation guide: Installation guide
Use¶
from route4me import Route4Me
from route4me.constants import ALGORITHM_TYPE, DISTANCE_UNIT, TRAVEL_MODE, OPTIMIZE
API_KEY = "11111111111111111111111111111111"
r4m = Route4Me(API_KEY)
optimization = r4m.optimization
address = r4m.address
optimization.algorithm_type(ALGORITHM_TYPE.TSP)
optimization.share_route(0)
optimization.store_route(0)
optimization.route_time(7 * 600)
optimization.rt(True)
optimization.route_max_duration(86400)
optimization.route_name('Single Driver Round Trip')
optimization.optimize(OPTIMIZE.TIME)
optimization.distance_unit(DISTANCE_UNIT.MI)
optimization.travel_mode(TRAVEL_MODE.DRIVING)
address.add_address(
address='754 5th Ave New York, NY 10019',
lat=40.7636197,
lng=-73.9744388,
alias='Bergdorf Goodman',
is_depot=True,
time=0
)
address.add_address(
address='717 5th Ave New York, NY 10022',
lat=40.7669692,
lng=-73.9693864,
alias='Giorgio Armani',
time=60
)
address.add_address(
address='888 Madison Ave New York, NY 10014',
lat=40.7715154,
lng=-73.9669241,
alias='Ralph Lauren Women\'s and Home',
time=60
)
address.add_address(
address='1011 Madison Ave New York, NY 10075',
lat=40.7772129,
lng=-73.9669,
alias='Yigal Azrou\u00ebl',
time=60
)
address.add_address(
address='440 Columbus Ave New York, NY 10024',
lat=40.7808364,
lng=-73.9732729,
alias='Frank Stella Clothier',
time=60
)
address.add_address(
address='324 Columbus Ave #1 New York, NY 10023',
lat=40.7803123,
lng=-73.9793079,
alias='Liana',
time=60
)
address.add_address(
address='110 W End Ave New York, NY 10023',
lat=40.7753077,
lng=-73.9861529,
alias='Toga Bike Shop',
time=60
)
address.add_address(
address='555 W 57th St New York, NY 10019',
lat=40.7718005,
lng=-73.9897716,
alias='BMW of Manhattan',
time=60
)
address.add_address(
address='57 W 57th St New York, NY 10019',
lat=40.7558695,
lng=-73.9862019,
alias='Verizon Wireless',
time=60
)
response = r4m.run_optimization()
print("Optimization Problem ID: {}".format(response.get("optimization_problem_id")))
for a in response.get("addresses", []):
print('{} - {} - {}'.format(a.get("sequence_no"), a.get("alias"), a.get("address")))
Installation guide¶
There are several ways to install Route4Me Python SDK.
PyPI¶
To install Route4Me Python SDK run this command in your terminal:
$ pip install route4me-sdk
If you don’t have pip
installed you can use this
guide to install pip.
Source Code¶
The source code of Route4Me Python SDK is open, public and live on GitHub: https://github.com/route4me/route4me-python-sdk.
You can either clone the entire repository:
$ git clone git://github.com/route4me/route4me-python-sdk.git
Or, download the zip/tarball:
# tarball
$ curl -OL https://github.com/route4me/route4me-python-sdk/tarball/master
# zip version:
$ curl -OL https://github.com/route4me/route4me-python-sdk/archive/master.zip
Now you can explore/modify code or embed it in your own project.
API¶
-
class
route4me.api.
Route4Me
(key, headers={'Accept': '*/*', 'Accept-Encoding': 'identity, deflate, compress, gzip', 'User-Agent': 'python-sdk'}, redirects=True, verify_ssl=True, proxies={})[source]¶ Bases:
object
Route4Me Python SDK
-
__init__
(key, headers={'Accept': '*/*', 'Accept-Encoding': 'identity, deflate, compress, gzip', 'User-Agent': 'python-sdk'}, redirects=True, verify_ssl=True, proxies={})[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
get_optimization
(optimization_problem_id)[source]¶ Get optimization given optimization_problem_id :param optimization_problem_id: :return:
-
Data Structures¶
API endpoints¶
Members¶
-
class
route4me.members.
Members
(api)[source]¶ Bases:
route4me.base.Base
Members management.
-
app_purchase_user_license
(**kwargs)[source]¶ Application purchase user License :param kwargs: :return: API response content
-
get_api_key_users
(**kwargs)[source]¶ Get users taht belong to a given api_key using GET request :return: API response
-
member_authenticate
(**kwargs)[source]¶ Member Authenticate :param kwargs: :return: API response content
-
Optimization¶
-
class
route4me.optimization.
Optimization
(api)[source]¶ Bases:
route4me.base.Base
An Optimization Problem is a collection of addresses that need to be visited. This is distinct from a Route, which is a sequence of addresses that need to be visited by a single vehicle and a single driver in a fixed time period. Solving an Optimization Problem results in a number of routes.
-
delete_address_from_optimization
(**kwargs)[source]¶ Delete Address from an optimization using DELETE request :return: API response :raise: ParamValueException if required params are not present.
-
delete_optimization
(**kwargs)[source]¶ Delete optimization using DELETE request :return: API response :raise: ParamValueException if required params are not present.
-
get_optimization
(**kwargs)[source]¶ Get optimization using GET request :return: API response :raise: ParamValueException if required params are not present.
-
Utilities¶
CHANGELOG¶
This is the history of changes of the route4me-python
package
This file should be filled by maintainers, using pull requests Please, follow this guide
[0.0.7.0] - 2020-09-01¶
Removed¶
- Python 2 support
- Pypy build
- Set Tracking Data Test
Added¶
- Documentation
- Changelog file
- Tox
- MANIFEST file
- VERSION file
Fixed¶
- Bug in Optimization Callback example
- Some Test Cases that were failing
Changed¶
- setup.py
- Travis config file
[0.0.6.1] - 2019-11-06¶
Added¶
- Redirect flag to QS when redirects are disable
Fixed¶
- Bug on batch geocoding
[0.0.6.0] - 2019-10-24¶
Changed¶
- Batch Geocodig method converted to POST request.
Fixed¶
- Bug that assign the geo-coordinates to the wrong addresses
[0.0.5.1] - 2018-08-22¶
Changed¶
- Changed all responses to JSON.
Fixed¶
- All examples to support JSON response
- GPS Test
[0.0.5.0] - 2018-02-26¶
Added¶
- Address-Book example to query for any field
Removed¶
- Lib xmltodict dependency.
- Limit and offset as required fields in addressbook service
Changed¶
- Addresses service
[0.0.3.8] - 2016-09-12¶
Added¶
- Activity Feed Support and Examples
- Optimization missing Examples
- Rapid Address missing Examples, remove python env from all examples, moved geocoding examples to its own folder
- File Uploading feature and examples
- Avoidance Zone missing Examples
[0.0.3.3] - 2016-04-18¶
Added¶
- Generic Example, Notes, Delete Route, Single Depot Multiple Driver, Single Depot Multiple Driver TW Examples and Features
[0.0.3.2] - 2016-03-24¶
Added¶
- Activities, Optimizations, Routes, Telematics, and Users Examples
- Notes, and Activities Services
[0.0.3.0] - 2016-01-19¶
Added¶
- Example to update address attributes/details in an existing route (i.e. custom data, alias, order details, weight)
- Example to insert address into existing route
- Example to remove address from existing route
- Example to move address from one stop into another
License¶
Copyright (C) 2016-2020 Route4Me
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.