Way to Use Open Trip Planner REST Api in My Web App ??

3,266 views
Skip to first unread message

Sumit D

unread,
Jul 24, 2014, 6:46:58 AM7/24/14
to opentrippl...@googlegroups.com
Hello All,

I am New in OTP.

I want to build Web app using OTP Rest API.

Is it possible to build web app using OTP rest API ?? I have my own GTFS Feed .

I have not found any exact Url or proper documentation to describe how i use OTP rest API to build web app.

Is OTP REST API is provide URL where i hit this url & get Result in JSON or XML which i am used in My Map ???


Thanks ,

Sumit Dheeman

email...@gmail.com

unread,
Jul 26, 2014, 8:12:58 AM7/26/14
to opentrippl...@googlegroups.com
Hello!

OTP consists of 2 things Java REST server and javascript client.
Official client is leaflet client which talks with server in JSON REST.

Here is whole of source code for official client: https://github.com/opentripplanner/OpenTripPlanner/tree/0.11.x/otp-leaflet-client/src/main/webapp

But there are other clients: https://groups.google.com/forum/#!searchin/opentripplanner-dev/mobile/opentripplanner-dev/4FgBmyn0rbM/-rkVLtR1A4UJ
This is one of them: https://github.com/conveyal/otp.js

To use OTP in your web app you can look how this clients communicate, and there is also API documentation:
http://docs.opentripplanner.org/apidoc/0.11.0/index.html for vestion 0.11 and partly master
And for version 0.10: http://docs.opentripplanner.org/apidoc/0.10.0/index.html

You just add your own GTFS and OSM and build a graph and then run OTP server. You can then connect to this server from your webapp or official one.

Sumit D

unread,
Jul 28, 2014, 1:21:36 AM7/28/14
to opentrippl...@googlegroups.com
Thanks,
For Guide me , Now i am making my understanding,

according to you I download whole code of OTP for Github.
an set up my localhost.

* Then I am hit my Local url from my web app and get Json results ???

* I am confuse how i use my GTFS routes , like agency.txt , routes.txt, stop.txt etc. in OTP ??
  you suggest me for build a graph for GTFS.  Please explain more ??

Thanks ,

Sumit

Marko Burjek

unread,
Jul 28, 2014, 5:17:03 PM7/28/14
to opentripplanner-users
I'm assuming you are using version 0.11.

You can see JSON with help of Firefox web developer
https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor or
Chrome developer tools https://developer.chrome.com/devtools/index

or you can open localhost as http://localhost:8080/?debug=true and you
will get a popup with planner response json.
You can disable it with http://localhost:8080/?debug=false

How to get data for example transit routes:

default is routerId.

http://localhost:8080/otp/routers/default/transit/routes?extended=true
All the agencies:
http://localhost:8080/otp/routers/default/transit/agencyIds?extended=true

http://localhost:8080/otp/routers/default/transit/stopTimesForStop?agency=MARPROM&id=292&startTime=1406077200000&endTime=1406163600000&extended=true

All the rest of API calls are here:
http://docs.opentripplanner.org/apidoc/0.11.0/resource_TransitIndex.html

If you just write this in browser you will get XML. You need to send
correct accept header to get JSON.

To use GTFS. Put GTFS zip file in same folder as OSM data and run otp like:
./otp --build ../data/data1 --transitIndex
--build needs a path to a directory with GTFS and/or OSM and/or elevation data
--transitIndex is needed so that stop and route data is build

After that you can run a server like:
./otp --graphs ../data/data1 --server
--graphs needs same path as --build, because Graph.obj is created in
the same folder as GTFS and other files.

For more option use ./otp --help

OTP uses routes.txt, stops.txt etc. to build a graph with transit
data. You can use it to search for paths. Or use a transitIndex to
find all routes between stops. All stopTimes for stop, all stops near
point etc..
> --
> You received this message because you are subscribed to the Google Groups
> "OpenTripPlanner Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to opentripplanner-...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Sumit D

