GraphQL Occupancy API V2
- 1 Overview
- 2 Authorization
- 3 Endpoint Url
- 4 Request Types
- 4.1 Enums
- 4.1.1 OccupancyStatus
- 4.1.2 LabelsMatch
- 4.1.3 GroupBy
- 4.1.4 CheckConsistency
- 4.2 Input Types
- 4.2.1 LocationWithRadiusInput
- 4.2.2 FilterInput
- 4.1 Enums
- 5 Response Types
- 5.1 Core Types
- 5.1.1 Location
- 5.1.2 OccupancySummary
- 5.2 Hierarchical Types
- 5.2.1 ProjectOccupancy
- 5.2.2 ZoneOccupancy
- 5.2.3 LevelOccupancy
- 5.2.4 GroupOccupancy
- 5.2.5 PositionOccupancy
- 5.3 Subscription-Related Types
- 5.1 Core Types
- 6 Operations
- 6.1 Queries
- 6.1.1 Project Occupancy Query
- 6.1.2 Zone Occupancy Query
- 6.1.3 Level Occupancy Query
- 6.1.4 Group Occupancy Queries
- 6.1.5 Position Occupancy Query
- 6.2 Mutations and Subscriptions
- 6.2.1 Subscrption Types
- 6.2.2 Subscription expiry
- 6.2.3 Create Snapshot Subscription
- 6.2.4 Create Updates Subscription
- 6.2.5 Subscription Updates Warning
- 6.2.6 Update Snapshot Subscription
- 6.2.7 Update Updates Subscription
- 6.2.8 Demand Snapshot
- 6.2.9 Keep Alive Subscirption
- 6.3 GraphQL Schema
- 6.1 Queries
Overview
This document outlines the GraphQL Occupancy API V2, which uses the Occupancy Aggregator service. Key updates include support for zone and floor queries, label aggregation, hybrid parking types, and two types of real-time subscriptions. The API is designed for efficient real-time parking space data retrieval and management, supporting various use cases from individual space monitoring to group and zone-level occupancy tracking.
Authorization
In order to authorize with this API, you need to add the following header to your request:
Key | Value |
---|---|
Authorization | <your token> |
Your token can be obtained from the Company Info section of the Nwave’s console.
You are not able to make API calls more frequently, than 300 times per 5 minutes with the same token. If amount of requests exceeds the limit, API reponds with error until the end of the 5 minute interval.
Endpoint Url
This API is available at the following url:
https://occupancy.api.nwave.io/graphql
Â
Request Types
Enums
OccupancyStatus
enum OccupancyStatus {
Free
Occupied
Undefined
}
Represents the current state of a parking space:
Free
: Space is available for parkingOccupied
: Space is currently in useUndefined
: Status cannot be determined (e.g., sensor malfunction or missing data)
LabelsMatch
enum LabelsMatch {
all
any
exclude
}
Defines how multiple label filters should be applied when searching for parking spaces:
all
: Space must have all specified labelsany
: Space must have at least one of the specified labelsexclude
: Space must not have any of the specified labels
GroupBy
Specifies the hierarchical level at which to aggregate parking data:
project
: Aggregate across entire projectszone
: Aggregate by zoneslevel
: Aggregate by floor/levelgroup
: Aggregate by parking space groupsposition
: Show individual parking spaces
CheckConsistency
Controls validation of hierarchical relationships in queries:
hierarchy
: Ensures entities exist within their parent containers (e.g., zones within projects, groups within zones)
Input Types
LocationWithRadiusInput
Defines a circular geographical area by specifying a center point and radius. Used for location-based filtering of parking data.
Fields:
latitude
: The latitude coordinate of the center pointlongitude
: The longitude coordinate of the center pointdistanceMeters
: The radius of the circular area in meters, defining how far from the center point to include results
FilterInput
Provides comprehensive filtering capabilities for querying parking occupancy data.
Fields:
id
: Unique identifier for the filterprojectId
: Filter by specific project IDszoneId
: Filter by specific zone IDslevelId
: Filter by specific level IDsgroupId
: Filter by specific group IDsgroupCustomId
: Filter by custom group identifiersnetworkId
: Filter by network IDslabels
: Filter by space labels (e.g., "EV", "Disabled")labelsMatch
: Specify how to match multiple labels (all/any/exclude)floorNumber
: Filter by specific floor numbersgroupBy
: Specify how to aggregate the results (group/level/position/project/zone)
Â
Response Types
Core Types
Core types form the foundation of the occupancy API, with Location being used to position elements geographically and OccupancySummary providing the essential metrics needed to understand parking availability at any level of the system hierarchy.
Location
Represents a geographical coordinate point used throughout the API to specify positions of parking facilities, zones, spaces and other physical elements in the system.
Fields:
lat
: The latitude coordinate of the location pointlon
: The longitude coordinate of the location point
OccupancySummary
Provides statistical information about parking space occupancy. It is used across different hierarchy levels (projects, zones, levels, groups) to give an overview of parking space utilization and availability.
Fields:
total
: The total number of parking spaces in the scopeoccupied
: The number of parking spaces currently in useavailable
: The number of parking spaces currently available for useundefined
: The number of parking spaces whose status cannot be determined (e.g., no sensor in position or device error)
When handling parking space availability, it is recommended to treat spaces with undefined
OccupancyStatus as occupied
to avoid potential space conflicts and ensure better user experience.
Hierarchical Types
ProjectOccupancy
Represents the highest level in the parking facility hierarchy, typically encompassing an entire parking facility or a collection of parking areas managed as a single entity. It provides aggregated occupancy data for all parking spaces within the project.
Fields:
id
: Unique integer identifier for the projectname
: Human-readable name of the parking projectlocation
: Geographic coordinates representing the project's central location pointoccupancy
: Aggregated statistics showing total spaces, occupied spaces, available spaces, and undefined statuses across the entire project
ZoneOccupancy
Represents a distinct area within a parking facility that contains multiple parking spaces. Zones help organize parking facilities into logical sections and provide aggregated occupancy data for their contained spaces.
Fields:
id
: Unique integer identifier for the zonename
: Human-readable name for the zone (e.g., "South Garage")projectId
: Reference to the parent project containing this zonelocation
: Geographic coordinates representing the central point of the zoneoccupancy
: Statistical summary of parking space availability within the zone
LevelOccupancy
Represents a floor or level within a parking facility, providing occupancy data for a specific vertical section of the facility. This type is particularly useful for multi-story parking structures where understanding availability per floor is important for navigation and space allocation.
Fields:
id
: Unique integer identifier for the levelname
: Human-readable name for the level (e.g., "Ground Floor", "Level C")zoneId
: Reference to the parent zone containing this levelprojectId
: Reference to the parent project containing this levelfloorNumber
: Numeric representation of the floor level within the structureoccupancy
: Statistical summary of parking space availability on this level
GroupOccupancy
Represents a collection of related parking spaces within a level, such as designated sections for specific types of vehicles or parking purposes. Groups allow for logical organization of parking spaces and enable targeted monitoring of specialized parking areas.
Fields:
id
: Unique integer identifier for the groupprojectId
: Reference to the parent project containing this groupzoneId
: Reference to the parent zone containing this grouplevelId
: Reference to the parent level containing this groupname
: Human-readable name for the group (e.g., "EV Charging Section", "Row 2A")groupType
: Classification of the group's type ('general', 'marked_parking_bay', 'unmarked_parking_bay', 'standalone_car_counters', 'array_car_counters', 'multi_level_parking')customId
: Optional external identifier for integration with other systemslocations
: Array of geographic coordinates defining the physical bounds of the groupoccupancy
: Statistical summary of parking space availability within the group
PositionOccupancy
Represents an individual parking space and its current state. This type provides the most granular level of occupancy data, enabling precise tracking of individual space availability and characteristics.
Fields:
id
: Unique integer identifier for the parking spacecustomId
: Optional external identifier for integration with other systemsgroupId
: Reference to the parent group containing this positionzoneId
: Reference to the parent zone containing this positionlevelId
: Reference to the parent level containing this positionprojectId
: Reference to the parent project containing this positionoccupancyStatus
: Current state of the parking space (Free/Occupied/Undefined)statusChangeTime
: Timestamp of when the occupancy status last changedlocation
: Geographic coordinates of the parking spacelabels
: Array of tags describing characteristics of the space (e.g., "EV", "Disabled", "VIP")
Subscription-Related Types
CreateSubscriptionResponse
Returns the essential information needed to manage real-time data subscriptions. This type is returned by all subscription-related mutations, including creation, updates, and keep-alive operations.
Fields:
id
: Unique UUID identifier used for referencing this subscription in subsequent operations, including listening for updates and managing the subscription lifecycle
expiresOn
: Timestamp indicating when the subscription will automatically expire if not renewed
OccupancySnapshot
Represents a complete state capture of parking occupancy data at a specific moment in time. This type provides a hierarchical view of the entire parking system, from individual spaces up to projects, enabling comprehensive analysis of parking availability across all levels of organization.
Fields:
id
: Unique UUID integer identifier for this snapshotprojects
: Array of project-level occupancy datazones
: Array of zone-level occupancy data within the projectslevels
: Array of level-level occupancy data within the zonesgroups
: Array of group-level occupancy data within the levelspositions
: Array of individual parking space data within the groupsoccupancy
: Overall statistical summary across all entities in the snapshot
SubscriptionOccupancySnapshot
Represents the response payload for snapshot-based subscriptions, providing complete state information for all entities matching the subscription filters. This type is used when subscribers need comprehensive occupancy data rather than just changes.
Fields:
id
: Unique UUID identifier linking this update to its subscriptiontime
: Timestamp indicating when this snapshot was generatedfilters
: Array of complete occupancy snapshots matching the subscription's filter criteria
SubscriptionOccupancyUpdates
Represents the response payload for update-based subscriptions, providing only changed entities since the last update. The specific field populated in the response corresponds to the groupBy
parameter specified during subscription creation (e.g., if groupBy: zone
was specified, only the zone
field will contain data).
Fields:
id
: Unique UUID identifier linking this update to its subscriptiontime
: Timestamp indicating when this update was generatedproject
: Updated project data when grouping by projectszone
: Updated zone data when grouping by zoneslevel
: Updated level data when grouping by levelsgroup
: Updated group data when grouping by groupsposition
: Updated individual space data when grouping by positions
Â
Operations
Queries
In GraphQL, a Query is similar to a GET request in traditional APIs, where the client requests data from the server. Clients can pass query parameters to filter or specify the data they need, making queries customizable and efficient. Each query defines what fields to retrieve, and the server responds with only the requested data.
Project Occupancy Query
Retrieves occupancy information for parking projects matching the specified criteria. This query is particularly useful for applications that need to monitor multiple parking facilities, such as city-wide parking management systems or multi-site parking operators.
Schema
Example Query
Example Response
Zone Occupancy Query
Retrieves occupancy information for parking zones within a specified geographic area. This query is ideal for mobile applications that need to display nearby parking availability to users based on their current location, helping drivers quickly find available parking in their vicinity.
Schema
Example Query
Example Response
Level Occupancy Query
Retrieves occupancy information for specific levels or floors within parking facilities. This query is particularly useful for mobile applications that help users find parking in multi-story structures, enabling them to make informed decisions about which floor to park on before entering the facility.
Schema
Example Query
Example Response
Group Occupancy Queries
Retrieves occupancy information for specific groups of parking spaces. This query is useful for applications that need to monitor specialized parking areas or specific sections within a parking facility.
Schema
Example Request
Example Response
Position Occupancy Query
Retrieves detailed information about individual parking spaces. This query provides the most granular level of parking data, allowing applications to access specific space characteristics and their current state.
Schema
Example Request
Example Response
Mutations and Subscriptions
Subscrption Types
This API enables the creation of subscriptions and provides real-time updates about these subscriptions. There are two types of subscriptions available:
Snapshot Subscriptions: Provide complete occupancy data for the subscribed entities whenever any change occurs.
Update Subscriptions: Provide only the changed occupancy data, making them more efficient for real-time updates.
In GraphQL, a mutation is used to modify or create data on the server, similar to POST, PUT, or DELETE requests in REST APIs. In our use case, mutations are used to create and update subscriptions, allowing clients to manage parking-related subscriptions.
Subscription expiry
Create Snapshot Subscription
Example use case: This mutation creates a subscription to monitor parking availability in zones 10 and 11 within project 101. It uses a zone-based grouping (groupBy: zone
) and filters for parking spaces labeled as EV. The subscription is limited to a 5,000-meter radius around the given coordinates (latitude: 37.7749, longitude: -122.4194). The labelsMatch: any
ensures that any space marked as EV will be included. The mutation response will include a unique subscription id
and an expiresOn
field, indicating when the subscription will expire.
Create Updates Subscription
Example use case: When monitoring a large parking facility, receiving only changed data can significantly reduce bandwidth usage. This subscription will only return information about spaces that have changed their occupancy status.
Subscription Updates Warning
Update Snapshot Subscription
Example use case: In this mobile app scenario, the user initially subscribed to parking availability within a 5,000-meter radius, but as they zoom in on the map, the subscription needs to be adjusted to a smaller area.
Update Updates Subscription
Similar to updating snapshot subscriptions, but for the more efficient updates-only subscription
Â
Demand Snapshot
Example use case: During testing or debugging, you may need to manually trigger a complete data update.
Keep Alive Subscirption
Extends the expiration time of any subscription without modifying its parameters.
GraphQL Schema
Â
Â