makeshot.ai

A simple and efficient Elixir library for interacting with the makeshot.ai API, enabling you to generate screenshots and PDFs from URLs programmatically. This package streamlines the process of capturing web content for documentation, archiving, and visual representation.

Installation

Add makeshot_ai to your list of dependencies in mix.exs: elixir def deps do [

{:makeshot_ai, "~> 0.1.0"} # Replace with the latest version

] end

Then, run mix deps.get to fetch the dependency.

Usage Examples

Before using the library, configure your API key in your application's configuration: elixir config :makeshot_ai, api_key: "YOUR_API_KEY"

Here are some examples of how to use makeshot_ai:

1. Capture a screenshot of a website: elixir alias MakeshotAi

MakeshotAi.capture_screenshot("https://example.com") |> case do {:ok, screenshot_url} ->

IO.puts "Screenshot URL: #{screenshot_url}"

->

IO.puts "Error: #{reason}"

end

2. Capture a screenshot with custom viewport dimensions: elixir alias MakeshotAi

MakeshotAi.capture_screenshot("https://example.com", viewport: %{width: 1280, height: 720}) |> case do {:ok, screenshot_url} ->

IO.puts "Screenshot URL: #{screenshot_url}"

->

IO.puts "Error: #{reason}"

end

3. Generate a PDF from a website: elixir alias MakeshotAi

MakeshotAi.generate_pdf("https://example.com") |> case do {:ok, pdf_url} ->

IO.puts "PDF URL: #{pdf_url}"

->

IO.puts "Error: #{reason}"

end

4. Generate a PDF with custom options: elixir alias MakeshotAi

options = %{ print_background: true, margin: %{

top: "10mm",
bottom: "10mm"

} }

MakeshotAi.generate_pdf("https://example.com", options) |> case do {:ok, pdf_url} ->

IO.puts "PDF URL: #{pdf_url}"

->

IO.puts "Error: #{reason}"

end

5. Handle errors gracefully using pattern matching: elixir alias MakeshotAi

case MakeshotAi.capturescreenshot("invalid_url") do {:ok, } ->

IO.puts "Screenshot captured successfully (this won't happen)."

->

IO.puts "Invalid URL provided."

->

IO.puts "An unexpected error occurred: #{reason}"

end

Feature Summary

License

MIT

This package is part of the makeshot.ai ecosystem. For advanced features and enterprise-grade tools, visit: https://makeshot.ai/