SerpCheap (serpcheap v0.2.0)

Copy Markdown View Source

Elixir client for the serp.cheap Google Search API.

Configure it via application env (the Phoenix way):

config :serpcheap, api_key: System.get_env("SERPCHEAP_API_KEY")

Then call from anywhere — options can also be overridden per call:

{:ok, results} = SerpCheap.search("best running shoes", gl: "us")

Summary

Functions

Find where a url/domain ranks for a keyword across Google result pages.

Like rank/3 but returns the result or raises SerpCheap.Error.

Fetch and extract a single page (content + optional screenshot).

Like scrape/2 but returns the result or raises SerpCheap.Error.

Run a Google search. Retries transient errors (429/503/timeout) with backoff.

Like search/2 but returns the result or raises SerpCheap.Error.

Types

opts()

@type opts() :: keyword()

response()

@type response() :: {:ok, map()} | {:error, SerpCheap.Error.t()}

Functions

rank(url, query, opts \\ [])

@spec rank(String.t(), String.t(), opts()) :: response()

Find where a url/domain ranks for a keyword across Google result pages.

rank!(url, query, opts \\ [])

@spec rank!(String.t(), String.t(), opts()) :: map()

Like rank/3 but returns the result or raises SerpCheap.Error.

scrape(url, opts \\ [])

@spec scrape(String.t(), opts()) :: response()

Fetch and extract a single page (content + optional screenshot).

scrape!(url, opts \\ [])

@spec scrape!(String.t(), opts()) :: map()

Like scrape/2 but returns the result or raises SerpCheap.Error.

search(query, opts \\ [])

@spec search(String.t(), opts()) :: response()

Run a Google search. Retries transient errors (429/503/timeout) with backoff.

search!(query, opts \\ [])

@spec search!(String.t(), opts()) :: map()

Like search/2 but returns the result or raises SerpCheap.Error.