Judgment Labs Logo

Client methods

TypeScript JQL client methods, request options, and transport behavior.

judgeval-js JQL source on GitHub

Public methods

client.query(query, options?: { limit?: number; signal?: AbortSignal }): Promise<JqlQueryResponse>
client.present(presentation, options?: { limit?: number; signal?: AbortSignal }): Promise<JqlPresentationResponse>
client.discover(kind, options?: DiscoveryOptions & JqlRequestOptions): Promise<JqlQueryResponse>
MethodAccepted queryEndpoint behaviorReturns
querySource query, pipeline, or discovery queryExecutes structured JQLJqlQueryResponse
presentA .table(...) or .chart(...) resultExecutes the wrapped query and projects a renderer-neutral frameJqlPresentationResponse
discoverA documented discovery kind plus kind-specific optionsBuilds a discovery IR object, then delegates to queryJqlQueryResponse

Request option: limit

limit is an integer from 1 through 10,000, validated by the public API. When omitted, the SDK sends 10,000.

  • The request-envelope limit replaces any limit inside the JQL object — it is not a min(). Because the public API always sends one, an inner .rows(... limit ...) of 100 is widened to 10,000 unless you also set the method-level limit.
  • Set the method-level limit whenever you want a smaller result.
  • The envelope limit is ignored for terminals that do not produce a limitable result, such as count and agg.
  • client.discover forwards its limit only as the request cap. To set the IR-level discovery limit, build the discovery object directly and pass it to client.query.
  • An out-of-range limit is rejected as a 400 with error Validation failed, not BAD_QUERY.
  • signal is passed to fetch as an AbortSignal.

Transport

The SDK sends:

{
  "query": { "op": "query", "source": "traces", "select": { "op": "ids" } },
  "limit": 100
}

to the project-scoped query endpoint. present uses a separate /query/presentation endpoint; discover shares the query endpoint. The SDK supplies Authorization: Bearer <api key>, the X-Organization-Id header, and the resolved project ID as a path parameter. The public response never includes compiled SQL — it is stripped at the API boundary.

Use Responses and errors for the exact success and failure shapes.