public-transport / transport.rest

Information about the *.transport.rest APIs.
https://transport.rest/
41 stars 4 forks source link

oebb.transport.rest #28

Open nocontent06 opened 2 months ago

nocontent06 commented 2 months ago

How about implementing the OEBB to transport.rest?

derhuerst commented 1 month ago

Hey, you're welcome to host an instance! I can then direct oebb.transport.rest to you.

nocontent06 commented 1 month ago

I'd love to do so. But I didn't manage to authorise at the OEBB's mgate.exe... do you know how to do that?

derhuerst commented 1 month ago

[…] I didn't manage to authorise at the OEBB's mgate.exe... do you know how to do that?

hafas-client's ÖBB profile shows how to do it.

It will be the most straightforward for you to pass it into hafas-rest-api@5, this is how v6.bvg.transport.rest (a.k.a. bvg-rest@6), v6.db.transport.rest (a.k.a. db-rest@6) & v6.vbb.transport.rest (a.k.a. vbb-rest@6) do it too.

nocontent06 commented 1 month ago

Ah i see what you mean...

I created a repo running on oebb.transport.rest

derhuerst commented 1 month ago

I recommend you to use hafas-rest-api@5 to build the API, both to save time and to get an API that behaves like v6.{bvg,db,vbb}.transport.rest.

nocontent06 commented 1 month ago

Okay sure...

The API is running on https://oebb.macistry.com temporarily if you wanna try it out.

e.g. https://oebb.macistry.com/journeys?from=8100085&to=8100147

derhuerst commented 1 month ago

The API is running on https://oebb.macistry.com temporarily if you wanna try it out.

Do you want me to configure a subdomain v6.oebb.transport.rest?

nocontent06 commented 1 month ago

Oh that'd be perfect!

I'll update the code that it uses hafas-rest-api soon

derhuerst commented 1 month ago

https://github.com/nocontent06/oebb.transport.rest/blob/e9e94df0f61c04b5cde51beca29af4ef6f648343/src/createHafasClient.js#L5

Please adapt this so something meaningful! From the hafas-client readme:

Because the operators of the HAFAS endpoint should be able to contact you about excessive traffic, please pass a link to your project/program (or an email address) into createClient():

derhuerst commented 1 month ago

v6.oebb.transport.rest is now a CNAME for oebb.macistry.com.

nocontent06 commented 1 month ago

Perfect!

I've updated my repo so far, that everything is ready for transition.

I just have to write a documentation.

The index page is currently oebb.macistry.com and the API chills on oebb.macistry.com/api

So basically... what do we need more?

Test: https://oebb.macistry.com/api/journeys?from=8100085&to=8100147

nocontent06 commented 1 month ago

image

It's running :)

derhuerst commented 1 month ago

I just have to write a documentation.

I highly recommend using hafas-rest-api@5. You will get a generated API documentation as well as an OpenAPI spec out-of-the-box. Both of them are generated from the parameters metadata in each route (e.g. here for /stops/:id/departures).

You will also get built-in:

The index page is currently oebb.macistry.com and the API chills on oebb.macistry.com/api

I recommend you to prefix/namespace your entire API with the version, e.g. $version.oebb.transport.rest or oebb.transport.rest/$version. Another option is using content negotiation for that, but it's easier to mess up.

Over time, I've had to make breaking changes with my *.transport.rest APIs several times. (You will have to make such breaking changes too, given that you use hafas-client, which will eventually change its response format.)

Having the v6 prefix with my *.transport.rest APIs really helps with deprecating the old one and deploying the new one next to it.

So basically... what do we need more?

You should configure your server to serve requests under v6.oebb.transport.rest.