Queries
Fetch feature values via online query.
Chalk maintains several client libraries and a REST API for fetching feature values.
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.
Query for features in your favorite language.
> 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
Chalk supports a REST API for querying online features and exposes this endpoint in several API clients. When you execute an online query, resolvers will execute to produce the requested data. Online query will prioritize running online resolvers over offline resolvers to compute features if both are possible.
The following endpoint can also be hit with the python ChalkClient by using its query
method.
For information on how to authenticate the ChalkClient
, check out the section on
authentication.
Read more about the parameters to this method here.
inputsmap[string, 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[]
stalenessmap[string, duration]
contextQueryContext?
environmentstring?
tagsstring[]?
preview_deployment_idstring?
query_namestring?
branchstring?
More information on parameters is available here
dataFeatureResult[]
fieldstring
user.identity.has_voip_phone
.valuetypeof(field)?
errorChalkError?
metaFeatureResolutionMeta?
errorsChalkError[]?
metaQueryMeta?
include_meta
or explain
is set to True
.execution_duration_sfloat
deployment_idstring?
environment_idstring?
environment_namestring?
query_idstring?
query_timestampdatetime?
query_hashstring?
explain_outputstring?
explain
is set toTrue
.Chalk offers support for the user for when queries don’t work.
The first step is always to check to see the response contains any errors
.
Often, the error message will directly point to the failure.
In the case of more complicated queries, queries can be sent with explain=True
.
This will return a representation of the query plan in the meta
return attribute.
The user can use this information to verify the resolvers and operators ran during execution.
Beware, this will result in slower execution times.
Some queries that involve multiple operations might need additional tracking.
Users can supply store_plan_stages=True
to store intermediate outputs at all operations of the query.
This will dramatically slow things down, so use wisely!
These results are visible in the dashboard under the “Queries” page.
For more information, read the ChalkClient
docs here.