Growbud Logo

API Quickstart

Get up and running with the Growbud API in minutes

Multiple Languages

Examples in JavaScript, Python, and cURL to match your tech stack

Get Credentials

Access the Growbud web app to generate API tokens

Full Documentation

Explore the complete API reference with interactive docs

Before You Start

You'll 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 [email protected] for simulation options to test the API.

Step-by-Step Code Examples

Follow these examples to integrate Growbud sensor data into your application. Choose your preferred programming language and copy the code snippets.

1

1. Install the SDK

First, install the necessary dependencies for making API requests.

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

2. Set up authentication

Configure your API credentials. Get your 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

Monitor your API balance in USD before making 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

Retrieve a list of 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

Retrieve sensor data for specific 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

Retrieve the most recent data for all 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

Retrieve 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

Modify threshold settings for a specific 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 [email protected]

Next Steps

Explore the Full API

View all available endpoints, request/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 & Analysis

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

Automated Alerts

Set up custom alerts when sensor values exceed thresholds using the latest endpoint.

Dashboard Integration

Display real-time sensor data in custom dashboards or existing monitoring systems.

IoT Automation

Trigger irrigation, climate control, or other systems based on sensor readings.

Need Help?

Our team is here to help you succeed with your integration.