Chalk home page
Docs
API
CLI
  1. Online Queries
  2. Overview

Chalk support a REST API for querying online features and exposes this endpoint in several API clients. When you execute an online query, online resolvers will execute to produce the requested data.

Request

POST
https://api.chalk.ai/v1/query/online
Attributes
inputsmap[string, JSON]
Input features are the features that you provide at the time of making a request. For example, you likely want to provide the primary key of the feature sets you are querying. Feature inputs are provided by fully qualified path, rooted in the same feature namespace. Has many featuresare input as lists, and struct features are input as Json.

An example of passing a user with two credit cards as input: {user.id: '1', user.cards: [card.id: 'xyz', card.id:'abc']}

outputsstring[]
Outputs are the features that you'd like to compute from the inputs.
stalenessmap[string, duration]
Maximum staleness overrides for any output features or intermediate features. See query caching for more information.
contextQueryContext?
The context object controls the environment and tags under which a request should execute resolvers:
QueryContext
environmentstring?
The environment under which to run the resolvers. Like resolvers, API tokens can be scoped to an environment. If no environment is specified in the query, but the token supports only a single environment, then that environment will be taken as the scope for executing the request.
tagsstring[]?
The tags used to scope the resolvers.
deployment_idstring?
The preview deployment id. See Preview Deployments for more information.
query_namestring?
The query name. Information about Named Queries is available in the dashboard.

Response

Attributes
dataFeatureResult[]
The outputs features and any query metadata
FeatureResult
fieldstring
The name of the feature requested, eg. user.identity.has_voip_phone.
valuetypeof(field)?
The value of the requested feature. If an error was encountered in resolving this feature, this field will be empty.
errorChalkError?
The error code encountered in resolving this feature. If no error occurred, this field is empty.
tstimestamp
The time at which this feature was computed. This value could be significantly in the past if you're using caching.
errorsChalkError[]?
Errors encountered while running the resolvers. Each element in the list is a ChalkError. If no errors were encountered, this field is empty.

Library support

Chalk maintains libraries in several major languages for fetching online feature values. If you need support for a language that we don’t support, let us know! We also support a rest API if you’d like to build your own.

> chalk query \
      --in user.id=1 \
      --out user.identity.is_voip_phone \
      --out user.fraud_score \
      --staleness user.account_balance=10m \
      --environment staging \
      --tag live