Git Product home page Git Product logo

share-now-api's Introduction

Preview of demo website

Share Now car locations

Here is demo page that shows the locations of all Share Now cars. Only cars in Hamburg are shown right now.

Green markers are cars that became available.

Grey markers are cars that became unavailable.

Usage

npm install
node server.js

Go to http://localhost:8080.

MQTT

The data is serverd by a MQTT broker. For Europe the endpoint is mqtts://driver.eu.share-now.com:443. The clientId is a random UUID prefixed with a: for anonymous connections. No username and password are required.

You can subscribe to multiple topics. The schema is C2G/S2C/<locationId>/<topic>.GZ where topic is either VEHICLELIST or VEHICLELISTDELTA.

Possible locationId values are:

  • Germany
    • Hamburg - 3
    • Berlin - 12
    • Frankfurt am Main - 33
    • München - 26
    • Köln - 19
    • Stuttgart - 18
  • Italy
    • Milan - 20
    • Rome - 31
    • Turin - 44
  • Other countries
    • Copenhagen - 52
    • Paris - 48
    • Amsterdam - 5
    • Vienna - 7
    • Madrid - 36
    • Budapest - 55

The data received is json compressed with gzip.

VEHICLELIST

Subscriptions to this topic will give you a list with all cars for the given location. A message is sent each time there is an update, so you should unsubscribe as soon as you get the first message.

Example
{
    "connectedVehicles": [
        {
            "id": "WBY8P210107E82494",
            "plate": "M-EV1558E",
            "geoCoordinate": {
                "latitude": 53.57132,
                "longitude": 9.95367
            },
            "fuellevel": 84,
            "address": "Fruchtallee 107, 20259 Hamburg",
            "locationId": "3",
            "buildSeries": "BMW_I3",
            "fuelType": "ELECTRIC",
            "primaryColor": "B85U",
            "hardwareVersion": "HW42",
            "imageUrl": "https://www.car2go.com/rentalassets/vehicles/{density}/bmw_i3_capparis_white.png",
            "transmission": "GA",
            "rank": 1,
            "vin": "WBY8P210107E82494",
            "locationIdAsLong": 3
        }
    ],
    "locationId": 3,
    "eventType": "CONNECTED_VEHICLES",
    "timestamp": 1589666154706
}

VEHICLELISTDELTA

This topic receives messages whenever a car becomes available or unavailable.

Example
{
    "addedVehicles": [
        {
            "id": "WME4533421K323858",
            "plate": "HH-GO8560",
            "geoCoordinate": {
                "latitude": 53.55533,
                "longitude": 10.02782
            },
            "fuellevel": 59,
            "address": "Jungestra\u00c3\u0178e 6, 20535 Hamburg",
            "locationId": "3",
            "buildSeries": "C453",
            "fuelType": "GASOLINE",
            "primaryColor": "EN2U",
            "secondaryColor": "EDAO",
            "hardwareVersion": "HW3",
            "imageUrl": "https://www.car2go.com/rentalassets/vehicles/{density}/c453_silver.png",
            "transmission": "GA",
            "rank": 1,
            "vin": "WME4533421K323858",
            "locationIdAsLong": 3
        }
    ],
    "removedVehicles": [
        "WME4533421K291769"
    ],
    "locationId": 3,
    "timestamp": 1589656739007,
    "eventType": "VEHICLE_LIST_UPDATE"
}

Code

All Share Now api related code is in sharenow.js. Rest of the files are for the demo webpage.

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.