Farmforce API Documentation
Farmforce API Documentation
1.0 Overview
Farmforce provides an API for clients who wish to access data programmatically. For example, by selecting the view “Farmer”, the client can
retrieve a list of records containing farmer data, such as name, mobile number and village. Almost all Farmforce views are available through the
API (a list of available views is provided by the API itself).
The Farmforce API is based on the REST standard, where URLs represent data and actions on the data are performed using http verbs (such as
GET for retrieving data and POST for creating data). Any programming language capable of performing HTTPS requests can be used. Data
returned from API uses the JSON stardard, with UTF-8 encoding.
Clients using the API must be authenticated, by using a Farmforce username and password, and requests are rate-limited (currently the limit is 50
requests per hour).
In the rest of this guide, all example calls will assume we are using the following tenant URL:
https://test.farmforce.com/
GET https://test.farmforce.com/api/v0/views?format=json
The response will include the name of each view, along with the URL used to retrieve its data:
1 account_balances /api/v0/view/account_balances/
2 active-farmers /api/v0/view/active-farmers/
3 api_log /api/v0/view/api_log/
4 apipermission_changelog /api/v0/view/apipermission_changelog/
5 applets /api/v0/view/applets/
6 auth_group /api/v0/view/auth_group/
7 auth_user /api/v0/view/auth_user/
8 authorisation_for_chemical_applications /api/v0/view/authorisation_for_chemical_applications/
9 bin-card-example /api/v0/view/bin-card-example/
10 buyers /api/v0/view/buyers/
11 certification_states /api/v0/view/certification_states/
12 certifications /api/v0/view/certifications/
13 chemical_targets /api/v0/view/chemical_targets/
14 chemicals /api/v0/view/chemicals/
15 climate_conditions /api/v0/view/climate_conditions/
16 companies /api/v0/view/companies/
17 compliance_categories /api/v0/view/compliance_categories/
18 compliance_questions_ranking /api/v0/view/compliance_questions_ranking/
19 conflict_tickets_view /api/v0/view/conflict_tickets_view/
20 countries /api/v0/view/countries/
21 crop_categories /api/v0/view/crop_categories/
22 crop_protocol_templates /api/v0/view/crop_protocol_templates/
23 crop_varieties /api/v0/view/crop_varieties/
24 cropping_cycle_financials /api/v0/view/cropping_cycle_financials/
25 crops /api/v0/view/crops/
26 device_binary_view /api/v0/view/device_binary_view/
27 device_logs /api/v0/view/device_logs/
28 device_registry /api/v0/view/device_registry/
29 device_sync_sessions /api/v0/view/device_sync_sessions/
30 device_synccommandrequests /api/v0/view/device_synccommandrequests/
31 device_synchronization /api/v0/view/device_synchronization/
32 devices /api/v0/view/devices/
33 devices_unregistered /api/v0/view/devices_unregistered/
34 employers /api/v0/view/employers/
35 equipment /api/v0/view/equipment/
36 farm /api/v0/view/farm/
37 farmer_certifications /api/v0/view/farmer_certifications/
38 farmer_compliance /api/v0/view/farmer_compliance/
39 farmer_last_activity /api/v0/view/farmer_last_activity/
40 farmer_premiums /api/v0/view/farmer_premiums/
41 farmer_proposed_actions /api/v0/view/farmer_proposed_actions/
42 farmer_scorecard_analysis /api/v0/view/farmer_scorecard_analysis/
43 farmercertifications_fieldquotas /api/v0/view/farmercertifications_fieldquotas/
44 farmer-details-more /api/v0/view/farmer-details-more/
45 farmer-email /api/v0/view/farmer-email/
46 farmers /api/v0/view/farmers/
47 farmers_staff /api/v0/view/farmers_staff/
48 farmers-and-field /api/v0/view/farmers-and-field/
49 farming_operators /api/v0/view/farming_operators/
50 farms /api/v0/view/farms/
51 fertilizers /api/v0/view/fertilizers/
52 fftenant_messagereceivetrigger /api/v0/view/fftenant_messagereceivetrigger/
53 fftenant_messagetriggeraction /api/v0/view/fftenant_messagetriggeraction/
54 field_size_discrepancy /api/v0/view/field_size_discrepancy/
55 field_size_discrepancy_assumed /api/v0/view/field_size_discrepancy_assumed/
56 field-productivity.DashboardWidget /api/v0/view/field-productivity.DashboardWidget/
57 fields /api/v0/view/fields/
58 ga_costs /api/v0/view/ga_costs/
59 ga_equipment_cost /api/v0/view/ga_equipment_cost/
60 ga_operator_cost /api/v0/view/ga_operator_cost/
61 group_loans /api/v0/view/group_loans/
62 groups_view /api/v0/view/groups_view/
63 grower_and_harvest_information /api/v0/view/grower_and_harvest_information/
64 growing_activities_operator_view /api/v0/view/growing_activities_operator_view/
65 growing_activity_alerts /api/v0/view/growing_activity_alerts/
66 growing_activity_types /api/v0/view/growing_activity_types/
67 growth_stages /api/v0/view/growth_stages/
68 ha_costs /api/v0/view/ha_costs/
69 harvest_collection_bin_brands /api/v0/view/harvest_collection_bin_brands/
70 harvest_collection_bin_types /api/v0/view/harvest_collection_bin_types/
71 harvest_collection_containers /api/v0/view/harvest_collection_containers/
72 harvest_collection_locations /api/v0/view/harvest_collection_locations/
73 harvest_collection_types /api/v0/view/harvest_collection_types/
74 harvest_collections /api/v0/view/harvest_collections/
75 harvest_sale_per_farmer /api/v0/view/harvest_sale_per_farmer/
76 harvest_sales /api/v0/view/harvest_sales/
77 harvest_warehouse_view /api/v0/view/harvest_warehouse_view/
78 harvest-information /api/v0/view/harvest-information/
79 harvesting_activities_operator_view /api/v0/view/harvesting_activities_operator_view/
80 harvesting_activity_alerts /api/v0/view/harvesting_activity_alerts/
81 harvests_and_loans /api/v0/view/harvests_and_loans/
82 harvest-warehouse-summary /api/v0/view/harvest-warehouse-summary/
83 hc_weight_change_reasons /api/v0/view/hc_weight_change_reasons/
84 hc-bin-type-and-brand /api/v0/view/hc-bin-type-and-brand/
85 hs_per_field /api/v0/view/hs_per_field/
86 impersonator-log /api/v0/view/impersonator-log/
87 input_groups /api/v0/view/input_groups/
88 input_storage_warehouse_view /api/v0/view/input_storage_warehouse_view/
89 input_usage /api/v0/view/input_usage/
90 input_warehouse_inventory /api/v0/view/input_warehouse_inventory/
91 input-list-for-input-loans /api/v0/view/input-list-for-input-loans/
92 input-list-totals /api/v0/view/input-list-totals/
93 inventory_disposal_reason /api/v0/view/inventory_disposal_reason/
94 inventory_items /api/v0/view/inventory_items/
95 json_changelog /api/v0/view/json_changelog/
96 loan_products /api/v0/view/loan_products/
97 loan_repayments /api/v0/view/loan_repayments/
98 loans /api/v0/view/loans/
99 manufacturers /api/v0/view/manufacturers/
A call to retrieve a list of farmers would therefore have the following form:
Retrieving list of farmers
GET https://test.farmforce.com/api/v0/view/farmers/?format=json
There is a limit of records that can be retrieved in each call to the API, currently this limit is 500 records.
{"columns":
[
"Photo", "Farmer ID", "First Name", "Last Name", "Mobile Number",
"Certification ID", "Village", "Groups", "Farmer Tags", "Creation Date",
"Last Modified Date"
], "data":
[
{
"id": 4243,
"object": "+16185550103",
"row":
[
"", "PN3.1.13", "", "", "+16185550103", null, null, "", "",
"2013-11-26T09:36:14", "2013-11-26T09:36:14"
]
}, {
"id": 4252,
"object": "Cesaro Antonio",
"row":
[
"", "PN3.1.26", "Cesaro", "Antonio", "+14245550102", null, "Gansa",
"", "\"Maize\",\"detailed\",\"testing\"", "2015-07-14T11:37:41.403906",
"2016-02-09T16:45:46.193250"
]}, {
"id": 176,
"object": "Daniel Barasa",
"row":
[
"", "PN5*35*6", "Daniel", "Barasa", "+12095550101", null,
"Korkorla", "Insured farmers group", "\"detailed\"",
"2013-01-08T00:00:00", "2015-06-15T11:06:10.649198"
]
}
]
}
A response will contain a columns section with a single record containing the field names of the returned data and a data section with all the
respective records. Each record will have an id and an object field with a text representation of the record (this varies per view) and a row field
which will contain the actual data of the record corresponding to the field names in the columns section.
limit
Each API call can return a maximum of 500 records. However, we can define exactly how many records we wish to retrieve by setting the
limit in the Resource URI:
GET https://test.farmforce.com/api/v0/view/farmers/?format=json&limit=20
page
By default, each API call will return the 10 first records (or whatever the limit is set to) and this will be the first page of results. If we wish to
access the next page of records (11 to 20), we use the page option as follows:
GET https://test.farmforce.com/api/v0/view/farmers/?format=json&page=2
Default: 1
format
This is used to select one of the two available formats for returning data.
text filtering
We may filter the returning results by specifying values for text columns in the returning dataset. We can filter by searching an exact match
to a column, i.e. search for farmers with first name "Cesaro":
GET
https://test.farmforce.com/api/v0/view/farmers/?format=json&column_1_equ
als=Cesaro
or we can filter by a partial match, i.e. search for farmers with IDs that contain PN3.1:
GET
https://test.farmforce.com/api/v0/view/farmers/?format=json&column_0_con
tains=PN3.1
number filtering
If we want to filter by numeric columns, we can use the equals switch as in text filtering or we can use two additional switched, valid for
numbers only: greater_than and lesser_than. These can be used separetely (i.e. all harvest collections with balance greater or equal to 5)
or together to define a range (i.e. all harvest collections with balance between 1000 and 3000)
Number filtering
GET
https://test.farmforce.com/api/v0/view/harvest_collections/?format=json&
column_10_greater_than=20
GET
https://test.farmforce.com/api/v0/view/harvest_collections/?format=json&
column_10_greater_than=1000&column_10_lesser_than=3000