Reading state views
A State View is state computed from events: a component’s evolve function folds the events its definition selects. Reading one renders it at a revision. See State Changes & State Views.
The examples use the TodoMVC example in a database of your own. Set it up first.
What a read names
Section titled “What a read names”- A State View and its version, such as
todo-listandv1. - A revision: a number, or
latest.latestredirects to the database’s current revision. - A binding for each parameter the view’s definition declares.
Over HTTP
Section titled “Over HTTP”curl -L "https://sandbox.evidentsource.com/api/v1/db/todomvc-yourname/latest/state-views/todo-list/v1"{"todos":[{"id":"3f0b5a0e-1c2d-4e5f-8a9b-0c1d2e3f4a5b","title":"Try EvidentSource","completed":false,"createdAt":"2026-09-17T00:00:00Z"}]}The reply is the view’s state, in the content type its definition declares: here, JSON. A view whose definition names a presenter is answered by that presenter instead: your Accept header is matched against the content types it offers, and a request it can’t satisfy is answered 406. A view whose state is a collection is read only through a presenter: without one, a read is refused with 409, code collection-needs-presenter.
Parameters
Section titled “Parameters”A view can select events by a value the reader supplies. single-todo selects the events whose subject is one todo’s id, so a read binds it:
curl -L "https://sandbox.evidentsource.com/api/v1/db/todomvc-yourname/latest/state-views/single-todo/v1?subject.todo_id=3f0b5a0e-1c2d-4e5f-8a9b-0c1d2e3f4a5b"A binding is {attribute}.{parameter}={value}, where the attribute is stream, subject or event_type. Each set of bindings is its own instance of the view: one todo, one account, one order. A query parameter without a . is passed to the view’s presenter, and is refused for a view that names none.
Reading the past
Section titled “Reading the past”A read at an earlier revision shows the view as it stood then. Use a revision number in place of latest:
curl "https://sandbox.evidentsource.com/api/v1/db/todomvc-yourname/1/state-views/todo-list/v1"A view whose definition folds in effective-time order is read at an effective-time cut, effective_time_end_at: a time, or now, which redirects to the time it resolved to. Such a view refuses a read without one, and its response reports the cut it applied in x-effective-time-end-at. TodoMVC’s views fold in revision order, so they take no cut, and ignore one. See Bi-temporal reads.
Caching
Section titled “Caching”A successful read at a revision carries Cache-Control: public, max-age=60, or private, max-age=60 when the request carries a credential or the server requires authentication, and a weak ETag. Send the tag back in If-None-Match and an unchanged view is answered 304 with no body. The redirects from latest and from an effective_time_end_at=now carry Cache-Control: no-store, since the next commit, or the clock, moves where they point. The body at the same URL can still change, for instance after the database is deleted and created again or the view’s snapshots are expired, which is why the cache lifetime is short.
Over gRPC and SDKs
Section titled “Over gRPC and SDKs”Call FetchStateViewAtRevision; see gRPC API. Each SDK wraps it; see Connecting with an SDK.
Following changes
Section titled “Following changes”There is no subscription to a State View. SubscribeDatabaseUpdates streams a database’s revision as it advances; render the view again at the revision it reports. Updates coalesce: a busy database or a slow client gets the latest revision, not one update per transaction.