Skip to content

Commit 10cc5cb

Browse files
author
Jakob Stolze
committed
feat: make apiKey optional in apiClient helper
1 parent f1033fd commit 10cc5cb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

openrouteservice/utility.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
from openrouteservice.configuration import Configuration
22
from openrouteservice.api_client import ApiClient
33

4-
def apiClient(apiKey: str, host: str = None) -> ApiClient:
4+
def apiClient(apiKey: str = None, host: str = None) -> ApiClient:
55
configuration = Configuration()
6-
configuration.api_key['Authorization'] = apiKey
6+
7+
if(apiKey):
8+
configuration.api_key['Authorization'] = apiKey
79

810
if(host):
911
configuration.host = host
12+
13+
if not(host or apiKey):
14+
raise ValueError('apiKey is required when using api.openrouteservice.org as a host. Please specify an apiKey or use a different host.')
1015

1116
return ApiClient(configuration)
1217

0 commit comments

Comments
 (0)