> For the complete documentation index, see [llms.txt](https://docs.iotex.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.iotex.io/blockchain/ecosystem/powered-by-iotex-devices/pebble-tracker/query-pebble-data.md).

# Query Pebble Data

Pebble Tracker will send data messages to either the Mainnet or the Testnet of the Real-World Oracle, depending on the [firmware configuration](broken://pages/eHdubKNJVxJ2fhF6mb6x). All data messages can be fetched from the Oracle network by querying the following endpoints using GraphQL.

## Mainnet endpoint

Use the GraphQL endpoint below to query the Real-world Data Oracle Mainnet:

[-> https://pebble.iotex.me/v1/graphql ](<https://pebble.iotex.me/v1/graphql >)

## Testnet Endpoint

Use the GraphQL endpoint below to query the Real-world Data Oracle Testnet:

[-> https://dev.iotex.io/v1/graphql](https://dev.iotex.io/v1/graphql)

## Example queries

You can use a public GraphQL endpoint like <https://tray.io/docs/api/sandbox> to test some queries:

### List devices owned by a specific account

```graphql
query {
      pebble_device (limit: 10, where: {owner: {_eq: "0x259c0a4251ee7CD3cbA0a437973443c9C7cd2D4f"} }) {
        id
        owner
      }
    }
```

**Result**:

```json
{
  "data": {
    "pebble_device": [
      {
        "id": "351358810263431",
        "owner": "0x259c0a4251ee7CD3cbA0a437973443c9C7cd2D4f"
      },
      {
        "id": "351358813374789",
        "owner": "0x259c0a4251ee7CD3cbA0a437973443c9C7cd2D4f"
      }
    ]
  }
}
```

### Query additional device data

```graphql
query  {
  pebble_device (limit: 1, where: {owner: {_eq: "0x259c0a4251ee7CD3cbA0a437973443c9C7cd2D4f"} }) {
    id
    name
    owner
    address
    firmware
    avatar
    beep
    config
    configurable
    created_at
    data_channel
  }
}
```

Result:

```json
{
  "data": {
    "pebble_device": [
      {
        "id": "351358810263431",
        "name": "My Living Room",
        "owner": "0x259c0a4251ee7CD3cbA0a437973443c9C7cd2D4f",
        "address": "0x6ff4142596AaD08e95362EA9b4e03c50645E187a",
        "firmware": "Riverrock 1.0.8",
        "avatar": "https://storageapi.fleek.co/uu-z-team-bucket/b7a5acf3-c513-4279-944b-72f4dbf17e8c",
        "beep": 1000,
        "config": null,
        "configurable": false,
        "created_at": "2022-01-06T16:45:40.118+00:00",
        "data_channel": 8183
      }
    ]
  }
}
```

### Query the most recent datapoint with valid GPS for a device

```graphql
query  {
  pebble_device_record(limit: 1,  order_by: {timestamp: desc}, where: {imei: {_eq: "351358810263431"}, latitude: {_neq: "200.0000000"}}) {
      latitude, longitude, timestamp
    }
}
```

Result:

```graphql
{
  "data": {
    "pebble_device_record": [
      {
        "latitude": "45.4799999",
        "longitude": "9.1500000",
        "timestamp": 1641854726
      }
    ]
  }
}
```


---

# 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://docs.iotex.io/blockchain/ecosystem/powered-by-iotex-devices/pebble-tracker/query-pebble-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.
