Recipes
Four common uses, with the minimal code for each.
Link previews in a blog
Call /meta at publication time, or on the server, and keep the result with the article. You do not call the API on every visit.
async function linkCard(url) {
const params = new URLSearchParams({ url });
const response = await fetch(`https://omnillink.kayzen-lyon.com/api/v1/meta?${params}`);
const { status, data } = await response.json();
if (status !== "success") return null;
return {
title: data.title ?? new URL(data.url).hostname,
description: data.description,
image: data.image?.url ?? null,
site: data.publisher,
};
}
Share images
Capture a page designed for the purpose, at the size social networks expect. selector limits the capture to one element.
<meta property="og:image"
content="https://omnillink.kayzen-lyon.com/api/v1/screenshot?url=https%3A%2F%2Fexample.com%2Fcards%2Flaunch&width=1200&height=630&format=jpeg" />
Price monitoring
Describe the fields once; call the same request at regular intervals. ttl sets how long the answer stays cached.
curl -G "https://omnillink.kayzen-lyon.com/api/v1/extract" \
--data-urlencode "url=https://example.com/product/42" \
--data-urlencode 'fields={"name":{"selector":"h1"},"price":{"selector":".price","type":"number"}}' \
--data-urlencode "ttl=900"
PDF archiving
/pdf renders the page with its print stylesheet. force=true guarantees a copy of the page as it is at that moment.
curl -o archive.pdf "https://omnillink.kayzen-lyon.com/api/v1/pdf?url=https%3A%2F%2Fexample.com%2Fblog%2Flaunch&format=A4&force=true"
Check that you are allowed to copy and keep the pages you archive or collect.