npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ojp-sdk

v0.23.3

Published

OJP (Open Journey Planner) Javascript SDK

Downloads

1,906

Readme

OJP Javascript SDK

https://github.com/openTdataCH/ojp-js/

The OJP Javascript SDK is a Javascript/Typescript package used for communication with OJP APIs.

Resources

  • latest changes: CHANGELOG
  • SDK documentation: https://opentdatach.github.io/ojp-js
  • npm ojp-sdk package: https://www.npmjs.com/package/ojp-sdk
  • OJP Demo App: https://opentdatach.github.io/ojp-demo-app/ - web application using this SDK

Usage

  "dependencies": {
    "ojp-shared-types": "0.1.11",
    "ojp-sdk": "0.23.3",
  }
  • resources to use the SDK
    • this repo's playground app - playground.component.ts
    • SDK documentation: https://opentdatach.github.io/ojp-js
    • OJP Demo App: https://opentdatach.github.io/ojp-demo-app/ - web application using this SDK

Create SDK

import * as OJP from 'ojp-sdk-next';

// ...

// declare the stage config, PROD example below
const httpConfig: OJP.HTTPConfig = {
  url: 'https://api.opentransportdata.swiss/ojp20',
  authToken: 'TOKEN_FROM_opentransportdata.swiss',
};

// define a requestorRef that describes the client
const requestorRef = 'MyExampleTransportApp.v1';

// create the SDK
const language = 'de'; // de, fr, it, en
const ojpSDK = OJP.SDK.create(requestorRef, httpConfig, language);

Location Information Request (LIR)

Find locations by name, stop reference or inside a bounding box rectangle.

// case1 - build LIR by Name
const searchTerm = 'Bern';
const request = LocationInformationRequest.initWithLocationName('Bern');

// build LIR by StopRef
const stopRef = '8507000'; // Bern
const request2 = LocationInformationRequest.initWithPlaceRef(stopRef);

// build LIR by BBOX
// these are equivalent
let bbox: string | number[] = '7.433259,46.937798,7.475252,46.954805';
bbox = [7.433259, 46.937798, 7.475252, 46.954805];

const request3 =  ojpSDK.request.initWithBBOX(bbox, ['stop']);

// change XML payload if needed
request.payload.initialInput ...

// Fetch the results
async myMethod() {
  // ...
  const response = await request.fetchResponse(ojpSDK);

  if (!response.ok) {
    // handle error
    console.log(response.error);
    return;
  }

  // do something with the value
  const placeResults = response.value.placeResult ?? [];
  placeResults.forEach(placeResult => {
    console.log(placeResult.place.name);
  });
}

Trip Request (TR)

Find trips between A-B endpoints defined by stop references and / or coordinates

// a) from/to StopPlaceRefs
const fromStopRef = '8507000';  // Bern
const toStopRef = '8503000';    // Zürich
const request = OJP.TripRequest.initWithPlaceRefsOrCoords(fromStopRef, toStopRef);

// b) from/to coord pairs (latitude, longitude)
const fromCoordsRef = '46.957522,7.431170';
const toCoordsRef = '46.931849,7.485132';
const request2 = OJP.TripRequest.initWithPlaceRefsOrCoords(fromCoordsRef, toCoordsRef);

// change XML payload if needed
request.payload.params ...

// or use one of modifier method

// return precise route for legs, disabled by default
request.enableLinkProkection();

// set monomodal car requests
request.setCarRequest();

// Fetch the results
async myMethod() {
  // ...
  const response = await request.fetchResponse(ojpSDK);

  if (!response.ok) {
    // handle error
    console.log(response.error);
    return;
  }

  // do something with the value
  const tripResults = response.value.tripResult ?? [];
  tripResults.forEach(tripResult => {
    // handle tripResult response
  });
}

Stop Event Request (SER)

Display arrival / departure service information for stop references.

const stopRef = '8507000'; // Bern
const request = OJP.StopEventRequest.initWithPlaceRefAndDate(stopRef, new Date());

// change XML payload if needed
request.payload.params ...

// Fetch the results
async myMethod() {
  // ...
  const response = await request.fetchResponse(ojpSDK);

  if (!response.ok) {
    // handle error
    console.log(response.error);
    return;
  }

  // do something with the value
  const stopEventResults = response.value.stopEventResult ?? [];
  stopEventResults.forEach(stopEventResult => {
    // handle stopEventResult response
  });
}

Trip Info Request (TIR)

Display full service information (stop calls, service data)

const journeyRef = 'ch:1:sjyid:100001:2179-001'; // from a DatedJourneyService in a TR TimedLeg
const request = OJP.StopEventRequest.initWithJourneyRef(journeyRef);

// change XML payload if needed
request.payload.params ...

// Fetch the results
async myMethod() {
  // ...
  const response = await request.fetchResponse(ojpSDK);

  if (!response.ok) {
    // handle error
    console.log(response.error);
    return;
  }

  // do something with the tripInfoResult
  const tripInfoResult = response.value.tripInfoResult;
}

License

The project is released under a MIT license.

Copyright (c) 2021 - 2026 Open Data Platform Mobility Switzerland - opentransportdata.swiss.