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 sensors
  • Create sensor(s)
  • Update sensor(s)
  1. Asset Management
  2. GraphQL API Overview

Sensors

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

PreviousHivesNextAsset Tags

Last updated 4 months ago

A sensor can be associated with a , , or . This flexibility allows for effective monitoring across different areas, from general traffic at floor entrances to pinpointing specific occupancy locations within a zone.

This page provides guidance on how to , , and within an organization.

First, obtain an access token to get started .


Get all sensors

query allSensors {
  sensors {
      data {
          client_id
          floor_id
          room_id
          hive_id
          hive_serial
          sensor_id
          name
          mac_address
          mode
          model
          sensitivity
          center
          height
          orientation
          field_of_view
      }
  }
}

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 allSensors {\n  sensors {\n      data {\n          client_id\n          floor_id\n          room_id\n          hive_id\n          hive_serial\n          sensor_id\n          name\n          mac_address\n          mode\n          model\n          sensitivity\n          center\n          height\n          orientation\n          field_of_view\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 allSensors {\\n  sensors {\\n      data {\\n          client_id\\n          floor_id\\n          room_id\\n          hive_id\\n          hive_serial\\n          sensor_id\\n          name\\n          mac_address\\n          mode\\n          model\\n          sensitivity\\n          center\\n          height\\n          orientation\\n          field_of_view\\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 allSensors {\\n  sensors {\\n      data {\\n          client_id\\n          floor_id\\n          room_id\\n          hive_id\\n          hive_serial\\n          sensor_id\\n          name\\n          mac_address\\n          mode\\n          model\\n          sensitivity\\n          center\\n          height\\n          orientation\\n          field_of_view\\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)

Create sensor(s)

mutation createSensor($sensor: CreateSensorInput!) {
  createSensors(sensors: [$sensor]) {
    sensor_id
    name
    mac_address
  }
}

# Variables
{
  "sensor": {
    "name": "new_sensor_name",
    "mac_address": "placeholder_mac"
  }
}

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 createSensor($sensor: CreateSensorInput!) {\n  createSensors(sensors: [$sensor]) {\n    sensor_id\n    name\n    mac_address\n  }\n}","variables":{"sensor":{"name":"new_sensor_name","mac_address":"placeholder_mac"}}}'
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 createSensor($sensor: CreateSensorInput!) {\\n  createSensors(sensors: [$sensor]) {\\n    sensor_id\\n    name\\n    mac_address\\n  }\\n}\",\"variables\":{\"sensor\":{\"name\":\"new_sensor_name\",\"mac_address\":\"placeholder_mac\"}}}")

  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 createSensor($sensor: CreateSensorInput!) {\\n  createSensors(sensors: [$sensor]) {\\n    sensor_id\\n    name\\n    mac_address\\n  }\\n}\",\"variables\":{\"sensor\":{\"name\":\"new_sensor_name\",\"mac_address\":\"placeholder_mac\"}}}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer [insert access_token here]'
}

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

print(response.text)

Update sensor(s)

mutation updateSensors($sensor: UpdateSensorInput!) {
  updateSensors(sensors: [$sensor]) {
    client_id
    floor_id
    room_id
    hive_id
    hive_serial
    sensor_id
    name
    mac_address
    mode
    model
    sensitivity
    center
    height
    orientation
    field_of_view
  }
}

# Variables
{
  "sensor": {
    "sensor_id": "sensor_2k53witHHhYxj7iMK4qdefI5zoO",
    "name": "updated_sensor_name"
  }
}

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 updateSensors($sensor: UpdateSensorInput!) {\n  updateSensors(sensors: [$sensor]) {\n    sensor_id\n    name\n  }\n}","variables":{"sensor":{"sensor_id":"sensor_2k53witHHhYxj7iMK4qdefI5zoO","name":"updated_sensor_name"}}}'
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 updateSensors($sensor: UpdateSensorInput!) {\\n  updateSensors(sensors: [$sensor]) {\\n    sensor_id\\n    name\\n  }\\n}\",\"variables\":{\"sensor\":{\"sensor_id\":\"sensor_2k53witHHhYxj7iMK4qdefI5zoO\",\"name\":\"updated_sensor_name\"}}}")

  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 updateSensors($sensor: UpdateSensorInput!) {\\n  updateSensors(sensors: [$sensor]) {\\n    sensor_id\\n    name\\n  }\\n}\",\"variables\":{\"sensor\":{\"sensor_id\":\"sensor_2k53witHHhYxj7iMK4qdefI5zoO\",\"name\":\"updated_sensor_name\"}}}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer [insert access_token here]'
}

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

print(response.text)

floor
room
zone
here
retrieve
create
update sensor information