Skip to content

tomrss/py-osrm-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py-osrm-client

build publish PyPI version

Simple and typed Python client for OSRM api.

Requirements

Installation

pip install py-osrm-client

Usage

Async client:

import asyncio
from osrm import OsrmAsyncClient

async def example():
    async with OsrmAsyncClient() as osrm:
        coordinates = [(0.1, 0.2), (0.3, 0.4)]
        trip = await osrm.trip(coordinates)
        print(trip)

asyncio.run(example())

Sync client:

from osrm import OsrmClient

with OsrmClient() as osrm:
    coordinates = [(0.1, 0.2), (0.3, 0.4)]
    trip = osrm.trip(coordinates)
    print(trip)

By default the clients will refer to the OSRM demo server at https://router.project-osrm.org. To use another OSRM server:

async with OsrmAsyncClient(base_url='https://my-custom-osrm-server.com') as osrm:
    # use client

Refer to OSRM api documentation for more details about OSRM services and options.