Giter Site home page Giter Site logo

theanticarcollective / transitland-rest-client Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 377 KB

Easy to use, minimal, and simple implementation of the Transitland v2 REST API for fetching GTFS, GTFS Realtime, GBFS, and MDS data in Javascript and/or Typescript.

License: MIT License

JavaScript 1.00% TypeScript 99.00%
api api-client api-rest client feed gbfs gtfs gtfs-realtime gtfs-rt rest

transitland-rest-client's People

Contributors

danthonywalker avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

transitland-rest-client's Issues

Generate Types for GeoJSON and GeoJSONL Formats

Currently, the project only provides types for JSON format responses. The Transitland REST API supports GeoJSON and GeoJSONL formats, thus, this project should supply types suitable for these formats.

To efficiently support these formats, #2 should probably be completed before any effort is made on this issue.

Support "Downloading source GTFS"

"Feeds" and "Feed versions" support a "Downloading source GTFS" endpoint. This endpoint returns data in a format unlike any other endpoint in the Transitland ecosystem, thus, likely needs its own function within the client.

Rework Type Generation

Currently, types are generated by hitting the REST API pseudo-randomly and using the responses to generate types. This is extremely inefficient (both in time and use of rate limits) and does not cover every response case,

Transitland provides schemas in the form of GraphQL objects.
https://github.com/interline-io/transitland-server/tree/main/schema

The REST API uses GraphQL internally which means these schemas should be identical to the REST client. Similar to the transitland-gql-client project, this project should automatically derive types on any schema update.

Explore Alternative Client Designs

Currently, the design of Client is incredibly basic. This makes usage of this library very easy and straightforward to understand. However, its current implementation constrains too much. For example, fetch only supports JSON-like responses so endpoints like "Downloading source GTFS" (#1) and supporting PNG formats (#4) are impossible.

One potential design would be to make "request functions". For example:

const { feeds } = await client.fetch(feeds());

This would call exactly to /feeds with no query parameters, and the function would automatically supply (and validate) the response type. That would make calls like this possible assuming an adequate implementation of response handling with these functions:

const stream = await client.fetch(feeds({ format: "PNG" }));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.