SDKs
Elixir
Patrones idiomáticos de Elixir para Phoenix y OTP
Usa Req (el cliente HTTP moderno de Elixir) — construido sobre Finch, viene con reintentos y connection pooling.
mix.exs
defp deps do
[
{:req, "~> 0.5"}
]
endConfiguración
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
endDistill de una página
def distill(url) do
client()
|> Req.post!(url: "/distill", json: %{url: url})
|> Map.fetch!(:body)
|> get_in(["data", "markdown"])
endExtract de datos estructurados
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 con Oban
Para fan-out asíncrono, encola los envíos con Oban y deja que tu endpoint de Phoenix maneje el webhook callback:
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")
}
})
endVerifica la firma del webhook en tu controlador de Phoenix — ver Webhooks.
Un SDK oficial de Elixir está en desarrollo — vuelve pronto.