{"id":13681668,"url":"https://github.com/epicallan/hreq","last_synced_at":"2025-03-16T23:31:40.966Z","repository":{"id":56844382,"uuid":"209843216","full_name":"epicallan/hreq","owner":"epicallan","description":"A type dependent highlevel HTTP client library inspired by servant-client.","archived":false,"fork":false,"pushed_at":"2019-11-26T13:56:32.000Z","size":172,"stargazers_count":53,"open_issues_count":4,"forks_count":3,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-02-27T15:17:45.390Z","etag":null,"topics":["haskell-library","http-client","network"],"latest_commit_sha":null,"homepage":"https://lukwagoallan.com/posts/http-requests-with-hreq","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/epicallan.png","metadata":{"files":{"readme":"README.lhs","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-20T17:13:33.000Z","updated_at":"2024-12-12T08:13:37.000Z","dependencies_parsed_at":"2022-09-09T02:22:59.747Z","dependency_job_id":null,"html_url":"https://github.com/epicallan/hreq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epicallan%2Fhreq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epicallan%2Fhreq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epicallan%2Fhreq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epicallan%2Fhreq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/epicallan","download_url":"https://codeload.github.com/epicallan/hreq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243826797,"owners_count":20354221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haskell-library","http-client","network"],"created_at":"2024-08-02T13:01:34.044Z","updated_at":"2025-03-16T23:31:40.391Z","avatar_url":"https://github.com/epicallan.png","language":"Haskell","funding_links":[],"categories":["Haskell"],"sub_categories":[],"readme":"# Hreq\n\n[![Hackage](https://img.shields.io/hackage/v/hreq-core.svg?logo=haskell)](https://hackage.haskell.org/package/hreq-client)\n[![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![Build status](https://img.shields.io/travis/epicallan/hreq.svg?logo=travis\u0026branch=master)](https://travis-ci.org/epicallan/hreq)\n\n## Intro\n\nHreq is a high-level easy to use type-driven HTTP client library inspired by Servant-Client. Hreq provides an alternative approach to type-safe construction and interpretation of API endpoints for Http client requests.\n\nThe Hreq github repository is a mono-repo composed of the following:\n\n- [hreq-core](https://github.com/epicallan/hreq/tree/master/hreq-core) implementing core functionality.\n\n- [hreq-client](https://github.com/epicallan/hreq/tree/master/hreq-client) an HTTP client using hreq-core functionality\n\n- [hreq-conduit](https://github.com/epicallan/hreq/tree/master/hreq-conduit) an HTTP client with streaming support via conduit.\n\n### Checkout accompanying blog post and minimal tutorial for more details\n\n* [HTTP Requests with Hreq](https://lukwagoallan.com/posts/http-requests-with-hreq)\n\n##  Motivation\n\nHreq was motivated by the simplicity and ease of use of [req](https://github.com/mrkkrp/req) and the type driven elegance of [servant-client](https://github.com/haskell-servant/servant/tree/master/servant-client).\nI envisioned Hreq as the best possible compromise of both worlds.\n\n### Some of the Key Points\n\n - A default HTTP client manager is set up within the library such that one doesn't have to think about manager configuration.\n\n - Hreq provides type synonyms for common API type combinators, therefore, reducing on API types verbosity.\n\n - In Hreq, API types are used directly within API functions via Type Application while in servant-client API types create new API functions for creating API requests.\n\n - In Hreq, API Request component arguments are provided to the API function through a Heterogeneous list.\n\n - Hreq supports the concept of Retry policy, whereby an http request is retried automatically on network connection failure based on a set Retry policy.\n\n## Usage Example\n\n\n```haskell\n{-# LANGUAGE OverloadedStrings #-}\n{-# LANGUAGE TypeApplications #-}\n{-# LANGUAGE DeriveAnyClass #-}\n{-# LANGUAGE TypeOperators #-}\n{-# LANGUAGE DeriveGeneric #-}\n{-# LANGUAGE DataKinds  #-}\n\nmodule Main where\n\nimport Data.Aeson (FromJSON, ToJSON)\nimport GHC.Generics (Generic)\nimport Hreq.Client\n\ndata User = User\n  { name :: String\n  , age  :: Int\n  } deriving (Show, Generic, FromJSON, ToJSON)\n\nmain' :: IO ()\nmain' = do\n  res \u003c- runHreq baseUrl $ do\n    -- | Makes Post request with newUser as a request body\n    createdUser \u003c- createUser newUser\n    -- | Makes Get Request with \"allan\" as a URL fragment\n    myUser      \u003c- getUserByName \"allan\"\n    -- | Makes a Get Request returning a list of Users\n    allUsers    \u003c- hreq @(GetJson [User]) Empty\n    return (createdUser, myUser, allUsers)\n  print res\n  where\n    baseUrl :: BaseUrl\n    baseUrl = HttpDomain \"example.com\"\n\n    newUser :: User\n    newUser = User \"Allan\" 29\n\ncreateUser :: RunClient m =\u003e User -\u003e m User\ncreateUser user = hreq @(JsonBody User :\u003e PostJson User) (user :. Empty)\n\ngetUserByName :: RunClient m =\u003e String -\u003e m User\ngetUserByName userName = hreq @(Capture String :\u003e GetJson User) (userName :. Empty)\n\n```\n\n### Attribution\n\nHreq is heavily inspired by [servant-client](https://github.com/haskell-servant/servant) and ideas from [Serv](https://github.com/tel/serv).\n\n### Documentation\n\nThis README is tested by `markdown-unlit` to make sure the code builds. To keep _that_ happy, we do need a `main` in this file, so ignore the following :)\n\n```haskell\nmain :: IO ()\nmain = pure ()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepicallan%2Fhreq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fepicallan%2Fhreq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepicallan%2Fhreq/lists"}