OTAs: How to connect to Beds24 using API V2

From Beds24 Wiki
Revision as of 04:29, 23 October 2024 by Asher (talk | contribs)
Jump to navigation Jump to search


OTAs: How to connect to Beds24 using API V2
This page explains how OTAs can develop API connectivity with Beds24

1 Use case

You are an OTA, Booking Engine, or similar, and want to retrieve property, price and availability information from Beds24 to generate bookings which you then send back to Beds24.

Your developer develops the integration between your system and Beds24.

2 The Basics

It is a good idea to get a basic understanding of how Beds24 works.

We recommend going through this introduction and creating a test property with prices and any data you intend to use.

3 The API

Beds24 has two API versions, V1 and V2, we recommend using V2 for any new projects.

Documentation for API V2 is available here.

There is also interactive Swagger documentation. We recommend using Swagger to try the examples in this guide.

4 API V2 Authentication

API V2 uses refresh tokens which generate access tokens, these tokens will be included as headers in your requests in this format: "token: {token}"

To obtain a refresh token, first go the API page in the control panel and click the generate invite code button. Select the scopes you require then click the generate invite code button. You will now see an invite code on this page, you can copy this to your clipboard and use the GET /authentication/setup endpoint to exchange your invite code for a refresh token.

Request:

curl -X 'GET' \ 'https://beds24.com/api/v2/authentication/setup' \ -H 'accept: application/json' \ -H 'code: abc123'

Response:

{
  "token": "qEK5L...",
  "expiresIn": 86400,
  "refreshToken": "iexTC..."
}

In the above example, "token" is a short term access token that you will use to authenticate other API calls, "expiresIn" is how many seconds the token will last, finally you can use "refreshToken" to generate more tokens in the future.

Try making an invite code and exchanging it for a refresh token yourself with our Swagger page

5 Retrieving property data from Beds24

You can get properties from Beds24 using the GET /properties endpoint.

Try GETing properties with this request

curl -X 'GET' \ 'https://beds24.com/api/v2/properties' \ -H 'accept: application/json' \ -H 'token: 123...'

If successful, you should be able to see information about your properties in the JSON response.

In Swagger, try clicking the "schema" under POST /properties to see all the fields you can set using this endpoint.

By default not all property data will be returned, to include additional information in the response you can include parameters. For example, to include all of a property's room data in the response, add the parameter ?includeAllRooms=true to the request URL

curl -X 'GET' \ 'https://beds24.com/api/v2/properties?includeAllRooms=true' \ -H 'accept: application/json' \ -H 'token: 123...'

6 Price and availability

6.1 Calendar

GET /inventory/rooms/calendar can be used to retrieve per day price and availability information.

6.2 Availability

GET /inventory/rooms/availability can be used to retrieve the availability status of dates.

6.3 Offers

GET /inventory/rooms/offers can be used to retrieve offers based on specified criteria.

7 Bookings

POST /bookings can be used to send bookings to Beds24.