API Reference
In addition to the HSDS Schemas, HSDS provides an API Reference to support standardising how systems provide read or read/write access to information on organizations, services, locations, and the details about them. This specification provides most of the functionality needed for simple access and exchange of data, and systems are encouraged to use it as a blueprint for implementing their own API platforms.
Unlike with the HSDS Schemas where we can provide canonical JSON Schema representations of the model, we are unaware of a comparable technology for specifying API compliance with this specification. We do provide a canonical reference formatted as OpenAPI specification which can be taken and used as a starting point. However, OpenAPI is designed for describing individual APIs rather than specifying the requirements for arbitrary API conformant to the specification. It also does not support describing the intended behavior for systems handing requests with multiple filter parameters.
To overcome this limitation, the API specification on this page uses the key words “MUST”, “REQUIRED” and “OPTIONAL” in accordance with RFC 2119 to describe whether each endpoint is required by the API Specification. This is used alongside the details of the canonical OpenAPI formatted reference file to measure compliance with the API Specification.
The current canonical HSDS API specification in OpenAPI 3.1 format is available at the following URL: https://raw.githubusercontent.com/openreferral/specification/3.2/schema/openapi.json
For those more familiar with tools such as SwaggerUI, we provide a Swagger UI representation. Readers should note that due to incompatibilities between Swagger UI and OpenAPI 3.1, the file powering the Swagger UI representation is compiled from the canonical HSDS API specification file. Therefore if there are any conflicts between the Swagger UI representation and the specification defined on this API Reference page, then this specification takes precedence.
If there are errors or omissions in this API specification, you are encouraged to raise issues on on the issue tracker.
Lists and Pagination
API endpoints that return lists of entities, such as services returned by a /services endpoint MUST be paginated. To support this, the HSDS API reference defines the Page schema:
Title |
Description |
Type |
Format |
Required |
|---|---|---|---|---|
total_items |
integer |
|||
None |
The total number of entities (e.g. services, organizations) returned |
|||
total_pages |
integer |
|||
None |
Count of total pages. |
|||
page_number |
integer |
|||
None |
The number of the current page |
|||
size |
integer |
|||
None |
The number of entities in the current page. |
|||
first_page |
boolean |
|||
None |
A Boolean value indicating if this is the first page |
|||
last_page |
boolean |
|||
None |
A Boolean value indicating if this is the last page |
|||
empty |
boolean |
Required |
||
None |
A Boolean value indicating if there is an empty result set |
|||
This acts as a header to all responses containing a list. Ideally, Responses will include all the properties from Page, as well as a contents property. contents is an array containing a list of the appropriate objects (e.g. Services).
Each item in contents will normally contain all its direct properties, but do not need to contain arrays of child entities (e.g. Service Contacts). This is to prevent response data becoming unreasonably large.
Please see the included example responses to see this in practice.
Query Parameters and Filters
Many API endpoints defined in this API reference contain query parameters allowing users to filter results by various dimensions. For example, calls to the /services endpoint can include a modified_after query parameter to only include results modified on or after the supplied value.
Query parameters are cumulative in their effect, behaving as a boolean AND where the results fulfill the conditions of all supplied query parameters. For example, the following query will produce results which match taxonomy_id=XXX AND organization_id=YYY:
/services?taxonomy_id=XXX&organization_id=YYY
All APIs wishing to comply with this specification MUST ensure that query parameters are cumulative in their effect.
Metadata
In HSDS each object has non-required metadata field containing a metadata object. Since some API responses can contain a list of many objects — each with their own nested objects — this could result in a large quantity of metadata in the response.
Therefore we wish to be explicit that including the metadata property in each object is OPTIONAL, and API implementors are responsible for considering what is an appropriate level of metadata to include in each response based on their use-case.
Endpoint details
This section contains details of each API endpoint. Each section presents an endpoint defined by the API and presents a technical reference for that endpoint including query parameters, status codes, and compliance rules for HSDS.
The / endpoint
This endpoint is REQUIRED for conforming APIs.
Response details
This API response will return a JSON object containing the following key/value pairs:
version(String) – HSDS version of this API.profile(URI) – The identifier for the HSDS profile used by this API. This MUST be a URL which resolves to a location where the information on the HSDS profile of this API is be found.openapi_url(URI) – URL of the openapi JSON file which defines this API.
The /services/{id} endpoint
This endpoint is REQUIRED for conforming APIs.
- GET /services/{id}
Retrieves a fully nested service with all related data with id.
Retrieve fully nested service with all related data with id.
- Parameters
id (string) – The id of the service that the request is intended to retrieve.
- Status Codes
200 OK – A Service matching the {id}, with all related data according to the HSDS Specification for Service.
Response details
This API response will return service data.
The /services endpoint
This endpoint is REQUIRED for conforming APIs.
- GET /services
Retrieves paginated listings of services that only have one-to-one fields in them.
Retrieve fully nested service with all related data with id.
- Query Parameters
search (string) – Full text search.
page (integer) – Page number of paginated result.
per_page (integer) – Number of results requested in a single page.
format (string) – Return results in the specified format. Default is json. Could be ndjson which should stream all the results without pagination.
taxonomy_term_id (string) – Search for records with particular taxonomy_term.
taxonomy_id (string) – Search for records which contain any term with this taxonomy.
organization_id (string) – Search for services which contain services that that this organization provides.
modified_after (string) – Return all results modified on or after this datetime.
minimal (boolean) – Return array of just service ‘id’ and ‘modified_date’. When using this parameter aim to return all services within one call.
full (boolean) – Return a fully nested service, service_at_location, or organization based on the request.
- Status Codes
200 OK – A paginated list of services that only have one-to-one fields in them.
- POST /services
Retrieves paginated listings of services that only have one-to-one fields in them.
Retrieve fully nested service with all related data with id.
- Query Parameters
search (string) – Full text search.
page (integer) – Page number of paginated result.
per_page (integer) – Number of results requested in a single page.
format (string) – Return results in the specified format. Default is json. Could be ndjson which should stream all the results without pagination.
taxonomy_term_id (string) – Search for records with particular taxonomy_term.
taxonomy_id (string) – Search for records which contain any term with this taxonomy.
organization_id (string) – Search for services which contain services that that this organization provides.
modified_after (string) – Return all results modified on or after this datetime.
minimal (boolean) – Return array of just service ‘id’ and ‘modified_date’. When using this parameter aim to return all services within one call.
full (boolean) – Return a fully nested service, service_at_location, or organization based on the request.
- Status Codes
200 OK – A paginated list of services that only have one-to-one fields in them.
The following compliance rules apply to this endpoint
Required by HSDS? Yes
Response details
This API response will return service data.
The /taxonomies/{id} endpoint
This endpoint is OPTIONAL for conforming APIs.
Response details
This API response will return taxonomy data.
The /taxonomies endpoint
This endpoint is OPTIONAL for conforming APIs.
- GET /taxonomies
Paginated listing of taxonomies.
Paginated listing of taxonomies.
- Query Parameters
search (string) – Full text search.
page (integer) – Page number of paginated result.
per_page (integer) – Number of results requested in a single page.
format (string) – Return results in the specified format. Default is json. Could be ndjson which should stream all the results without pagination.
- Status Codes
200 OK – Paginated listing of taxonomies.
- POST /taxonomies
Paginated listing of taxonomies.
Paginated listing of taxonomies.
- Query Parameters
search (string) – Full text search.
page (integer) – Page number of paginated result.
per_page (integer) – Number of results requested in a single page.
format (string) – Return results in the specified format. Default is json. Could be ndjson which should stream all the results without pagination.
- Status Codes
200 OK – Paginated listing of taxonomies.
Response details
This API response will return taxonomy data.
The /taxonomy_terms/{id} endpoint
This endpoint is OPTIONAL for conforming APIs.
Response details
This API response will return taxonomy terms data.
The /taxonomy_terms endpoint
This endpoint is OPTIONAL for conforming APIs.
- GET /taxonomy_terms
Paginated listing of taxonomy terms
Full information on a taxonomy term
- Query Parameters
search (string) – Full text search.
page (integer) – Page number of paginated result.
per_page (integer) – Number of results requested in a single page.
format (string) – Return results in the specified format. Default is json. Could be ndjson which should stream all the results without pagination.
taxonomy_id (string) – Search for records which contain any term with this taxonomy.
top_only (boolean) – Only retrieve taxonomy terms that have not child terms.
parent_id (string) – Recieve taxonomy terms that have a parent with this id.
- Status Codes
200 OK – Paginated listing of taxonomy terms
- POST /taxonomy_terms
Paginated listing of taxonomy terms
Full information on a taxonomy term
- Query Parameters
search (string) – Full text search.
page (integer) – Page number of paginated result.
per_page (integer) – Number of results requested in a single page.
format (string) – Return results in the specified format. Default is json. Could be ndjson which should stream all the results without pagination.
taxonomy_id (string) – Search for records which contain any term with this taxonomy.
top_only (boolean) – Only retrieve taxonomy terms that have not child terms.
parent_id (string) – Recieve taxonomy terms that have a parent with this id.
- Status Codes
200 OK – Paginated listing of taxonomy terms
Response details
This API response will return taxonomy terms data.
The /organizations/{id} endpoint
This endpoint is OPTIONAL for conforming APIs.
- GET /organizations/{id}
Fully nested organization with service array that contains simple information which could only contain the service.id.
Fully nested organization with service array that contains simple information which could only contain the service.id.
- Parameters
id (string) – The id of the organization that the request is intended to retrieve.
- Query Parameters
full_service (boolean) – Fully nested organization with service array that contains full service information.
- Status Codes
200 OK – Fully nested organization with service array that contains simple information which could only contain the service.id.
Response details
This API response will return organization data.
The /organizations endpoint
This endpoint is OPTIONAL for conforming APIs.
- GET /organizations
Paginated list of basic Organization information
Paginated list of basic Organization information.
- Query Parameters
search (string) – Full text search.
full_service (boolean) – Fully nested organization with service array that contains full service information.
full (boolean) – Return a fully nested service, service_at_location, or organization based on the request.
taxonomy_term_id (string) – Search for records with particular taxonomy_term.
taxonomy_id (string) – Search for records which contain any term with this taxonomy.
page (integer) – Page number of paginated result.
per_page (integer) – Number of results requested in a single page.
format (string) – Return results in the specified format. Default is json. Could be ndjson which should stream all the results without pagination.
- Status Codes
200 OK – Paginated list of basic Organization information.
- POST /organizations
Paginated list of basic Organization information
Paginated list of basic Organization information.
- Query Parameters
search (string) – Full text search.
full_service (boolean) – Fully nested organization with service array that contains full service information.
full (boolean) – Return a fully nested service, service_at_location, or organization based on the request.
page (integer) – Page number of paginated result.
per_page (integer) – Number of results requested in a single page.
format (string) – Return results in the specified format. Default is json. Could be ndjson which should stream all the results without pagination.
taxonomy_term_id (string) – Search for records with particular taxonomy_term.
taxonomy_id (string) – Search for records which contain any term with this taxonomy.
- Status Codes
200 OK – Paginated list of basic Organization information.
Response details
This API response will return organization data.
The /service_at_locations/{id} endpoint
This endpoint is OPTIONAL for conforming APIs.
- GET /service_at_locations/{id}
Retrieve fully nested service_at_location with all related data with specified id.
Retrieve fully nested service_at_location with all related data with specified id.
- Parameters
id (string) – The id of the service that the request is intended to retrieve.
- Status Codes
200 OK – Retrieve fully nested service_at_location with all related data with specified id.
Response details
This API response will return service at location data.
The /service_at_locations endpoint
This endpoint is OPTIONAL for conforming APIs.
- GET /service_at_locations
Retrieve paginated listings of service_at_location that only have one-to-one fields in them.
Retrieve paginated listings of service_at_location that only have one-to-one fields in them.
- Query Parameters
search (string) – Full text search.
taxonomy_term_id (string) – Search for records with particular taxonomy_term.
taxonomy_id (string) – Search for records which contain any term with this taxonomy.
organization_id (string) – Search for services which contain services that that this organization provides.
modified_after (string) – Return all results modified on or after this datetime.
full (boolean) – Return a fully nested service, service_at_location, or organization based on the request.
page (integer) – Page number of paginated result.
per_page (integer) – Number of results requested in a single page.
format (string) – Return results in the specified format. Default is json. Could be ndjson which should stream all the results without pagination.
postcode (string) – The postcode or zip code of a point used to check service coverage. If service_area is available, only return results where the postcode exists within the service_area. If proximity is provided, only show results within the proximity from the centroid of the postcode.
proximity (string) – Return services that exist within meters from the centroid of the provided postcode
- Status Codes
200 OK – Retrieve paginated listings of service_at_location that only have one-to-one fields in them.
- POST /service_at_locations
Retrieve paginated listings of service_at_location that only have one-to-one fields in them.
Retrieve paginated listings of service_at_location that only have one-to-one fields in them.
- Query Parameters
search (string) – Full text search.
taxonomy_term_id (string) – Search for records with particular taxonomy_term.
taxonomy_id (string) – Search for records which contain any term with this taxonomy.
organization_id (string) – Search for services which contain services that that this organization provides.
modified_after (string) – Return all results modified on or after this datetime.
full (boolean) – Return a fully nested service, service_at_location, or organization based on the request.
page (integer) – Page number of paginated result.
per_page (integer) – Number of results requested in a single page.
format (string) – Return results in the specified format. Default is json. Could be ndjson which should stream all the results without pagination.
postcode (string) – The postcode or zip code of a point used to check service coverage. If service_area is available, only return results where the postcode exists within the service_area. If proximity is provided, only show results within the proximity from the centroid of the postcode.
proximity (string) – Return services that exist within meters from the centroid of the provided postcode
- Status Codes
200 OK – Retrieve paginated listings of service_at_location that only have one-to-one fields in them.
Response details
This API response will return service at location data.