> 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/qna/apis/websockets-vs-get_states-api-for-real-time-tracking-data.md).

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

Use WebSockets for real-time GPS data streaming without polling overhead. Use get\_states only if WebSockets unavailable in your environment

## 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/websocket.md)
* [`tracker/get_states`](https://navixy.com/docs/navixy-api/user-api/resources/tracking/tracker#post-tracker-get_states)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
