Network.HTTP.Conduit
has a clean API (it uses Network.HTTP.Types
) and is quite simple to use if you know a bit about conduits. Example:
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Conduit
import Network.HTTP.Conduit
import qualified Data.Aeson as J
main =
do manager <- newManager def
initReq <- parseUrl "https://api.github.com/user"
let req = applyBasicAuth "niklasb" "password" initReq
resp <- runResourceT $ httpLbs req manager
print (responseStatus resp)
print (lookup "content-type" (responseHeaders resp))
-- you will probably want a proper FromJSON instance here,
-- rather than decoding to Data.Aeson.Object
print (J.decode (responseBody resp) :: Maybe J.Object)
Also make sure to consult the tutorial.
wreq
is the most high level one. It makes heavy use of lens to give a consistent and a lean interface. – Creath