API Quickstart Guide
Developer Guide

API Quickstart

Connect to the Growbud API in a few minutes

Multiple languages

Examples in JavaScript, Python, and cURL

Get credentials

Open the Growbud web app to generate API tokens

Full documentation

Open the complete API reference with interactive docs

Before you start

You need:

  • A Growbud account (create one in the mobile app)
  • API credentials from growbud.app
  • At least one Growbud sensor linked to your account

No sensor yet? Email support@growbud.io for simulation options to test the API.

Step-by-step code examples

Use these examples to pull Growbud sensor data into your application. Choose a language and copy the snippets.

1

1. Install the SDK

Install the dependencies you need for API requests.

JS
1
2
3
npm install axios
# or
yarn add axios
2

2. Set up authentication

Set your API credentials. Get the API URL and token from the Growbud web app.

JS
1
2
3
4
5
6
7
8
// Save these in environment variables or a secure config file
const API_URL = 'YOUR_API_URL'; // Get from Growbud web app
const API_TOKEN = 'YOUR_API_TOKEN'; // Get from Growbud web app
const headers = {
'Authorization': `Bearer ${API_TOKEN}`,
'Content-Type': 'application/json'
};
3

3. Check your API balance

Check your API balance in USD before you make requests.

JS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
async function checkBalance() {
try {
const response = await axios.get(`${API_URL}/api/balance`, {
headers: headers
});
console.log('API Balance remaining: $' + response.data.balanceUsd);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
checkBalance();
4

4. List your sensors

List all sensors accessible to your account.

JS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const axios = require('axios');
async function listSensors() {
try {
const response = await axios.get(`${API_URL}/api/list-sensors`, {
headers: headers
});
console.log('Available sensors:', response.data.serialNumbers);
console.log('Balance remaining: $' + response.headers['x-api-balance-usd']);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
listSensors();
5

5. Query sensor data

Get sensor data for selected devices over a time period.

JS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
async function querySensorData() {
try {
const params = {
duration: 24, // Last 24 hours
serialNumbers: '[E200201B,E2002022]', // Your sensor serial numbers
format: 'json' // or 'csv'
};
const response = await axios.get(`${API_URL}/api/query`, {
headers: headers,
params: params
});
// Process the data for each sensor
for (const [sensorId, sensorData] of Object.entries(response.data)) {
console.log(`\nSensor ${sensorId}:`);
console.log('Fields:', sensorData.metadata.fields);
console.log('Units:', sensorData.metadata.units);
// Get latest reading
if (sensorData.data && sensorData.data.length > 0) {
console.log('Latest reading:', sensorData.data[sensorData.data.length - 1]);
}
}
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
querySensorData();
6

6. Get latest sensor readings

Get the most recent data for your sensors.

JS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
async function getLatestReadings() {
try {
const params = {
maxAge: 2 // Maximum age in days (1-8)
};
const response = await axios.get(`${API_URL}/api/latest`, {
headers: headers,
params: params
});
// Process each sensor's latest data
response.data.forEach(sensor => {
console.log(`\nSensor: ${sensor.name} (${sensor.serialNumber})`);
console.log(`Last seen: ${sensor.lastSeen}`);
console.log(`Online: ${sensor.isOnline}`);
console.log(`VWC: ${sensor.data.soil_vwc}%`);
console.log(`EC: ${sensor.data.pore_ec} mS/cm`);
console.log(`Temperature: ${sensor.data.air_temp}°F`);
console.log(`VPD: ${sensor.data.vpd} kPa`);
});
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
getLatestReadings();
7

7. Get sensor thresholds

Get threshold settings for your sensors and zones.

JS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
async function getThresholds() {
try {
// Get thresholds for specific sensors
const params = {
serialNumbers: '[E200201B,E2002022]',
includeZones: 'true' // Set to 'true' to include zone thresholds
};
const response = await axios.get(`${API_URL}/api/thresholds`, {
headers: headers,
params: params
});
// Process threshold data
response.data.forEach(item => {
if (item.serialNumber) {
console.log(`\nSensor: ${item.name} (${item.serialNumber})`);
} else if (item.zoneId) {
console.log(`\nZone: ${item.zoneName}`);
}
console.log('Thresholds:', JSON.stringify(item.thresholds, null, 2));
console.log('Grow Media:', item.growMedia);
});
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
getThresholds();
8

8. Update sensor thresholds

Change threshold settings for one sensor.

JS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
async function updateThresholds() {
try {
const thresholdData = {
serialNumber: "E200201B",
thresholds: {
air_temp: { min: 32, max: 120, low: 70, good: 80 },
humidity: { min: 0, max: 100, low: 60, good: 70 },
soil_vwc: { min: 0, max: 100, low: 60, good: 75 },
pore_ec: { min: 0, max: 15.0, low: 1.0, good: 2.0 },
vpd: { min: 0, max: 10, low: 0.9, good: 1.2 }
}
};
const response = await axios.put(
`${API_URL}/api/thresholds`,
thresholdData,
{ headers: headers }
);
console.log('Update result:', response.data);
console.log('Balance remaining: $' + response.headers['x-api-balance-usd']);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
updateThresholds();
9

9. Batch update thresholds

Update thresholds for multiple sensors and zones in one request.

JS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
async function batchUpdateThresholds() {
try {
const batchData = {
updates: [
{
serialNumber: "E200201B",
thresholds: {
air_temp: { min: 32, max: 120, low: 70, good: 80 },
humidity: { min: 0, max: 100, low: 65, good: 75 }
}
},
{
serialNumber: "E2002022",
thresholds: {
soil_vwc: { min: 0, max: 100, low: 55, good: 70 },
pore_ec: { min: 0, max: 15.0, low: 1.5, good: 2.5 }
}
},
{
zoneId: "Zone 1",
thresholds: {
vpd: { min: 0, max: 10, low: 0.8, good: 1.1 }
}
}
]
};
const response = await axios.put(
`${API_URL}/api/thresholds/batch`,
batchData,
{ headers: headers }
);
console.log('Batch update result:', response.data);
console.log('Status:', response.status === 200 ? 'All successful' : 'Partial success');
// Check individual results
response.data.results.forEach(result => {
const id = result.serialNumber || result.zoneId;
console.log(`${id}: ${result.success ? 'Success' : 'Failed'} - ${result.message}`);
});
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
batchUpdateThresholds();

?Next Steps

Explore the API Reference

Browse all available endpoints and their schemas below

Monitor API Balance

Check the X-API-Balance-USD header in responses

Handle Errors Gracefully

Implement proper error handling for 4xx and 5xx responses

Need Help?

Contact support@growbud.io

Next Steps

Explore the full API

View all endpoints, request and response schemas, and advanced features.

View API Reference

Monitor your usage

Track API credits, view analytics, and manage tokens in the web app.

Open Web App

Common use cases

Data logging and analysis

Pull historical data into spreadsheets or databases for trend analysis and reporting.

Automated alerts

Raise custom alerts when sensor values pass thresholds. Use the latest endpoint.

Dashboard integration

Show live sensor data in custom dashboards or existing monitoring systems.

IoT automation

Trigger irrigation, climate control, or other systems from sensor readings.

Need help?

Our team can help with your integration.