Skip to main content

How to Use the MyFarmbot Public API

This guide will teach you how to connect the MyFarmbot Public API to your own data using a RESTful API.

F
Written by Finlay Mitchell
Updated over 6 months ago

To better test this API, run the collection in Postman just by clicking the '> Run in Postman' button or you can visit our swagger documentation by clicking the link below.

πŸ‘€How to Get Enterprise Credentials: To request this info, reach out to our Customer Service team via email service@farmbot.com.au or phone 02 9901 4798

πŸ§‘πŸ»β€πŸŒΎHow to Get Support: For any support inquiries, reach out to our Customer Service team via email service@farmbot.com.au or phone 02 9901 4798

πŸ«±πŸ»β€πŸ«²πŸΎService Level Agreement: https://farmbot.com.au/service-levels-and-support/

1) Authorisation (Post):

  • In order to execute your public API transaction, you need to generate a bearer token using your credentials provided by MyFarmbot Support team.

  • Add this token to the headers of all your Public API calls under Authorization

auth-ur is https://fmbt-internal-production-ap-southeast-2.auth.ap-southeast-2.amazoncognito.com/

Get your Auth Token:

Authorisation (Basic Auth)

  • Username = <username>

  • Password = <password>

Headers

  • Content-Type = application/x-www-form-urlencoded

Body (urlencoded)

  • Scope = public-api/get-sensor-data

  • grant_type = client_credentials

public-api/v1 = To generate the token, execute the Authorisation POST request with the relevant credentials.

Authorisation (Bearer Token)

  • Token - this folder is using Bearer Token from folder public-api/v1

2) Returns all the Devices (Get):

Authorisation (Bearer Token)

  • This request is using Bearer Token from folder public-api/v1

Headers

  • Accept = application/json

Params

  • page = 1 (Should be the number of the page)

  • pageSize = 20 (Should be the number of items on each page. Min: 10, Max: 50)

  • order = DESC (Should be the order of the items in the list)

Example:

3) Returns a Specific Device (Get)

Authorisation (Bearer Token)

  • This request is using Bearer Token from folder public-api/v1

Headers

  • Accept = application/json

Path Variables

  • ID

Example:

Sites

Authorisation (Bearer Code)

  • This folder is using Bearer Token from folder public-api/v1

4) Returns all Enterprise Sites (Get)

Authorisation (Bearer Token)

  • This request is using Bearer Token from folder public-api/v1

Headers

  • Accept = application/json

Params

  • page = 1

  • pageSize = 20

  • order = DESC

Example:

5) Returns Specific Site (Get)

Authorisation (Bearer Token)

  • This request is using Bearer Token from folder public-api/v1

Headers

  • Accept = application/json

Example:

Sensor:

Authorisation (Bearer Token)

  • This folder is using Bearer Token from folder public-api/v1

Sensor List:

Authorisation (Bearer Token)

  • This folder is using Bearer Token from folder public-api/v1

6) Returns a List of Sensors (Get)

Authorisation (Bearer Token)

  • This request is using Bearer Token from folder public-api/v1

Headers

  • Accept = application/json

Params

  • page = 1 (Should be the number of the page)

  • pageSize = 20 (Should be the number of items on each page. Min: 10, Max: 50)

  • order = DESC (Should be the order of the items in the list)

  • sensorTypeIds = 1 (Should be a list of sensor types of IDs that exists in the database. Available values: 1 - Water tank, 2 - Electric fence, 3 - Rain gauge, 4 - Trough, 5 - Diesel tank, 6 - Pipe, 7 - Dam, 8 - Bore, 9 - Liquid fertiliser tank, 10 - Soil moisture, 11 - Soil temperature, 12 - Line pressure, 13 - Petrol tank, 14 - Camera, 15 - SOS staff, 16 - Check-in staff)

  • siteIds = Should be a list of site IDs that exist in the database example 46,100

Example:

{sensor Sid} and sample:

Authorisation (Bearer Token)

  • This folder is using Bearer Token from folder public-api/v1

7) Returns all the samples belongs to a sensor (Get)

Authorisation (Bearer Token)

  • This request is using Bearer Token from folder public-api/v1

Headers

  • Accept = application/json

Params

  • page = 1 (Should be the number of the page)

  • pageSize = 20 (Should be the number of items on each page. Min: 10, Max: 50)

  • order = DESC (Should be the order of the items in the list)

Path Variables

  • sensorSid = (Required) Should be an SID of a sensor that exists in the database.

Example:

8) Returns a Specific Sample (Get)

Authorisation (Bearer Token)

  • This request is using Bearer Token from folder public-api/v1

Headers

  • Accept = application/json

Path Variables

  • sensorSid = (Required) Should be an SID of a sensor that exists in the database.

  • id = (Required) Should be an SID of a sample that exists in the database.

9) Returns a Specific Sensor (Get)

Authorisation (Bearer Token)

  • This request is using Bearer Token from folder public-api/v1

Headers

  • Accept = application/json

Path Variables

  • sensorSid = (Required) Should be an SID of a sensor that exists in the database.

Example:

Notification

Authorisation (Bearer Token)

  • This folder is using Bearer Token from folder public-api/v1

10) Returns all the Notifications (Get)

Authorisation (Bearer Token)

  • This request is using Bearer Token from folder public-api/v1

Headers

  • Accept = application/json

Params

  • siteIds = Should be a list of site Ids

  • page = 1 (Should be the number of the page)

  • pageSize = 20 (Should be the number of items on each page. Min: 10, Max: 50)

  • order = DESC (Should be the order of the items in the list)

  • isAcknowledged = false

  • severity = 4

Example:

11) Returns a Specific Notification (Get)

Authorisation (Bearer Token)

  • This request is using Bearer Token from folder public-api/v1

Headers

  • Accept = application/json

Path Variables

  • id = (Required) Should be an ID of a notification that exists in the database.

Example:

Images

Authorisation (Bearer Token)

  • This folder is using Bearer Token from folder public-api/v1

12) Returns all Images of a Specific Camera (Get)

Authorisation (Bearer Token)

  • This request is using Bearer Token from folder public-api/v1

Params

  • page = 1

  • pageSize = 20

  • order = DESC

Path Variables

  • cameraId = 067a9ebe-26e6-47fd-961e-46c4769f0879


Example:

13) Returns a Specific Image (Get)

This request will return the image file, the user will have to download into local storage.

Authorisation (Bearer Token)

  • This request is using Bearer Token from folder public-api/v1

Path Variables

  • cameraId = 067a9ebe-26e6-47fd-961e-46c4769f0879

  • imageId = 4495

Example:

14) Health Controller Check (Get)

Authorisation (Bearer Token)

  • This request is using Bearer Token from folder public-api/v1

Headers

  • Accept = application/json

Example:

Did this answer your question?