reservations-eapi icon

reservations-eapi

(0 reviews)

Compression

RDG have enabled support for compression within the reservations API. By including 'Accept-Encoding: gzip' within the request header the response content will be compressed before being returned. This improves performance time as it reduces the amount of data which has to be transferred.

Example headers in a request

POST https://api.nationalrail.co.uk/reservations/api/v1/availability HTTP/1.1
Accept-Encoding: gzip
Authorization: Bearer {{token}}
Connection: Keep-Alive
Content-Length: 2783
Content-Type: application/json
Host: api.nationalrail.co.uk
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

Response headers:

HTTP/1.1 200 OK
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=UTF-8
Date: Thu, 06 Jul 2023 15:36:56 GMT
Strict-Transport-Security: max-age=31536000; includeSubdomains;
Transfer-Encoding: chunked
x-ssl-client-verify: NONE
x-correlation-id: f047cb10-1c12-11ee-885e-06ff204a1d13
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block

The headers after indicate that the response content has been compressed (content-encoding: gzip).

Compressing the response content makes minimal difference to small responses, but for bigger responses it can improve the response time by as much as 50%. Most HTTP modules natively handle compressed responses, so whilst requesting them is optional RDG strongly recommend doing so wherever possible. If your systems cannot handle compressed content in the response then do not include the 'Accept-Encoding: gzip' header in the request.


Last update: 02-Aug-2024 15.05: ASSIST API Documentation Maintenance: 'reservations-eapi', Version 'v2', Page 'Compression', Revision 'A'.

To request updates to this text please contact Neil Barkham.


Reviews