README.md

# 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}"
  {:error, reason} ->
    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}"
  {:error, reason} ->
    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}"
  {:error, reason} ->
    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}"
  {:error, reason} ->
    IO.puts "Error: #{reason}"
end

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

case MakeshotAi.capture_screenshot("invalid_url") do
  {:ok, _} ->
    IO.puts "Screenshot captured successfully (this won't happen)."
  {:error, :invalid_url} ->
    IO.puts "Invalid URL provided."
  {:error, reason} ->
    IO.puts "An unexpected error occurred: #{reason}"
end

## Feature Summary

*   **Screenshot Capture:** Generate high-quality screenshots of any accessible web page.
*   **PDF Generation:** Create PDF documents directly from web URLs.
*   **Customizable Options:** Fine-tune screenshot and PDF generation with a range of options, including viewport size, print background, and margins.
*   **Error Handling:** Robust error handling provides informative feedback for debugging and reliable integration.
*   **Simple API:** An intuitive and easy-to-use API simplifies the process of capturing web content.

## License

MIT

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