unread,
Jul 29, 2014, 12:34:56 AM7/29/14
to opentrippl...@googlegroups.com
Thanks Marko,

I have some new query:-

* Is OSM Data is necessary.
* I am follow two minutes intro of OTP from github
I am facing problem to install maven . Is Maven is necessary ?
Please Solve My query..

Thanks & Regards,

Sumit

Marko Burjek

unread,
Jul 29, 2014, 4:54:38 AM7/29/14
to opentripplanner-users
Hello!

OSM is optional.
Maven is necessary. What problems do you have and on what operating system?
>> > email to opentripplanner-...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "OpenTripPlanner Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to opentripplanner-...@googlegroups.com.

Shaun McDonald

unread,
Jul 29, 2014, 6:52:10 AM7/29/14
to Sumit D, opentrippl...@googlegroups.com
On 29 Jul 2014, at 05:34, Sumit D <deemte...@gmail.com> wrote:

Thanks Marko,

I have some new query:-

* Is OSM Data is necessary.

If you don’t include the OSM data, you need to be very specific on where you click for the start or end of the journey. It can be useful for testing datasets even with this limitation as the time to generate the graph is less and the startup time is shorter due to the smaller graph.

Shaun

Andrew Byrd

unread,
Jul 29, 2014, 7:08:51 AM7/29/14
to opentrippl...@googlegroups.com
On 07/29/2014 12:52 PM, Shaun McDonald wrote:
> If you don’t include the OSM data, you need to be very specific on where
> you click for the start or end of the journey. It can be useful for
> testing datasets even with this limitation as the time to generate the
> graph is less and the startup time is shorter due to the smaller graph.

But also keep in mind that if you are calling the API directly, transit
stop IDs are valid as start and end points.

-Andrew

Sumit D

unread,
Jul 30, 2014, 2:42:57 AM7/30/14
to opentrippl...@googlegroups.com
Thanks Andrew & Shaun for aware me about OSM.

I facing a issues to set up OTP server.

I am using Getting Started with OTP in eclipse.

I am Successfully installed Eclipse & all Plugin .

When i work on option 3 

Clone the OTP repository and import Maven projects all at once

but maven projects not show in my workspace ??
i unable to find any maven modules..

Please make your view .

Thanks ,

Sumit

Andrew Byrd

unread,
Jul 30, 2014, 9:37:11 AM7/30/14
to opentrippl...@googlegroups.com
Hello,

All previous releases of OTP were composed of multiple Maven
sub-modules. In development leading up to 1.0 release we have moved to a
single Maven project with no submodules. If you clone the OTP git
repository and don't switch to a different branch/tag you will be on the
master branch, which is this new code.

In that case it is normal that there are no submodules visible.

-Andrew

On 07/30/2014 08:42 AM, Sumit D wrote:
> Thanks Andrew & Shaun for aware me about OSM.
>
> I facing a issues to set up OTP server.
>
> I am using*Getting Started with OTP in eclipse.*
>
> I am Successfully installed Eclipse & all Plugin .
>
> When i work on option 3
>
>
> Clone the OTP repository and import Maven projects all at once
>
> but maven projects not show in my workspace ??
> i unable to find any maven modules..
>
> Please make your view .
>
> Thanks ,
>
> Sumit
>
>
>
> On Tuesday, July 29, 2014 4:38:51 PM UTC+5:30, Andrew Byrd wrote:
>
> On 07/29/2014 12:52 PM, Shaun McDonald wrote:
> > If you don’t include the OSM data, you need to be very specific on where
> > you click for the start or end of the journey. It can be useful for
> > testing datasets even with this limitation as the time to generate the
> > graph is less and the startup time is shorter due to the smaller graph.
>
> But also keep in mind that if you are calling the API directly, transit
> stop IDs are valid as start and end points.
>
> -Andrew
>
> --
> You received this message because you are subscribed to the Google
> Groups "OpenTripPlanner Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to opentripplanner-...@googlegroups.com
> <mailto:opentripplanner-...@googlegroups.com>.

