Application Programming Interface Report For Safe and Secure Parking Areas
Application Programming Interface Report For Safe and Secure Parking Areas
mmmll
Safe and Secure Truck Parking Study, API Design Guidelines
Report title:
2
Safe and Secure Truck Parking Study, API Design Guidelines
Foreword .................................................................................................................................... 5
3
Safe and Secure Truck Parking Study, API Design Guidelines
6. Conclusion ........................................................................................................................ 17
4
Safe and Secure Truck Parking Study, API Design Guidelines
Foreword
These guidelines are targeted at Safe and Secure parking providers for designing
Application Programming Interfaces (APIs) through which their services will be provided
through mobile apps to other entities, for example online platforms and fleet management
services. The provided APIs should enable authorised users to search, list, view details and
availability, as well as book, rate and comment on the parking areas.
In designing the API some general guidelines are recommended to be followed in order to
facilitate integration with back office systems, platforms and devices (e.g. smartphones),
and at the same time ensure its security and reliability and allow future updates. At the
same time the common approach to API design will also steer the way some user functions
are defined and thus enable a more seamless user experience regardless of app provider.
5
Safe and Secure Truck Parking Study, API Design Guidelines
Parking service providers could make their service available for individual users and
enable them to search and book a parking space for a single vehicle, for example from a
mobile device (app), or also for users or systems (e.g. fleet management systems,
Enterprise resource planning – ERP…) that would make a booking for one or more
vehicles. To facilitate both kinds of interactions, for both use cases a single API design
should be used.
Making available an API designed according to certain guidelines should enable service
providers to make their services available through more channels and thus allow them
wider visibility and potential for more efficient use of their parking areas and finally higher
revenues.
A well-designed web service does not require substantial effort to integrate and provides a
secure access to system functionalities without exposing nor compromising its internal
functioning.
6
Safe and Secure Truck Parking Study, API Design Guidelines
• Easy to learn
• Easy to use, even without documentation
• Hard to misuse
• Easy to read and maintain code that uses it
• Sufficiently powerful to satisfy requirements
• Easy to extend
• Appropriate to audience
2. Functional requirements
This chapter elaborates the essential and optional functionalities that must to be provided
though the APIs in order to support the identified needs and requirements. In the future, the
need to add new functionalities might arise, therefore, the APIs need to have such
possibility without compromising existing users and integrations.
2.1. Discovery
Functionality provides listing of parking locations based on provided criteria. Several
filters can be added to the search criteria simultaneously, and the results shall be provided
as ordered lists. The supported search criteria shall include parking location characteristics
of various types, for example:
Source:
https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/32713.pdf
7
Safe and Secure Truck Parking Study, API Design Guidelines
• Currency
• Security rating
• Comfort rating
• Last update (date)
Driver
• Restaurant / Coffee shop / buffet
• Hotel
• Toilets
• Showers
• Shop
• Lighting
• WiFi
• Medical first aid / assistance
• Cash machine (ATM)
• Camera surveillance
• Electric plugs
• Laundry
Vehicle
• Fuel
• Charging
• Snow and ice removal equipment
• Spare parts
• Mechanical assistance
• Vehicle wash
General
• Parking reservation and payment
• Capacity information
• Opening hours
• 24/7 security guard
• Camera surveillance
8
Safe and Secure Truck Parking Study, API Design Guidelines
• Name
• Surname
• Languages spoken
• Organisation title
• Address and postcode
• Country
• VAT
Furthermore, the user shall be able to provide more information to complete his profile, for
example upload his photo, provide his interests and other ‘socially’ relevant information.
2.4. Booking
An authorised user shall be able to book a slot (or several) at a selected parking location.
Limits need to be defined, such as maximum booking duration, earliest booking date,
maximum arrival delay. After a booking request is made and payment is processed, the
API shall respond with a booking confirmation.
9
Safe and Secure Truck Parking Study, API Design Guidelines
• User (ID)
• Vehicle registration number
• Selected parking area
• Selected parking lot
• Desired parking start time (dd/mm/yyyy, hh:mm)
• Desired parking duration (in periods of 4, 12, 24 and 48 hours)
• Transport of dangerous goods (ADR, yes/no)
• Refrigerated (yes/no)
• Special requirements
• User (ID)
• Booking ID
• Vehicle registration number
• Selected parking area
• Selected parking lot
• Parking start time (dd/mm/yyyy, hh:mm)
• Parking end time (dd/mm/yyyy, hh:mm)
• Latest parking arrival (dd/mm/yyyy, hh:mm)
• Transport of dangerous goods (ADR, yes/no)
• Special requirements
• Price paid
10
Safe and Secure Truck Parking Study, API Design Guidelines
3. Non-functional requirements
This chapter details the recommended approach to designing an API in a way to ensure
easy integration, security, and use.
At the same time, the most common data formats are XML and JSON, of which JSON is
more lightweight and recommended to be used on mobile devices.
3.2. Security
For basic functionalities, which do not require user authentication (e.g. parking search),
there are no specific security requirements. For services that require user authentication
and allow for booking, payment, user generated content, as a basic requirement, the API
should use HTTP Secure (HTTPS) communication with Transport Layer (TLS)
encryption.
Furthermore, the payment API should adhere to the requirements and recommendations
defined by Payment Card Industry Data Security Standard (PCI DSS). Further details on
securing payments are available at:
11
Safe and Secure Truck Parking Study, API Design Guidelines
https://www.pcisecuritystandards.org/pdfs/best_practices_securing_ecommerce.pdf?agree
ment=true&time=1499981509898
3.5. Documentation
The API shall be supplemented by a comprehensive and clear documentation, ideally with
code samples, a detailed API reference section and sequence diagrams
• 200 – OK
Indicates that the request has succeeded.
• 201 – CREATED
New resource has been created
• 204 – NO CONTENT
The resource was successfully deleted, no response body
• 304 – NOT MODIFIED
The date returned is cached data (data has not changed)
• 400 – BAD REQUEST
The request was invalid or cannot be served. The exact error should be explained in
the error payload. E.g. „The JSON is not valid “.
12
Safe and Secure Truck Parking Study, API Design Guidelines
• 401 – UNATHORIZED
The request requires user authentication.
• 403 – FORBIDDEN
The server understood the request but is refusing it or the access is not allowed.
• 404 – NOT FOUND
There is no resource behind the URI.
• 500 – INTERNAL SERVER ERROR
API developers should avoid this error. If an error occurs in the global catch blog,
the stack trace should be logged and not returned as a response.
4.2. Versioning
There is not a single recommendation on how to version the API. The following three
approaches are the most common:
Example:
http://api.truckparking.com/v1
http://apiv1.truckparking.com
The version need not be numeric, nor specified using the “v[x]” syntax. Alternatives
include dates, project names, seasons or other identifiers that are meaningful enough to the
team producing the APIs and flexible enough to change as the versions change.
Example:
Accept-version: v1
Accept-version: v2
13
Safe and Secure Truck Parking Study, API Design Guidelines
Example:
Accept: application/vnd.example.v1+json
Accept: application/vnd.example+json;version=1.0
In real world, an API is never going to be completely stable. It’s important how this change
is managed. A well-documented and gradual deprecation of API can be an acceptable
practice for most of the APIs.
4.3. Security
The points below may serve as checklist for designing secure RESTful APIs.
If you use HTTP 2, to improve performance – you can even send multiple requests over a
single connection, that way you avoid the complete TCP and SSL handshake overhead on
later requests.
Example:
14
Safe and Secure Truck Parking Study, API Design Guidelines
https://api.domain.com/user-
management/users/%7Bid%7D/someAction?apiKey=abcd123456789
Above URL exposes API key. Such form of security should be avoided.
This will prevent very basic replay attacks from people who are trying to brute force your
system without changing this timestamp.
4.5.1. Searching
A search is a sub-resource of a collection. As such, its results will have a different format
than the resources and the collection itself. This allows us to add suggestions, corrections,
and information related to the search.
Parameters are provided the same way as for a filter, through the query-string, but they are
not necessarily exact values, and their syntax permits approximate matching.
15
Safe and Secure Truck Parking Study, API Design Guidelines
4.5.2. Sorting
Sorting the result of a query on a collection of resources. A sort parameter should contain
the names of the attributes on which the sorting is performed, separated by a comma.
4.5.3. Filtering
Filtering consists in restricting the number of queried resources by specifying some
attributes and their expected values. It is possible to filter a collection on several attributes
at the same time and to allow several values for one filtered attribute.
4.5.4. Pagination
It is necessary to anticipate the paging of your resources in the early design phase of your
API. It is indeed difficult to foresee precisely the progression of the amount of data that
will be returned. Therefore, we recommend paginating your resources with default values
when they are not provided by the calling client, for example with a range of values [0-25].
5. Operational recommendations
5.1. Governance: updates and versioning
API specifications and versioning should be managed and published by a trusted entity.
The specification should include examples and a tool for testing the API. Furthermore, best
practices and SDK could be created for further facilitation of integrations.
16
Safe and Secure Truck Parking Study, API Design Guidelines
6. Conclusion
The present document is intended to assist parking service providers in designing and
developing their APIs in order to facilitate first of all development of user interfaces, such
as web and mobile (smartphone) apps, and secondly, integration with back office systems
such as fleet management systems, ERP and such.
The actual implementation is left to the parking service provider, and the present
guidelines should at least make the work of those implementing the API easier, and at the
same time help preserve parking system security and integrity.
The work could be complemented with an actual recommendation, or a reference model of
an implementation of such API. In order to create such model, several existing APIs would
need to be analysed and a solution that takes into account all relevant functionalities should
be presented. Such reference model would even more facilitate business uptake of smaller
parking service providers by lowering the cost and implementation time.
***
17