Why sync locally?
Lower latency
Serve quote data from your own database with no outbound API call in the critical path. Response times drop from hundreds of milliseconds to single-digit milliseconds.
Offline resilience
Your quoting tool keeps working during a network interruption. The local table is the source of truth for your application; HSD keeps it current.
SQL flexibility
Join HSD datasets against your own tables. Filter, sort, and aggregate using your database’s native query planner instead of URL parameters.
Predictable API usage
Sync runs on a schedule you control. You consume API budget in planned batches rather than at the mercy of unpredictable quote volume.
Available dataset keys
TheHsdDatasetKey type (exported from the SDK) defines the datasets available for sync:
Sync flow
The sync process follows five deterministic steps. The cursor is the key primitive — it is an opaque string that encodes the dataset version and position. Store it after every successful sync and pass it on the next delta call.Fetch a full snapshot
Call The snapshot response shape:
/api/v1/sync/snapshot with the dataset key and optional trade filter. The response contains all current records plus a cursor you will store for future delta calls.Store the cursor
Persist the cursor from
snapshot.sync.cursor to a durable store — your database, a config table, or a key-value store. The cursor is opaque; treat it as a string you pass back verbatim.Poll for changes with the cursor
On your scheduled interval (every 15–60 minutes is typical), read the stored cursor and call
/api/v1/sync/changes. If the server responds with HTTP 304 Not Modified (ETag match), there are no new changes and you can skip the remaining steps.Apply upserts and deletes
Iterate through
delta.changes and apply each operation to your local table. Three operation types are possible:| Operation | What to do |
|---|---|
upsert | Insert or update the record using record_id as the primary key |
delete | Remove the record with matching record_id from your local table |
supersede | Write the new payload over the old record; the old version is no longer authoritative |
Putting it together: a complete sync runner
Using ETags to skip no-op polls
The snapshot response includes anETag header. On subsequent requests, pass the value as If-None-Match. If the dataset has not changed, the server returns 304 Not Modified with no body — saving bandwidth and processing time.
API reference
Sync Snapshot
Full parameter list and response schema for
/api/v1/sync/snapshot.Sync Changes
Full parameter list and response schema for
/api/v1/sync/changes.