Hi
I am going to get messages for a specific device.
I tried to do it like this.

var device_params = JSON.stringify({"from":1614470400,"to":1614556799,"fields":"timestamp,position.latitude,position.longitude"})

const response = await axios({
        method: 'GET',
        url: https://flespi.io/gw/devices/{device_id}/messages,
        headers: {
          Authorization: FlespiToken ${FLESPI_API_TOKEN},
        },
        data: device_params
      })

But I am getting all messages for the device not filtered by device_params.
How can I get proper messages based on the device_params?

Thank you in advance.

    Could you explain to me more in detail?
    I can't find any filter field in the URL you sent me.

    Also, the above example I sent you in the first message is working in postman.

      meanking

      var device_params = JSON.stringify({
        "filter": "position.latitude,position.longitude",
        "fields": "timestamp,position.latitude,position.longitude",
        "from": 1613330400,
        "to": 1614556799
      })

        Thank you.
        Let me try

          Just I tried under your suggestion.
          But it is not restricted based on the timestamp.
          I need to filter based on from/to.

          This is the result of the whole message.
          😅
          Screenshot

            Ahh... You want to simplify the track? You can try to use generalize parameter for that (default value - 60 seconds). You can try for example"generalize": 20

              I tried this.
              const device_params = JSON.stringify({
              "filter": "position.latitude,position.longitude",
              "fields": "timestamp,position.latitude,position.longitude",
              "from": 1613330400,
              "to": 1614556799,
              "generalize": 60,
              })

              But the result is same. :(

                meanking Hmm try to play with generalize value to see changes. For example generalize: 600 to see one message in 10 minutes. But you should know that the generalize works only with time(timestamp).
                It does not take into account the proximity of coordinates, so if the device was constantly driving along the same route, you will see many similar tracks.
                You will not be able to make one from several tracks using just flespi api.

                  dexif
                  Seems you didn't understand what I want exactly.
                  I need to get messages from when to when. It is not the 60s or 600s.
                  It will be 1 day or 2 days.

                    Hmm. Ok then just use the "from/to" fields to get messages between two dates. But if you think that something going wrong on your account - just write us to integated chat on flespi.io. Then we can see if something is wrong.

                      dexif
                      As I said to you it is working in postman.
                      I think there is just a problem with my implementation.

                      Just there are 31 messages.
                      postman

                      But in my project, it returns 2000+ messages.
                      project

                        Ok. try this one.

                          var device_params = JSON.stringify({
                            'filter': 'position.latitude,position.longitude',
                            'fields': 'timestamp,position.latitude,position.longitude',
                            'from': 1613808230,
                            'to': 1614556799
                          })
                          const response = await axios.get(`https://flespi.io/gw/devices/${device_id}/messages`, {
                            headers: {
                              Authorization: `FlespiToken ${FLESPI_API_TOKEN}`
                            },
                            params: {
                              data: device_params
                            }
                          })

                        dexif
                        Thank you, it works as I expected.
                        👍️

                        I'm glad to hear that ;)

                          Write a Reply...