Skip to main content

Samplings

This API is to obtain samplings data created in the samplings feature.

Endpoints

sampling

GET /api/sampling

Returns an array with the samples according to the filters indicated in the query string.

One of the following parameters must be sent it in the query string:

  • field_id: ìnteger, field id
  • sampling_uuid: string, sampling uuid (if known)

Response

The following is the interface of an example response:

interface ApiSamplingI {
code: int
data: DataI[]
}

interface DataI {
groups: GroupI[]
yeargroup: number
created_at: string
field_id: number
zoning: {
info: {
map_id: string
}
type: string
}
analysis: {
[key: string]: AnalysisType[]
}
field_uuid: string
sampling_name: string
points: Point[]
group_assigned_id: number
sampling_uuid: string
closed_at: string | null
sample_set_uuid: string
}

interface GroupI {
samples: SampleI[]
group_data: {
sampling: {
color: string
name: string
}
}
group_uuid: string
}

interface SampleI {
code: string
spot_data: {
variables: VariableI[]
sampling: {
analysis: string
}
}
spot_uuid: string
}

interface VariableI {
name: string
value?: number
unit_id: number
}

interface AnalysisType {
name: string
unit_id: number
}

interface Point {
geometry: string
point_uuid: string
checked: number
created_at: string
group_uuid: string
}

analysis

GET /api/sampling/analysis

Returns an array with the analyzes and other sample data according to the filters indicated in the query string.

One of the following parameters must be sent in the query string:

  • field_id: ìnteger, field id
  • farm_id: ìnteger, farm id
  • sampling_uuid: string, sampling uuid (if known)

Response

The following is the interface of an example response:


interface SamplingAnalysisI {
code: number
data: DataI[]
}

interface DataI {
farm_id: number
field_id: number
zoning: ZoningI
analysis: AnalysisI
sampling_name: string
sampling_uuid: string
sample_set_uuid: string
}

interface ZoningI {
info: {
date: string // optional
layer: string // optional
operation: string // optional
hour: string // optional
provider: string // optional
map_id: string // optional
}
type: string
}

interface AnalysisI {
[key: string]: {
name: string
unit_id: number
}[]
}

Variables list

GET /api/sampling/variablelist

Returns a list of variables of the samples.

It is not necessary to send any parameters in the query string.

Response

The following is the response interface:

interface VariableListResponseI {
code: number
variablelist: Variablelist[]
}

interface Variablelist {
items: Item[]
list_name: string
variablelist_uuid: string
}

interface Item {
name: string
value: number
}

Upload a layer based on a sampling

Content-Type: application/json
POST /api/sampling/{sampling_uuid}/rasterize

This endpoint allows you to add a new layer based on the values of the sampling that you send in the url (sampling_uuid).

  • layers:Array contains an object per layer to create. This object contains the following properties:
    • analysis: name of the analysis.
    • variable_name: name of the variable.
    • layer_date: format of the date YYYY-MM-DDT00:00:00Z
    • layer_name: name of the layer
  • interpolation_polygon:Boolean if the value is false, interpolation is done by kriging; otherwise, interpolation is done by the polygon of the field or of the map referenced by the sampling.

Example of use:

{
"layers": [
{
"analysis": "0-20",
"variable_name": "MO",
"layer_date": "2024-11-26T16:29:31Z",
"layer_name": "MO_20"
}
],
"interpolation_polygon": false
}

Errors

These errors are specific to the samplings API, in addition to the general API errors.

codemsg
-11insufficient permissions