List API Events

MEGATRACKGPS SAS10 months ago

hello a cordial greeting I hope to be able to achieve a solution I am working on a design using API + React which I have a question regarding the events

only one event plus the ID is allowed to be read as shown in the traccar documentation

PATH PARAMETERS
id
required
integer

Example of a Successful Request for this via API

export const fetchEventById = async (token, eventId) => {
  try {
    const response = await traccarApi.get(`/events/${eventId}`, {
      headers: {
        Authorization: `Basic ${token}`,
      },
    });
    return response.data;
  } catch (error) {
    console.error(`Error al obtener el evento con id ${eventId}:`, error);
    throw error;
  }
};

But I Need To List All Events Or Recent Events Overall From All Devices

which is not allowed by the API that if it could be something like this

export const fetchAllEvents = async (token) => {
  try {
    const response = await traccarApi.get('/events', {
      headers: {
        Authorization: `Basic ${token}`,
      },
    });
    return response.data;
  } catch (error) {
    console.error('Error al obtener la lista de eventos:', error);
    throw error;
  }
};

Any solution that you can recommend to be able to list the events

Anton Tananaev10 months ago

Check the events report instead.

MEGATRACKGPS SAS10 months ago

I hadn't noticed that, I'm going to try it that way, I share my result, thank you Antom

MEGATRACKGPS SAS10 months ago

it worked that way, I still had to make other filters to be able to achieve the right result, thank you very much Antom for solving my doubt.

Resultado