Sumit D

unread,
Jul 31, 2014, 2:38:15 AM7/31/14
to opentrippl...@googlegroups.com
Thanks Andrew,

I can't set up OTP using Eclipse 

Now I am Trying to Set OTP using Netbeans.

Please Attachments.

But Here I unable to find Modules As mention in 

Getting started with OTP in Netbeans 


Please Solve out my Problem.

Thanks ,

Sumit
Screenshot-1.png

Andrew Byrd

unread,
Jul 31, 2014, 5:40:23 AM7/31/14
to opentrippl...@googlegroups.com
Hello,

Everything I wrote still holds with Netbeans, these facts are
independent of your development environment. There are no submodules in
the master branch. Older releases will have the submodules.

I've been working with IntelliJ Idea recently, and I find that importing
the master branch of OTP now requires no special tricks besides having
Lombok installed.

-Andrew
> > an email to opentripplanner-...@googlegroups.com <javascript:>
> > <mailto:opentripplanner-...@googlegroups.com <javascript:>>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "OpenTripPlanner Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to opentripplanner-...@googlegroups.com
> <mailto:opentripplanner-...@googlegroups.com>.

Sumit D

unread,
Jul 31, 2014, 5:47:54 AM7/31/14
to opentrippl...@googlegroups.com
Thanks Andrew, for aware me.

Now i using 0.11x branch in netbeans 
i am facing Some Problems  ,
Please See in below link 

https://groups.google.com/forum/#!topic/opentripplanner-users/4iaxO7LFU9M

If you make your view its really helpful for me.

Again Thanks,

Sumit Dheeman
>     > an email to opentripplanner-users+unsub...@googlegroups.com <javascript:>
>     > <mailto:opentripplanner-users+unsub...@googlegroups.com <javascript:>>.
>     > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "OpenTripPlanner Users" group.
> To unsubscribe from this group and stop receiving emails from it, send

Marko Burjek

unread,
Jul 31, 2014, 8:56:29 AM7/31/14
to opentripplanner-users
This modules you are missing are renamed in 0.11.

You can build it with: Run-> Run Project. Main class is OTPMain.
But you need parameters --build (and path to directory with OSM, and GTFS)

How do you add this parameters in Netbeans I don't know, because I do
everything from command line.

Try with Peter Berg's documentation: Which is current:
https://docs.google.com/document/d/17Q8zxmnqQIQGBK7BL7iYrxWeEJQoII9UO4cpNTAxlCw/edit
On Bulding graph. You don't need osmconvert part.

What would you like to do?
>> > > an email to opentripplanner-...@googlegroups.com
>> > <javascript:>
>> > > <mailto:opentripplanner-...@googlegroups.com
>> > <javascript:>>.
>> > > For more options, visit https://groups.google.com/d/optout
>> > <https://groups.google.com/d/optout>.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "OpenTripPlanner Users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an email to opentripplanner-...@googlegroups.com
>> > <mailto:opentripplanner-...@googlegroups.com>.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "OpenTripPlanner Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to opentripplanner-...@googlegroups.com.

Sumit D

unread,
Aug 1, 2014, 9:44:08 AM8/1/14
to opentrippl...@googlegroups.com
Hello Andrew,

Now I using 0.10 branch of otp in netbeans.

all Steps are working.


but when I am Search my routes between two points.

its give 404 not found.

when i am run opentripplanner-api-webapp in a netbeans its show me error

I am Just Paste error log . think its help.

cd /root/NetBeansProjects/OpenTripPlanner/opentripplanner-api-webapp; JAVA_HOME=/opt/lux/jdk1.7.0_15 /usr/local/netbeans-7.3/java/maven/bin/mvn -Dnetbeans.deploy=true package
Scanning for projects...

