Skip to main content

How to Get a List of Rooms

In this tutorial, we'll walk you through the steps to get a list of rooms using the Butlr API. To get started, you'll need an access token, which can be obtained by logging in.

Prerequisites​

Before proceeding with this tutorial, you'll need the following:

  • A Butlr account
  • An API access token

Step 1: Get an access token by logging in (more info)​

To get an access token, you'll need to log in to the Butlr API using your email and password. Here's the curl command to do so:

curl --location --request POST 'https://api.butlr.io/api/v2/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"username": "your@email.com",
"password": "your_password"
}'

Replace your@email.com and your_password with your email and password.

The response will contain your access token, which you'll need to include in subsequent requests.

Step 2: GraphQL query to get a list of rooms​

Once you have your access token, you can use it to make GraphQL queries to the Butlr API. Here's the GraphQL query to get a list of rooms:

{
rooms {
data {
client_id
floor_id
room_id
room_type

name
area {
unit
value
}
color
coordinates
capacity {
max
mid
}
}
}
}

This query will return a list of rooms, along with their associated data.

Step 3: Send the GraphQL query using curl​

To send the GraphQL query using curl, you'll need to include your access token in the Authorization header. Here's the curl command to do so:

curl --location --request POST 'https://api.butlr.io/api/v3/graphql' \
--header 'Authorization: Bearer INSERT_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"{\n rooms {\n data {\n client_id\n floor_id\n room_id\n room_type\n\n name\n area {\n unit\n value\n }\n color\n coordinates\n capacity {\n max\n mid\n }\n }\n }\n}","variables":{}}'

Replace INSERT_ACCESS_TOKEN with your access token.

Conclusion

In this tutorial, we walked you through the steps to get a list of rooms using the Butlr API. By following these steps, you should now be able to retrieve room data and use it in your applications.