Query API

Fetch your Live Tail logs with a HTTP API.

Querying Live Tail returns rows based on your query. Each request returns a pagination.next url which you can query for more logs. Note that the URL contains a cursor query that works only when you don't change any query parameters, otherwise the behavior is not defined.

GET https://logs.betterstack.com/api/v1/query

Query parameters

source_ids
string
query
string
batch
integer
from
string
to
string
order
string

Headers

Authorization
required string
200

Response body

{
  "data": [
    {
      "app": "sample_app",
      "source_id": "123",
      "dt": "2022-07-19 12:28:14.000000",
      "event.http_request_received.port": null,
      "event.http_response_sent.status": null,
      "message": "Hello, world!",
      "level": "debug",
      "context.runtime.thread_id": "70039367973540",
      "context.system.pid": "14",
      "context.http.path": null,
      "context.http.method": null,
      "context.http.host": null,
      "context.http.remote_addr": null
    },
    {
      "app": "sample_app",
      "source_id": "123",
      "dt": "2022-07-19 12:28:14.000000",
      "event.http_request_received.port": null,
      "event.http_response_sent.status": null,
      "message": "Hello, world!",
      "level": "debug",
      "context.runtime.thread_id": "70182641597580",
      "context.system.pid": "14",
      "context.http.path": null,
      "context.http.method": null,
      "context.http.host": null,
      "context.http.remote_addr": null
    }
  ],
  "pagination": {
    "next": "https://logs.betterstack.com/api/v1/query?batch=100&cursor=MjE5PTI%3D&from=2022-07-18+12%3A29%3A14+UTC&order=newest_first&source_ids=123&to=2022-07-19+12%3A28%3A14+UTC"
  }
}

Example cURL

Example
curl --request GET \
  --url https://logs.betterstack.com/api/v1/query \
  --header "Authorization: Bearer $TEAM_TOKEN"