lum_pub_test_... or lum_pub_live_...) is meant to be
embedded in a web page. It can only read data, only from the web origins you
list, and it carries its own abuse limits. Keep full and read keys on your
server: browsers on any website other than the Lumeus docs and dashboard
cannot read responses made with them (see CORS).
Create a publishable key
Create one in the dashboard under API keys, or from your server with a full key (the variables are set in the quickstart):
The response returns
api_key once, like other keys. GET /v1/keys lists the
type, origins and limits. PATCH /v1/keys/{id} changes the name,
allowed_origins, rate_limit_per_minute_per_ip or monthly_credit_cap
(send null to remove the cap). Revoke and rotate work as for other keys; a
rotated publishable key keeps its origins and limits.
Call the APIs from a page
The same key works on the Activity, Assets and RPC hosts of its network:Origin automatically. Lumeus checks it against the key:
- No
Origin, or one that is not inallowed_origins:403, and the browser cannot read the response. - An allowed origin: the response carries
Access-Control-Allow-Originwith that origin andVary: Origin.
Authorization; browsers cannot send X-API-Key cross-origin.
CORS
Which browser pages can read a response depends on the key:
Lumeus never allows credentials (cookies) or a wildcard origin, and every
response carries
Vary: Origin. A preflight (OPTIONS) answers 204 and
allows the Authorization, Content-Type, Idempotency-Key, If-Match,
If-None-Match and X-Request-Id request headers, cached for 600 seconds.
A page on an allowed origin can read these response headers, on errors too:
ETag, Link, Location, Retry-After, X-Request-Id,
X-Lumeus-Operation-Id, X-Lumeus-Idempotency, RateLimit-Limit,
RateLimit-Remaining and RateLimit-Reset.
So read Retry-After and X-Request-Id in your page as you would on a server.
What a publishable key can call
Everything else returns
403: Assets holders, holder rank and snapshots, any
as_of_ledger read, /v1/*, /billing/*, /operations/*, and RPC
sendTransaction and simulateTransaction, alone or in a batch. Call those
from your server with a secret key.
Limits and errors
The cap counts settled credits plus the worst-case cost of requests in flight.
Concurrent requests are admitted only while their worst cases fit under the
cap; when they do not, requests run one at a time, so usage passes the cap by at
most one request’s cost. A rotated key starts a new count.
What the origin check does not do
Origin is enforced by browsers. A script or server can send any Origin
header, so anyone who copies the key from your page can call the same read
routes from outside a browser. The origin list stops other websites from using
your key in their visitors’ browsers; it is not authentication. What bounds
misuse is the per-IP limit, the monthly credit cap and the read-only scope. Set
a cap you are comfortable paying for, keep the per-IP limit near what one
visitor needs, and rotate the key if you see unexpected usage in the
dashboard’s usage and request logs.