ciaranmccormick / python-bods-client

A python client for the Bus Open Data Service API
MIT License
21 stars 3 forks source link

Searching Datasets by multiple NOCS only searches for last NOC in list. #29

Closed spencer-b-318 closed 2 years ago

spencer-b-318 commented 2 years ago

Passing BODSClient.get_timetable_datasets() a list of NOCs only returns results containing the last NOC in the list. The code below should return 3 rows:

2 for 'BPTR' and 1 for 'RBTS'.

However it only returns 1 containing 'RBTS'

bods = BODSClient(api_key=api)

params = timetables.TimetableParams(nocs = ['BPTR','RBTS'])

data = bods.get_timetable_datasets(params=params)
j = data.json()
j1 = json.loads(j)
df = pd.json_normalize(j1['results'])
ciaranmccormick commented 2 years ago

@spencer-b-318 this looks like an issue with the BODS API only accepting list parameters in the format ?noc=BPTR,RBTS and not ?noc=BPTR&noc=RBTS (like some other APIs do). I'll work on a fix but in the meantime there is a work around you can create a one element list with comma separated string containing all the nocs,

params = timetables.TimetableParams(nocs = ['BPTR,RBTS'])

This will return the correct number of timetables.

ciaranmccormick commented 2 years ago

Fixed in 0.9.1