Perform HTTP requests to the FarmBot API.

Making requests

Making requests other than GET to the API will permanently alter the data in your account. Be especially careful making DELETE requests and POST requests to singular resources, like the /device endpoint, as the API will destroy data that cannot be recovered. Altering data through the API may cause account instability.

API endpoint list

Not sure which endpoint to access? Find the list here.

API endpoint documentation

Not sure what should be included in data updates? See the API docs here.

api_get(endpoint, database_id=None, payload=None)

Get information about a specific endpoint.

# Get info from an endpoint
peripherals = fb.api_get("peripherals")
# Get a specific resource by ID
peripheral = fb.api_get("peripherals", 12345)
# Get info from a singular endpoint
device = fb.api_get("device")

api_post(endpoint, payload=None)

Create new information contained within an endpoint.

# Add a new peripheral
new_peripheral = fb.api_post("peripherals", {
    "label": "LED",
    "pin": 13,
    "mode": 0,
})

api_patch(endpoint, payload, database_id=None)

Change information contained within an endpoint.

# Update a peripheral
updated_peripheral = fb.api_patch("peripherals", {
    "mode": 1,
}, 12345)

api_delete(endpoint, database_id, payload=None)

Delete information contained within an endpoint.

# Delete a peripheral
fb.api_delete("peripherals", 12345)

What’s next?