Some problems were encountered while building the effective model for org.opentripplanner:opentripplanner-api-webapp:war:0.10.1-SNAPSHOT
'reporting.plugins.plugin.version' for org.apache.maven.plugins:maven-project-info-reports-plugin is missing. @ org.opentripplanner:opentripplanner:0.10.1-SNAPSHOT, /root/NetBeansProjects/OpenTripPlanner/pom.xml, line 180, column 15
'reporting.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. @ org.opentripplanner:opentripplanner:0.10.1-SNAPSHOT, /root/NetBeansProjects/OpenTripPlanner/pom.xml, line 191, column 15

It is highly recommended to fix these problems because they threaten the stability of your build.

For this reason, future Maven versions might no longer support building such malformed projects.

                                                                        
------------------------------------------------------------------------
Building OpenTripPlanner API Webapp 0.10.1-SNAPSHOT
------------------------------------------------------------------------

[resources:copy-resources]
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
Copying 7 resources

[resources:resources]
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
Copying 7 resources

[compiler:compile]
Nothing to compile - all classes are up to date

[resources:testResources]
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory /root/NetBeansProjects/OpenTripPlanner/opentripplanner-api-webapp/src/test/resources

[compiler:testCompile]
No sources to compile

[surefire:test]
No tests to run.
Surefire report directory: /root/NetBeansProjects/OpenTripPlanner/opentripplanner-api-webapp/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0


[war:war]
Packaging webapp
Assembling webapp [opentripplanner-api-webapp] in [/root/NetBeansProjects/OpenTripPlanner/opentripplanner-api-webapp/target/opentripplanner-api-webapp]
Processing war project
Copying webapp resources [/root/NetBeansProjects/OpenTripPlanner/opentripplanner-api-webapp/src/main/webapp]
Webapp assembled in [777 msecs]
Building war: /root/NetBeansProjects/OpenTripPlanner/opentripplanner-api-webapp/target/opentripplanner-api-webapp.war
WEB-INF/web.xml already added, skipping
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 9.423s
Finished at: Fri Aug 01 18:58:20 IST 2014
Final Memory: 12M/139M
------------------------------------------------------------------------
NetBeans: Deploying on GlassFish Server 3.1.2
    profile mode: false
    debug mode: false
    force redeploy: true
In-place deployment at /root/NetBeansProjects/OpenTripPlanner/opentripplanner-api-webapp/target/opentripplanner-api-webapp
Initializing...
deploy?DEFAULT=/root/NetBeansProjects/OpenTripPlanner/opentripplanner-api-webapp/target/opentripplanner-api-webapp&name=OpenTripPlanner_API_Webapp&contextroot=/opentripplanner-api-webapp&force=true failed on GlassFish Server 3.1.2 
 
The module has not been deployed.
See the server log for details.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:210)
at org.netbeans.modules.maven.j2ee.ExecutionChecker.performDeploy(ExecutionChecker.java:178)
at org.netbeans.modules.maven.j2ee.ExecutionChecker.executionResult(ExecutionChecker.java:130)
at org.netbeans.modules.maven.execute.MavenCommandLineExecutor.run(MavenCommandLineExecutor.java:212)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)

Thanks & Regards,

Sumit Dheeman
>> >     > an email to opentripplanner-users+unsub...@googlegroups.com
>> > <javascript:>
>> >     > <mailto:opentripplanner-users+unsub...@googlegroups.com
>> > <javascript:>>.
>> >     > For more options, visit https://groups.google.com/d/optout
>> >     <https://groups.google.com/d/optout>.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "OpenTripPlanner Users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "OpenTripPlanner Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an

Sumit D

unread,
Aug 4, 2014, 4:21:00 AM8/4/14
to opentrippl...@googlegroups.com
Thanks to all,

Now I am Set up 0.11 branch using Netbeans .

Regards,

Sumit
Reply all
Reply to author
Forward
0 new messages