{"id":15471428,"url":"https://github.com/aisk/request","last_synced_at":"2025-05-01T10:55:58.760Z","repository":{"id":56876560,"uuid":"310598180","full_name":"aisk/request","owner":"aisk","description":"HTTP client for haskell, inpired by requests and http-dispatch.","archived":false,"fork":false,"pushed_at":"2023-12-06T08:44:39.000Z","size":24,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-01T10:55:53.208Z","etag":null,"topics":["haskell","http","http-client","request","requests"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aisk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-06T12:59:33.000Z","updated_at":"2025-04-18T05:31:45.000Z","dependencies_parsed_at":"2022-08-20T22:30:48.959Z","dependency_job_id":null,"html_url":"https://github.com/aisk/request","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aisk%2Frequest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aisk%2Frequest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aisk%2Frequest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aisk%2Frequest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aisk","download_url":"https://codeload.github.com/aisk/request/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251864175,"owners_count":21656289,"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","http","http-client","request","requests"],"created_at":"2024-10-02T02:19:37.175Z","updated_at":"2025-05-01T10:55:58.737Z","avatar_url":"https://github.com/aisk.png","language":"Haskell","readme":"# request\n\n![](https://miro.medium.com/max/1200/1*5KglaZoNp4fNpNHUao5u5w.jpeg)\n\nHTTP client for haskell, inpired by [requests](https://requests.readthedocs.io/) and [http-dispatch](https://github.com/owainlewis/http-dispatch).\n\n## Installation\n\nThis pacakge is published on [hackage](http://hackage.haskell.org/package/request) with the same name `request`, you can install it with cabal or stack or nix as any other hackage packages.\n\n## Usage\n\nYou can try this in haskell REPL once you have `request` installed:\n\n```haskell\nimport Network.HTTP.Request\n\nresp \u003c- get \"https://api.leancloud.cn/1.1/date\"\nprint $ requestStatus resp\n```\n\n## Core API\n\nRequest's API has three core concepts: `Request` record type, `Response` record type, `send` function.\n\n### Request\n\n`Request` is all about the information you will send to the target URL.\n\n```haskell\ndata Request = Request\n  { requestMethod  :: Method\n  , requestUrl     :: String\n  , requestHeaders :: Headers\n  , requestBody    :: Maybe Data.ByteString.ByteString\n  } deriving (Show)\n```\n\n### send\n\nOnce you have constructed your own `Request` record, you can call the `send` function to send it to the server. The `send` function's type is:\n\n```haskell\nsend :: Request -\u003e IO Response\n```\n\n### Response\n\n`Response` is what you got from the server URL.\n\n```haskell\ndata Response = Response\n  { responseStatus  :: Int\n  , responseHeaders :: Headers\n  , responseBody    :: Data.ByteString.ByteString\n  } deriving (Show)\n```\n\n### Example\n\n```haskell\n:set -XOverloadedStrings\n\nimport Network.HTTP.Request\n\n-- Construct a Request record.\nlet req = Request GET \"https://api.leancloud.cn/1.1/date\" [] Nothing\n-- Send it.\nres \u003c- send req\n-- access the fields on Response.\nprint $ requestStatus resp\n```\n\n## Shortcuts\n\nAs you expected, there are some shortcuts for the most used scenarios.\n\n```haskell\nget :: String -\u003e IO Response\nget url =\n  send $ Request GET url [] Nothing\n\ndelete :: String -\u003e IO Response\ndelete url =\n  send $ Request DELETE url [] Nothing\n\npost :: (String, Maybe Data.ByteString.ByteString) -\u003e IO Response\npost (url, body) =\n  send $ Request POST url [] body\n\nput :: (String, Maybe Data.ByteString.ByteString) -\u003e IO Response\nput (url, body) =\n  send $ Request PUT url [] body\n```\n\nThese shortcuts' definitions are simple and direct. You are encouraged to add your own if the built-in does not match your use cases, like add custom headers in every request.\n\n## API Documents\n\nSee the hackage page: http://hackage.haskell.org/package/request/docs/Network-HTTP-Request.html\n\n## About the Project\n\nRequest is \u0026copy; 2020-2021 by [aisk](https://github.com/aisk).\n\n### License\n\nRequest is distributed by a [BSD license](https://github.com/aisk/request/tree/master/LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faisk%2Frequest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faisk%2Frequest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faisk%2Frequest/lists"}