Skip to content

Rhein-Neckar-Verkehr/data-hub-typescript-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RNV Open Data Client

Contains a simple client in typescript to access the RNV Open Data API and a curl script with equivalent functionality.

This readme file contains information about using the client. For detailed documentation on how to use the GraphQL interface, see the documentation link from here

Preparation steps

Obtain Credentials

To get access to our Open Data Hub API with your solutions, it is necessary to have an oauth2 access token. You need to go through several steps to generate such a token.

  1. You register with your name and email for "Graphql" access here. Open RNV Formular.
  2. After about 10 minutes you should receive a mail with your basic credentials, it's recommended to save the mail.
  3. From these credentials you can generate an access token for your coded clients, there are several ways to obtain such a token, some of them are described here.

Prepare credentials

  1. Download the graphql.http file to this repo and place it in the root path.
  2. Download the preparation script from gist (see below).
  3. Run the shell script ./prepare_env_file.sh. This will generate a .env file which is read by the node.js application.

On Unix/Mac/Linux

You can copy the shell-script from node_modules.

curl https://gist.githubusercontent.com/rnv-opendata/8365b1317505a80359491c2124a05e94/raw/2fc73bdbb1dd4872feff7aa8182c477d01a379cc/prepare_env_file.sh > prepare_env_file.sh
sudo chmod u+rwx prepare_env_file.sh
./prepare_env_file.sh > ./node/.env

On Windows

$ cd node
$ curl https://gist.githubusercontent.com/rnv-opendata/900d43affca063caed7918f91d9531b5/raw/38060421063bc4766566e5324af489fbce226cac/prepare_env_file.cmd > prepare_env_file.cmd
$ pwsh prepare_env_file.cmd

Usage example

Once you obtained the credentials, you can run this project using yarn.

  1. First, change into the node directory.

  2. Install dependencies:

yarn
  1. Build the project:
yarn build
  1. Run a query, e.g.:
yarn station

Other examples can be found under "scripts" in the package.json

You can also use the curl script provided in curl_abfragen.sh

Important Links

  1. RNV Opendata GitHub Repository

About

Simple Typescript client for the data-hub API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published