Skip to content

Search with availabilities

Search with availabilities provides the functionality to receive a list of availabilities together with product or place meanwhile a lot of capabilities of search endpoint such as searching, filtering, etc. were used.

Search with availabilities samples

Get availabilities for restaurant

Getting availabilities for restaurants might be useful when it's necessary to display which restaurant is available according to the search criteria and date range.

link:

https://api.discover.swiss/info/v2/search

headers:

{
    "Accept-Language": "en"
}

body:

{
  "searchFields": "name",
  "searchText": "discover.swiss",
  "select":"name",

  "type": "FoodEstablishment",
  "productAvailability": [
      {
          "dateFrom": "2024-10-14",
          "dateUntil": "2024-10-16",
          "onDemand": true,
          "forType": "FoodEstablishment"
      }
  ],
  "onlyWithAvailabilities": true
}
{
  "count": 1,
  "values": [
    {
      "type": "FoodEstablishment",
      "name": "discover.swiss Bar",
      "productAvailability": [
        {
          "identifier": "exp_act_3a465a26-f47c-4453-9c0a-68bb21b32322",
          "date": "2024-10-14T00:00:00+00:00",
          "lastModified": "2024-10-01T13:25:12.5549334+00:00",
          "count": 997,
          "service": "exp-ds"
        },
        {
          "identifier": "exp_act_ebe0b7f3-e997-4862-9865-8564db105ad6",
          "date": "2024-10-14T00:00:00+00:00",
          "lastModified": "2024-10-01T13:25:12.5565811+00:00",
          "count": 20,
          "service": "exp-ds"
        },
        ...
      ]
    }
  ]
}

Get availabilities for hostel

Getting availabilities for hostel might help to find a hotel which corresponds to search criteria and is available for booking of specific date range.

link:

https://api.discover.swiss/info/v2/search

headers:

{
    "Accept-Language": "en"
}

body:

{
  "resultsPerPage": 100,
  "searchText": "Zürich",
  "select": "type,identifier,name",
  "project": [
    "sjh-web"
  ],
  "type": "LodgingBusiness",
  "combinedType": "Hostel",
  "productAvailability": [
    {
      "dateFrom": "2024-10-14",
      "dateUntil": "2024-10-30",
      "onDemand": false,
      "forType": "LodgingBusiness"
    }
  ],
  "onlyWithAvailabilities": false,
  "facets": []
}
{
  "count": 2,
  "values": [
    {
      "identifier": "log_8zx-tdgf_geethahg-vvqj-usbb-jidv-aacceiieists",
      "type": "LodgingBusiness",
      "name": "Jugendherberge Zürich",
      "productAvailability": [
        {
          "identifier": "sjh-assd_020_008038_acc",
          "date": "2024-10-13T22:00:00+00:00",
          "lastModified": "2024-09-30T07:03:45.2062081+00:00",
          "count": 420,
          "service": "sjh-020-acc"
        },
        ...,
        {
          "identifier": "sjh-assd_020_008038_acc",
          "date": "2024-10-28T23:00:00+00:00",
          "lastModified": "2024-09-30T07:03:45.3361112+00:00",
          "count": 502,
          "service": "sjh-020-acc"
        }
      ]
    },
    {
      "identifier": "log_px9-s28_bcch",
      "type": "LodgingBusiness",
      "name": "Zurich Youth Hostel"
    }
  ]
}

Multiple poduct availabilty request

Search allows the specification of multiple product availability requests in the same request. It makes it possible to specify multiple date ranges in same search request.

Filtering by place type

forType property in the availability request has the value "Product" we check availabilities for all products in the search response, on any other value we search for availability for locations as areaServed of products. If it is necessary to filter by place type use search filters.

{
  "productAvailability": [
    {
      "dateFrom": "2024-10-14",
      "dateUntil": "2024-10-16",
      "onDemand": false,
      "forType": "LodgingBusiness"
    },
    {
      "dateFrom": "2024-10-20",
      "dateUntil": "2024-10-26",
      "onDemand": true,
      "forType": "Product"
    }
  ],
  "onlyWithAvailabilities": true
}

On demand and cached availabilities

There are two ways to receive availabilities:

  • On-demand availabilities
  • Cached availabilities

Cached availabilities make search requests faster, but they don't guarantee that the requested entity is available at current moment.

On the opposite side, there are "on-demand" availabilities which are requested directly from the data provider and contain the most relevant information about availability.

Use onDemand property to specify which type of availabilities are requested.

Facets with availabilities

In search request with availabilities facets can be received just in a regular way as it is described here.

But they will be present only when onlyWithAvailabilities parameter has false value.