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