> For the complete documentation index, see [llms.txt](https://navixy.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://navixy.com/docs/navixy-api/user-api/resources/eco-fleet-api/resampling.md).

# Fuel data resampling

> Navixy Eco Fleet Lab has developed a solution for complex fuel data analysis. This method regenerates data sets which will be beneficial for a variety of exercises, enabling researchers, developers, and diagnostics experts to use the **processed data**.

**Diagnostic process** is an important procedure undertaken by numerous partners and investigators. Its primary purpose is to identify the underlying causes, which is essential for efficient fuel management by identifying any abnormalities. For example, they analyze key events - drains and refueling for fraud or look for a reason for the appearance of noise in the fuel data.

When partners or integrators incorporate fuel-related data into third-party systems for **further analysis and processing, including machine learning**, it can be highly effective in identifying behavioral patterns and detecting exceptions. This allows for more efficient investigations and enhances overall data processing capabilities.

Effective data management relies on **accurate and synchronized raw data**. However, inconsistencies in different data sets (i.e. position, speed, and fuel level) across various timeframes can pose challenges.

To tackle the challenges posed by incomplete or inconsistent data, we utilize advanced statistical models. With our API requests, you can easily **access and download processed datasets** from our platform for specific time periods. This API request specifically provides fuel-related data in a convenient CSV format.

> **Data resampling** refers to the joint process of creating a uniform data structure by organizing existing values and generating new ones (for missing values) in a chronological order, while considering equal time intervals. This approach ensures data integrity and facilitates analysis.

## data\_resampling

### Description

The API response is presented in a convenient CSV format, incorporating columns below:

* Time - timestamp (depending on the timezone the tracker is located)
* \[FUEL\_SENSOR\_NAME] - Fuel level (The column name is derived based on the sensor name. There could be more than 1 column)
* SPEED - object speed (km/h)
* MOVEMENT - movement status (0 - parking, 1 - moving, 2 - Idle)
* LNG - Longitude
* LAT - Latitude

**API path:** `/trackers/$tracker_id/resampling`, on the `/eco_fleet/v1` base path.

Additional list of resampling parameters

| name               | description                                                                                              | type   | format      |
| ------------------ | -------------------------------------------------------------------------------------------------------- | ------ | ----------- |
| data\_type         | Data type. Options: FUEL, SPEED,MOVEMENT, LNG, LAT                                                       | string | "SPEED"     |
| resampling\_method | Resampling method. Options: FOLLOWING, PREVIOUS, MEDIAN\_IN\_WINDOW, AVERAGE\_IN\_WINDOW, AVERAGE.       | string | "FOLLOWING" |
| delta              | Delta time in seconds. Has different meaning for different algorithms.                                   | int    | null/1      |
| fixed\_value       | A fixed value that will be used if no data is found in the interval. You can specify null or any number. | float  | nulll/5.5   |

**Description of resampling\_method**

* FOLLOWING - In this series, the subsequent value is utilized to substitute any missing values. Consequently, neighboring missing values are all substituted with the subsequent valid value. If there are any missing values at the end of the series, they are replaced with the preceding valid value. If delta is not null than algorithm changes: if the time interval \[T-Δ, T+0] contains at least one value, otherwise fixed\_value.
* PREVIOUS - The previous value in the series is utilized to substitute missing values. Consequently, the neighboring missing values are replaced with the earliest preceding valid value. If delta is not null than algorithm changes: if the time interval \[T-0, T+Δ] contains at least one value, otherwise fixed\_value.
* MEDIAN\_IN\_WINDOW - In this algorithm, the presence of delta is imperative. The average of all the neighboring values in the series within the interval \[T-Δ, T+Δ], fixed\_value if no values.
* AVERAGE\_IN\_WINDOW- In this algorithm, the presence of delta is imperative. The median of all the neighboring values in the series within the interval \[T-Δ, T+Δ], fixed\_value if no values.
* AVERAGE - To replace missing values in a series, we use the average of the two neighboring values. For any missing values between valid ones, we replace them with the average of the surrounding valid values. If the series begins or ends with missing values, we substitute them with the next or previous valid value accordingly. If delta is not equal to null than algorithm changes: if the interval \[T-Δ, T+Δ] contains at least one value, otherwise fixed\_value.

> We recommend utilizing distinct methods for varying data types, as outlined in the table below. However, the choice of which methods to employ ultimately depends on your individual needs and expectations.

| Method    | Data type            | Use case                                                                               |
| --------- | -------------------- | -------------------------------------------------------------------------------------- |
| Following | Ordered              | Data that is missing at the end of a time series or sequence, i.e Fuel, Movement       |
| Previous  | Ordered              | Data that is missing at the beginning of a time series or sequence, i.e Fuel, Movement |
| Median    | Evenly distributed   | Data that is not normally distributed, i.e. Fuel, Speed                                |
| Average   | Normally distributed | Data that is not evenly distributed, i.e. Fuel, Speed                                  |

Note that the response is CSV, not JSON, and that errors follow RFC 7807 problem details rather than the numeric `status.code` the Platform API uses.

## Resample fuel data

> Return fuel, speed, movement and location values resampled onto a uniform time grid, as CSV.\
> \
> Columns are \`Time\`, one column per fuel sensor named after that sensor, \`SPEED\` in km/h, \`MOVEMENT\` where 0 is parking, 1 is moving and 2 is idle, \`LNG\`, and \`LAT\`. A tracker with no fuel sensors returns the \`Time\` column alone.\
> \
> Timestamps follow the timezone the tracker is located in.

```json
{"openapi":"3.1.0","info":{"title":"Navixy Eco Fleet API","version":"0.1.0"},"tags":[{"name":"Eco Fleet","description":"Resampling fuel and movement data onto a uniform time grid, and scoring how noisy a fuel sensor's readings are."}],"servers":[{"url":"https://api.eu.navixy.com/eco_fleet/v1","description":"Navixy production server on European platform"},{"url":"https://api.us.navixy.com/eco_fleet/v1","description":"Navixy production server on American platform"},{"url":"https://api.me.navixy.com/eco_fleet/v1","description":"Navixy production server on Middle East platform"}],"security":[{"api_key":[]}],"components":{"securitySchemes":{"api_key":{"type":"apiKey","description":"Either a user session hash or an API key, with the \"NVX \" prefix, for example \"NVX 22eac1c27af4be7b9d04da2ce1af111b\". The same credential the Platform API uses.","name":"Authorization","in":"header"}},"schemas":{"ResamplingProp":{"type":"object","description":"How one data type should be resampled.","properties":{"data_type":{"type":"string","description":"Which series this applies to.","enum":["FUEL","SPEED","MOVEMENT","LNG","LAT"]},"resampling_method":{"type":"string","description":"How to fill a gap. `FOLLOWING` fills from the next known value, for data missing at the end of a series. `PREVIOUS` fills from the previous known value, for data missing at the beginning. `MEDIAN_IN_WINDOW` suits evenly distributed data that is not normally distributed. `AVERAGE_IN_WINDOW` and `AVERAGE` suit normally distributed data that is not evenly distributed.","enum":["FOLLOWING","PREVIOUS","MEDIAN_IN_WINDOW","AVERAGE_IN_WINDOW","AVERAGE"]},"delta":{"type":["integer","null"],"description":"Window size in seconds, where the method uses one."},"fixed_value":{"type":["number","null"],"description":"A constant to use instead of a computed value, where applicable."}},"required":["data_type","resampling_method"]}},"responses":{"Problem":{"description":"Error response, following RFC 7807 problem details. Note this is not the Platform API error shape: there is no `success` field and no numeric `status.code`.","content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string","description":"Error type identifier, for example `errors/entity/not-found`, `errors/external-api/navixy`, `errors/sensors/quality/not-enough-readings`, or `errors/default/unauthorized`. `about:blank` for generic HTTP errors."},"title":{"type":"string","description":"Short human-readable summary."},"status":{"type":"integer","description":"HTTP status code, repeated in the body."},"detail":{"type":"string","description":"What went wrong. For `errors/external-api/navixy` this carries the underlying Platform API code and message."},"instance":{"type":"string","description":"Path of the request that failed, relative to the base path."}}}}}}}},"paths":{"/trackers/{tracker_id}/resampling":{"post":{"tags":["Eco Fleet"],"summary":"Resample fuel data","description":"Return fuel, speed, movement and location values resampled onto a uniform time grid, as CSV.\n\nColumns are `Time`, one column per fuel sensor named after that sensor, `SPEED` in km/h, `MOVEMENT` where 0 is parking, 1 is moving and 2 is idle, `LNG`, and `LAT`. A tracker with no fuel sensors returns the `Time` column alone.\n\nTimestamps follow the timezone the tracker is located in.","operationId":"ecoFleetTrackerResampling","parameters":[{"name":"tracker_id","in":"path","required":true,"description":"ID of the tracker, also known as object_id. Must belong to the authorized user and must not be blocked.","schema":{"type":"integer"}},{"name":"interval","in":"query","required":false,"description":"Period to analyse, as an ISO 8601 interval. Defaults to the last week.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"step_size":{"type":"integer","description":"Resampling step in minutes."},"resampling_props":{"type":"array","description":"How to resample each data type.","items":{"$ref":"#/components/schemas/ResamplingProp"}}},"required":["step_size","resampling_props"]}}}},"responses":{"200":{"description":"Resampled series as CSV","content":{"text/csv":{"schema":{"type":"string"}}}},"400":{"description":"Bad request, or the period could not be parsed.","$ref":"#/components/responses/Problem"},"401":{"description":"No credential supplied. Type `errors/default/unauthorized`.","$ref":"#/components/responses/Problem"},"404":{"description":"Tracker not found. Type `errors/entity/not-found`.","$ref":"#/components/responses/Problem"},"502":{"description":"The Navixy Platform API could not be reached, or returned an error. Type `errors/external-api/navixy`, with the underlying code and message in `detail`.","$ref":"#/components/responses/Problem"},"default":{"$ref":"#/components/responses/Problem"}}}}}}
```

#### Errors

This API reports errors as RFC 7807 problem-detail strings, so the [general error codes](/docs/navixy-api/general/errors.md#error-codes) do not apply to it:

* `errors/entity/not-found` - if there is no tracker with such ID belonging to the authorized user.
* `errors/external-api/navixy` - error accessing the Navixy Platform API. The underlying numeric code and message arrive in the `detail` field, so this is where Platform API errors such as **204 Entity not found** and **208 Device blocked** surface, rather than as top-level codes of this API.
* `errors/default/unauthorized` - no credential supplied.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://navixy.com/docs/navixy-api/user-api/resources/eco-fleet-api/resampling.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
