Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Req v0.2.0

req_0.2.0.livemd

Req v0.2.0

Badge

Run in Livebook

Setup

Mix.install([
  {:req, "~> 0.2.0"},
  {:req_s3, github: "wojtekmach/req_s3"}
])
:ok

Defaults

Req.default_options(base_url: "https://api.github.com/repos/elixir-lang/elixir")
:ok
Req.get!("").body["description"]
"Elixir is a dynamic, functional language designed for building scalable and maintainable applications"
Req.get!("/issues").body
|> Enum.map(& &1["title"])
|> Enum.filter(&(&1 =~ "Support Erlang/OTP"))
["Support Erlang/OTP 25 new features", "Support Erlang/OTP 24 new features",
 "Support Erlang/OTP 23 new features"]

“Plugins” (just steps!)

# reset default options set in the previous section
Req.default_options([])
:ok
Req.get!("s3://ossci-datasets/", steps: [ReqS3]).body
["mnist/", "mnist/t10k-images-idx3-ubyte.gz", "mnist/t10k-labels-idx1-ubyte.gz",
 "mnist/train-images-idx3-ubyte.gz", "mnist/train-labels-idx1-ubyte.gz"]
body = Req.get!("s3://ossci-datasets/mnist/train-images-idx3-ubyte.gz", steps: [ReqS3]).body
<<_::32, n_images::32, n_rows::32, n_cols::32, _body::binary>> = body

{n_images, n_rows, n_cols}
{60000, 28, 28}