SDKs
Elixir
Idiomatische Elixir-patronen voor Phoenix en OTP
Gebruik Req (de moderne Elixir HTTP client) — gebouwd op Finch, geleverd met retries en connection pooling.
mix.exs
defp deps do
[
{:req, "~> 0.5"}
]
endConfigureren
defmodule Thunderbit do
@api "https://openapi.thunderbit.com/openapi/v1"
defp client do
Req.new(
base_url: @api,
auth: {:bearer, System.fetch_env!("THUNDERBIT_API_KEY")},
receive_timeout: 60_000
)
end
endEen pagina Distillen
def distill(url) do
client()
|> Req.post!(url: "/distill", json: %{url: url})
|> Map.fetch!(:body)
|> get_in(["data", "markdown"])
endGestructureerde data Extracten
def extract(url, schema) do
client()
|> Req.post!(url: "/extract", json: %{url: url, schema: schema})
|> Map.fetch!(:body)
|> Map.fetch!("data")
end
extract("https://example.com/product/iphone-15-pro", %{
type: "object",
properties: %{
name: %{type: "string"},
price: %{type: "number"}
},
required: ["name", "price"]
})Batch met Oban
Voor async fan-out wachtrij je submissions met Oban en laat je je Phoenix-Endpoint de Webhook-callback afhandelen:
def submit_batch(urls) do
client()
|> Req.post!(url: "/batch/distill", json: %{
urls: urls,
webhook: %{
url: "#{MyApp.Endpoint.url()}/webhooks/distill",
secret: System.fetch_env!("WEBHOOK_SECRET")
}
})
endVerifieer de Webhook-signature in je Phoenix-controller — zie Webhooks.
Een officiële Elixir SDK is in ontwikkeling — kom binnenkort terug.