# WebSockets vs get\_states API for real-time tracking data

## Question

WebSockets vs `tracker/get_states`. Which should I use for real-time tracking data?

## Answer

Developing third‑party software may require reading real-time tracking data. There are two main methods you can use:

* WebSockets
* `tracker/get_states` API method

In most cases, **WebSockets** is what you want to implement. WebSockets natively support real‑time connections for reading GPS-related device data.

The `get_states` method is more for getting the last known valid GPS data. However, if you can't use WebSockets in your application for some reason, you can set up polling for GPS data using `get_states`.

### WebSockets

Pros:

* Natively supports real‑time connections
* A fast and reliable way of getting real‑time tracking data
* Doesn't load the API in terms of requests per second (unlike polling)

Cons:

* May be harder to implement compared to a simple HTTP request API usage

### get\_states

Pros:

* Simple HTTP request

Cons:

* Doesn't support real‑time updates (requires polling)
* In a real‑time scenario, each API call loads the platform in terms of allowed requests per second

## Links

* [WebSocket](/docs/navixy-api/user-api/backend-api/websocket.md)
* [`tracker/get_states`](https://www.navixy.com/docs/navixy-api/user-api/backend-api/resources/tracking/tracker#get_states)


---

# Agent Instructions: 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:

```
GET https://navixy.com/docs/qna/apis/websockets-vs-get_states-api-for-real-time-tracking-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
