Closed ways closed 5 years ago
You should use the Geocoder API /autocomplete
endpoint for searching up stop places and their ID before using the JourneyPlanner API to do the actual travel search.
So this call: GET https://api.entur.io/geocoder/v1/autocomplete?text=Lijordet&size=20&lang=no
will give you search results in GeoJSON format for "Lijordet". The first feature has the category "metroStation"
and the ID "NSR:StopPlace:3700". This is the ID you can use in the stopPlace
graphql query.
If you're using JavaScript, you might want to check out our SDK: https://github.com/entur/sdk
An example with the SDK:
import EnturService from '@entur/sdk'
const service = new EnturService({ clientName: 'awesomecompany-awesomeapp' })
async function getDeparturesFromPlace(placeName) {
const [feature] = await service.getFeatures(placeName)
const departures = await service.getStopPlaceDepartures(feature.properties.id)
departures.forEach((departure) => {
const { expectedDepartureTime, destinationDisplay, serviceJourney } = departure
const { line } = serviceJourney.journeyPattern
console.log(`${expectedDepartureTime} ${line.transportMode} ${line.publicCode} ${destinationDisplay.frontText}`)
})
}
getDeparturesFromPlace('Lijordet')
So this call:
GET https://api.entur.io/geocoder/v1/autocomplete?text=Lijordet&size=20&lang=no
will give you search results in GeoJSON format for "Lijordet". The first feature has the category"metroStation"
and the ID "NSR:StopPlace:3700". This is the ID you can use in thestopPlace
graphql query.
Thanks! Got it working at https://gitlab.com/larsfp/pentur
Hi again.
I'm trying to search for a stop by name in NSR. The API has two examples. Search for place and search for stop.
Place:
This gives several hits, but not the stop I'm looking for: https://en-tur.no/nearby-stop-place-detail?id=NSR:StopPlace:3700
Stop: I can find stops by "id", but I can't tell how to specify string to search for here.
Edit: update second example used