-
Notifications
You must be signed in to change notification settings - Fork 16
Function for getting prices would be convenient. #97
Comments
Hi! You're right. This SDK is currently only for journey planning. If you want prices and offers, you can use the Offers API. There are some guides there, but depending on what you want to do, they might not all be relevant. Maybe I can help if you give me some more details. You can also always contact us by using the feedback form on developer.entur.org or by sending an email to kollektivdata@entur.org. Thanks for reaching out! I agree, functions for getting prices would be convenient. :) |
I see! Yeah, I tried to use the offers API but couldn't quite figure it out |
I'm interested in the details of what you're trying to do, if you'd like to share more details. Maybe we can improve the docs and SDK further. :) Are you trying to show prices for journeys (trip patterns) or for certain zones? For a certain operator (Ruter, Vy or others)? For one adult, or special combinations? |
I’m creating a lowfare calendar for train prices (like the one Norwegian has for their planes). So I need a way to get the prices for a given journey on a given day. I think the prices for short train journeys (i.e. Lillestrøm - Oslo) stay more or less the same, but it is relevant for longer journeys (Oslo - Bergen). Check out my repo for a example of what I am doing 😄 |
Hi @draperunner. Vy blocked the ip of the server my project was running on so i figured I'd try moving over to Entur. I am trying to get an offer for this trip using this endpoint: Any help would be appreciated :) |
To get the ID, you also need to do make the search through Offers using the /search/graphql endpoint. All you need to do is to point the const sdk = new EnturService({
clientName: '<YOUR_CLIENT_NAME>',
+ hosts: {
+ journeyplanner: 'https://api.staging.entur.io/sales/v1/offers/search'
+ }
}) The trip patterns will then have an I suggest you use the staging URL for testing and respect rate limits, so we don't need to block you as well ;). Check out the throttler utility if you're bulk calling a lot of calls. |
Burning the midnight oil and responding to (I assume) work related questions late at night? Props! Thank you very much for the fast response. I’ll probably use C# and .NET Core for querying the API and then cache the results on my server, but thank you very much. I think I’ll figure it out by looking at the source code here. I’ll make sure to follow the rate limits and try to implement some kind of throttler on my backend. Looking at your constraints in rateLimits.js, it seems like I am allowed to do quite a lot of calls. |
So. I manage to query However when i try to query Any suggestions? |
A trip pattern is only cached for about 15 minutes, so if the ID |
I don't think that's it. For example, you could try this curl --location --request POST 'https://api.staging.entur.io/sales/v1/offers/search/graphql' --header 'Content-Type: application/json' --data-raw '{"query":"{\r\n trip(\r\n from: {place: \"NSR:StopPlace:548\"\r\n }\r\n\r\n to: {\r\n place:\"NSR:StopPlace:337\"\r\n }\r\n dateTime: \"2020-01-09T00:00:00+0100\",\r\n modes: [rail]\r\n \r\n \r\n \r\n )\r\n\r\n#### Requested fields\r\n {\r\n tripPatterns {\r\n startTime\r\n duration\r\n\r\n legs {\r\n mode\r\n distance\r\n line {\r\n id\r\n publicCode\r\n authority{\r\n name\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}","variables":{}}' | grep -Po '"id": *"\K[^"]*' | awk 'NR==1{print$1}' | xargs -I id curl --location --request GET 'https://api.staging.entur.io/sales/v1/offers/search/trip/trip-pattern/id' to see an example of what I mean |
You're right, something's wrong with the query from the SDK. I'm not sure exactly what. But it works with our v1 beta version. You could try |
I guess this is the wrong place to ask. I am not really looking to use the SDK. I just want to call the API. Is there something wrong with the offers API? And is there somewhere else I should rather ask for help? |
It's something in the GraphQL query that makes offers unable to fetch product information. It works with the query used in @entur/sdk v1.0-next, but not the one in v0 or in your curl. Try removing fields and see if you suddenly get an answer. |
I tried removing some fields from the post to the
I managed to get the |
I tried to use your SDK for a side project I am working on, but due to there not being a function for getting prices, and your API documentation being fairly poor. I resorted to using Vy's undocumented API
The text was updated successfully, but these errors were encountered: