Butlr Developer Docs
  • Welcome
  • What is Butlr
  • Spatial Metrics
  • Getting Started
    • Authentication
    • Making your first query
    • Mint Client Credentials
  • Changelog
  • Asset Management
    • GraphQL API Overview
      • Sites
      • Buildings
      • Floors
      • Rooms
      • Zones
      • Hives
      • Sensors
      • Asset Tags
    • GraphQL API Introsepction
  • Historical Occupancy
    • Reporting API Overview
      • Floor Occupancy
      • Room Occupancy
      • Zone Occupancy
      • Query Occupancy by Tag
      • Traffic
      • Presence Time
      • Statistic Overview
    • FAQs
  • Real-time occupancy
    • Webhooks Overview
      • Area Detections
      • Entryway Traffic
      • Floor Occupancy
      • Room Occupancy
      • Zone Occupancy
      • Motion Detection
      • No Motion Detection
    • Manage Webhooks
      • Create Webhooks
      • Update Webhooks
      • Delete Webhooks
      • List Webhooks
  • LINKS
    • Butlr Postman Collection
    • Butlr Website
    • Status
    • Support
    • Log In
Powered by GitBook
On this page
  • Get all buildings
  • Update building(s)
  1. Asset Management
  2. GraphQL API Overview

Buildings

You can use Butlr's GraphQL API to create, update, and retrieve information about buildings.

PreviousSitesNextFloors

Last updated 5 months ago

A building is an individual structure within a , comprising one or more floors. A site can have one or multiple buildings.

This page provides guidance on how to , , and , enabling streamlined management of building data and ensuring operational efficiency.

First, obtain an access token to get started .


Get all buildings

query allBuildings {
  buildings {
    data {
      id
      name
      capacity {
        max
        mid
      }
      floors {
        id
        name
        ...FloorFragment
      }
      buildingNumber
      address {
        lines
      }
      customID
      site {
        id
        name
        ...SiteFragment
      }
    }
  }
}

Code Examples

curl --location 'https://api.butlr.io/api/v3/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer [insert access_token here]' \
--data '{"query":"query allBuildings {\n  buildings {\n    data {\n      id\n      name\n      capacity {\n        max\n        mid\n      }\n      floors {\n        id\n        name\n      }\n      buildingNumber\n      address {\n        lines\n      }\n      customID\n      site {\n        id\n        name\n      }\n    }\n  }\n}","variables":{}}'
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.butlr.io/api/v3/graphql"
  method := "POST"

  payload := strings.NewReader("{\"query\":\"query allBuildings {\\n  buildings {\\n    data {\\n      id\\n      name\\n      capacity {\\n        max\\n        mid\\n      }\\n      floors {\\n        id\\n        name\\n      }\\n      buildingNumber\\n      address {\\n        lines\\n      }\\n      customID\\n      site {\\n        id\\n        name\\n      }\\n    }\\n  }\\n}\",\"variables\":{}}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer [insert access_token here]")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
import requests
import json

url = "https://api.butlr.io/api/v3/graphql"

payload = "{\"query\":\"query allBuildings {\\n  buildings {\\n    data {\\n      id\\n      name\\n      capacity {\\n        max\\n        mid\\n      }\\n      floors {\\n        id\\n        name\\n      }\\n      buildingNumber\\n      address {\\n        lines\\n      }\\n      customID\\n      site {\\n        id\\n        name\\n      }\\n    }\\n  }\\n}\",\"variables\":{}}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer [insert access_token here]'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)


Update building(s)

mutation updateBuildingInfo($input: UpdateBuildingInfoInput!) {
  updateBuildingInfo(input: $input) {
    building {
      id
      name
      capacity {
        max
        mid
      }
      floors {
        id
        name
      }
      buildingNumber
      address {
        lines
      }
      customID
      site {
        id
        name
      }
    }
  }
}

# Variables
{
    "input" : {
        "name": "example_building_updated_name",
        "id" : "building_2mAArGz8LmitbjThTYHYoRVciLY"
    }
}

Code Examples

curl --location 'https://api.butlr.io/api/v3/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer [insert access_token here]' \
--data '{"query":"mutation updateBuildingInfo($input: UpdateBuildingInfoInput!) {\n  updateBuildingInfo(input: $input) {\n    building {\n      id\n      name\n      capacity {\n        max\n        mid\n      }\n      floors {\n        id\n        name\n      }\n      buildingNumber\n      address {\n        lines\n      }\n      customID\n      site {\n        id\n        name\n      }\n    }\n  }\n}","variables":{"input":{"name":"example_building_updated_name","id":"building_2mAArGz8LmitbjThTYHYoRVciLY"}}}'
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.butlr.io/api/v3/graphql"
  method := "POST"

  payload := strings.NewReader("{\"query\":\"mutation updateBuildingInfo($input: UpdateBuildingInfoInput!) {\\n  updateBuildingInfo(input: $input) {\\n    building {\\n      id\\n      name\\n      capacity {\\n        max\\n        mid\\n      }\\n      floors {\\n        id\\n        name\\n      }\\n      buildingNumber\\n      address {\\n        lines\\n      }\\n      customID\\n      site {\\n        id\\n        name\\n      }\\n    }\\n  }\\n}\",\"variables\":{\"input\":{\"name\":\"example_building_updated_name\",\"id\":\"building_2mAArGz8LmitbjThTYHYoRVciLY\"}}}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer [insert access_token here]")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
import requests
import json

url = "https://api.butlr.io/api/v3/graphql"

payload = "{\"query\":\"mutation updateBuildingInfo($input: UpdateBuildingInfoInput!) {\\n  updateBuildingInfo(input: $input) {\\n    building {\\n      id\\n      name\\n      capacity {\\n        max\\n        mid\\n      }\\n      floors {\\n        id\\n        name\\n      }\\n      buildingNumber\\n      address {\\n        lines\\n      }\\n      customID\\n      site {\\n        id\\n        name\\n      }\\n    }\\n  }\\n}\",\"variables\":{\"input\":{\"name\":\"example_building_updated_name\",\"id\":\"building_2mAArGz8LmitbjThTYHYoRVciLY\"}}}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer [insert access_token here]'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
site
here
retrieve
create
update building information