Get Vehicle In, Vehicle Out API

Start with either the /assets or /locations endpoints, then use this API to retrieve the websocket URL to subscribe to “vehicle in, vehicle out” events.

The websocket URL provides a link to near real-time data for vehicle parking at the specified monitored location. You must use a websocket client to retrieve this data.

METHOD GET
URI <production url>/v1/assets/{id}/live-events?event-types=PKIN, PKOUT
Sample Request URI <production url>/v1/assets/1000000018/live-events?event-types=PKIN, PKOUT

Query Parameters

Parameter Description Required? Filter Values
id GE identifier for the device. Yes Value such as 1000000018.
live-events Specific to real-time data from websocket. Yes event-type
event-type Filter for parking events. Yes Insert the following enumeration codes to identify vehicles entering and exiting parking spaces:
PKIN
If you filter by PKIN, you receive a list of vehicles (identified by object-id) entering parking areas within the boundaries.
PKOUT
If you filter by PKOUT you receive a list of vehicles (identified by object-id) exiting parking areas within the boundaries.

Sample Response

This API returns a WebSocket response. You must use a WebSocket client to retrieve the live data.
{
  "url": "ws://ie-websocket-server-<production_url>/consume?routing_key=c358a630-592d-4257-93c8-bc1669fbf4c9",
  "registered-events": "PKIN,PKOUT"
}

WebSocket Information

The Vehicle In, Vehicle Out API uses the WebSocket protocol for streaming data. The streaming endpoint format is: ws://<streaming url>

The WebSocket protocol is used instead of HTTP because Vehicle In, Vehicle Out streams near real-time data.

Note: The ingestion URI and <Predix-Zone-Id> are included with the environment variables for your application when you bind your application to Intelligent Environment service instance. To view the environment variables, on a command line, enter:
cf env <application name>

For all streaming requests, use the token you received from UAA in the Authorization section of the HTTP header, in the following format:

Bearer <token from trusted issuer>
The following example shows a data-ingestion request:
URL: wss://ingestion_url 
Headers:
    Authorization: Bearer <token from trusted issuer>
    Predix-Zone-Id: <Predix-Zone-Id>
    Origin: http://<origin-hostname>/
         Request Payload: {
      "messageId": "<MessageID>",
    "body":
[
         {
            "name":"<TagName>",
          "datapoints":
[
[
                  <EpochInMs>,
                <Measure>,
                <Quality>
]
],
          "attributes":
{
               "<AttributeKey>":"<AttributeValue>",
             "<AttributeKey2>":"<AttributeValue2>"
          }
       }
    ]
 }

Websocket Response Parameters

Parameter Data Type Required? Description
event-uid String   A unique identifier established by a customer or external resource for the parking event.
timestamp Number   Actual timestamp when event occurred. Timestamps are in EPOCH format.
event-type String   Identifies this type of event:
PKIN
Vehicle entering parking space.
PKOUT
Vehicle exiting parking space.
device-uid String   A unique identifier established by a customer or external resource for the device recording this event.
location-uid String   A unique identifier established by a customer or external resource to identify a parking location the vehicle entered or departed from in this event.
properties Map   Custom properties captured for this event-type instance.
object-uid String   A unique identifier established by a customer or external resource for the vehicle that entered or departed the related (parking) location.
coordinates Array   GPS coordinates identifying the location of the parked vehicle. Four coordinates representing the vehicle should be provided for each location-uid.
measures Array  
tag
identifier for the vehicle
value
number, such as 100
unit
percent

Sample Response

Note: You must use a WebSocket client to retrieve this data.
{ 
        "event-uid": "360597e9-3a3d-4f1c-a686-4d575ba11f55", 
        "timestamp": 1461019279795, 
        "event-type": "PKOUT", 
        "device-uid": "HYP1040-75", 
        "location-uid": "158-parkingspot", 
        "properties": {   
        "object-uid": "cf0dfb91-b11e-4d4d-9213-eb057187122f",   
        "coordinates":
        "32.711637:-117.15732968838816,32.711637100678395:-117.15736341303291,32.711734:-117.15736427535526,32.711733:-117.15733055071051" 
        }, 
        "measures": [   
        {     
        "tag": "PKOVLP",     
        "value": 100,     
        "unit": "PCT"   
        } 
        ]}
Note: The above examples shows the interval in seconds, but your PARKING simulation is shown in minutes.