Publish an API and call it
APIM 1 · 3:25
An HTTP service goes public through the hub's API gateway, and the first call returns its JSON. Publishing needs three documents, and the gateway lets no call through until a subscription allows it.
What it covers
- The API, version and deployment documents for
invoices, a proxy to the upstream service - Publishing to production with one
weikio apply, the deployment document included - An anonymous subscription for a first look
- A call to
api.example.comforwarded through the gateway to the upstream service - How the URL is built from the host name, the prefix, the version and the path
- The API's page in the admin UI, with its versions and subscriptions
Commands in this video
Terminal
$ weikio apply -f ./finance/apis/
$ weikio subscription create finance/first-look --env production --api invoices --type anonymous
$ curl http://api.example.com/invoices/1.0/orders/42Transcript
- 0:02This video publishes an API and calls it.
- 0:05The hub's API gateway serves any HTTP service;
- 0:10the upstream is the address the author writes.
- 0:16The hub is running, with the project finance.
- 0:19Production is live on api.example.com, and orders-api runs in production.
- 0:26No API is published yet.
- 0:34The API is three YAML documents in the finance folder, applied like everything else.
- 0:40The first names it: an API called invoices, served under the prefix invoices.
- 0:47The second is version 1.0, of type proxy:
- 0:51the gateway forwards the call to the upstream.
- 0:54Its cluster names the upstream's address, and the third deploys it to production.
- 1:04Applying is the whole publish.
- 1:07The hub stores the documents and turns them into the gateway's routing on the spot.
- 1:12One row per document, and the last line says the gateways were updated.
- 1:17Without the deployment, no gateway serves it.
- 1:22Nothing is open by default: a subscription says who may call.
- 1:27This one is anonymous: anyone on the host name can call, for a first look.
- 1:32Production asks before it changes, and a yes creates it.
- 1:36A real caller with a key comes in video two.
- 1:45Now a caller dials the public URL.
- 1:48The gateway matches the host and the path, and forwards the call to the upstream.
- 1:54The upstream receives the path below the version,
- 1:57so orders/42 reaches the orders route.
- 2:01The answer comes back through the gateway, and the caller gets the JSON.
- 2:09The URL is the host name, the prefix, the version and the path.
- 2:14api.example.com is production's own host name; the admin set it once.
- 2:21The prefix picks the API, the version picks which version answers,
- 2:26and the rest is the path the upstream sees.
- 2:34The admin UI keeps a page for the API.
- 2:38Its overview lists version 1.0, deployed in production, with the public URL.
- 2:45And the subscriptions section shows first-look, with no credential.
- 2:51The version's own page shows the route and the cluster it forwards through.
- 3:00Here is the whole picture.
- 3:02Three documents, one apply, a subscription, and the gateway serving the API.
- 3:08The upstream answered, and the caller saw only the URL.
- 3:12Video two gives a real caller a key and a rate limit.
Next in this track
APIM 2 · 3:08 Open it to a caller: a key and a limit Watched