Skip to content

Instantly share code, notes, and snippets.

@Frost
Created May 8, 2015 19:58
Show Gist options
  • Select an option

  • Save Frost/ca99f1aed635fc247657 to your computer and use it in GitHub Desktop.

Select an option

Save Frost/ca99f1aed635fc247657 to your computer and use it in GitHub Desktop.
Fetching book info from Google Books API using elixir
defmodule GoogleBooks do
use HTTPoison.Base
@base_url "https://www.googleapis.com/books/v1/volumes?q=isbn:"
def process_url(isbn13) do
isbn = String.replace(isbn13, "-", "")
@base_url <> isbn
end
def process_response_body(body) do
body
|> Poison.decode!
|> Enum.map(fn({k, v}) -> {String.to_atom(k), v} end)
end
end
@Frost
Copy link
Copy Markdown
Author

Frost commented May 8, 2015

...and exchange @base_url for "http://libris.kb.se/xsearch?format=json&query=ISBN:" to look stuff up on LIBRIS :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment