What HTTP client library to start with as a Elixir beginner?

I wanted to write a library for interacting with a Web API as a practical way of learning Elixir. However, there seem to be a lot of different open source HTTP client libraries I can use! I am unsure what to use to start off with. I do want to use something basic so that I learn as much as possible while working on my project.

I noticed the Tesla library but I was wondering if anyone has any other lower level recommendations.

1 Like

I would recommend Finch, which is a layer on top of Mint. They are both fully written in Elixir, but I feel Mint is too low level if you want an easy to use API.

4 Likes

finch is pretty nice and allows you good control and branching on responses. It strikes a good balance between control and brevity IMO.

Many people started using req lately. I checked it out quickly and liked what I saw, though never tried it personally.

That being said, nowadays I’d use Tesla and pick an underlying HTTP client for it, which would be Finch. I simply like having the same dev experience everywhere where HTTP client is needed. Though that’s not an accepted fact, just my own preference.

1 Like

I recommend Req. Has a ton of concise out of the box defaults, you generally don’t worry about the minutiae. It retries etc, all configurable but all with great defaults for your 99% cases.

Example:

Req.get!(req_url,
  headers: [
    {"user-agent",
     "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36"}
  ]
).body
9 Likes

It is strange that nobody mentioned HttpPoison. It is one of the oldest and most reliable libraries out there. It has full flexibility, starting from doing standard requests, to custom client implementation by using callbacks provided by the library.

I would also recommend req :slight_smile: still not 1.0 though.