sncf-api

A simple wrapper for SNCF API

Usage no npm install needed!

<script type="module">
  import sncfApi from 'https://cdn.skypack.dev/sncf-api';
</script>

README

Sncf-API

Travis Coverage Status

This is a simple wrapper for the SNCF (French National Railways Company) API. -> for more info on the API itself

Getting started

Terminal : install from npm

npm install sncf-api

JS

// import the wrapper
var SncfApi = require("sncf-api");

// set credentials
SncfApi.withCredentials('username','password');

// create a request with req(), fill it (here with the listNetworks instructions), when your request is good, use build() then execute()
SncfApi.req().listNetworks().build().execute(function(err, resp){
  // err is null if everything went good
});

Chained instructions

// to list arrivals in a given networks
SncfApi.req().withNetwork('given-network-id').listArrivals().build().execute(function(err, resp){
  // err is null if everything went good
});    

You can chain every type of the following list :

  • Networks
  • Lines
  • Routes
  • StopPoints
  • StopAreas
  • Departures
  • Arrivals
  • CommercialModes
  • PhysicalModes
  • Companies
  • Places
  • PlacesNearby

For every type, you have 2 instructions :

  • list
  • with

eg : for the Lines type, you can use listLines() or withLine()