{"id":15470474,"url":"https://github.com/dlesl/erqwest","last_synced_at":"2025-04-15T06:13:44.194Z","repository":{"id":47444175,"uuid":"389737305","full_name":"dlesl/erqwest","owner":"dlesl","description":"An experimental erlang HTTP client wrapping reqwest","archived":false,"fork":false,"pushed_at":"2023-10-01T19:02:02.000Z","size":941,"stargazers_count":34,"open_issues_count":8,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T06:13:36.914Z","etag":null,"topics":["erlang","http","reqwest","rust"],"latest_commit_sha":null,"homepage":"","language":"Erlang","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/dlesl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2021-07-26T18:50:19.000Z","updated_at":"2024-05-01T19:59:30.000Z","dependencies_parsed_at":"2022-09-12T02:20:57.839Z","dependency_job_id":null,"html_url":"https://github.com/dlesl/erqwest","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlesl%2Ferqwest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlesl%2Ferqwest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlesl%2Ferqwest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlesl%2Ferqwest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dlesl","download_url":"https://codeload.github.com/dlesl/erqwest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249016638,"owners_count":21198833,"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":["erlang","http","reqwest","rust"],"created_at":"2024-10-02T02:04:53.770Z","updated_at":"2025-04-15T06:13:44.164Z","avatar_url":"https://github.com/dlesl.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nerqwest\n=======\n\n[![Hex pm](http://img.shields.io/hexpm/v/erqwest.svg?style=flat)](https://hex.pm/packages/erqwest)\n\nAn erlang wrapper for [reqwest](https://github.com/seanmonstar/reqwest) using\n[rustler](https://github.com/rusterlium/rustler). Map-based interface inspired\nby [katipo](https://github.com/puzza007/katipo).\n\nFeatures\n--------\n\n* HTTP/1.1 and HTTP/2 with connection keepalive/reuse\n* Configurable SSL support, uses system root certificates by default\n* Sync and async interfaces\n* Proxy support\n* Optional cookies support\n* Optional gzip support\n\nPrerequisites\n-------------\n\n* Erlang/OTP\n* Rust\n* OpenSSL (not required on mac)\n\nOr use the provided `shell.nix` if you have nix installed.\n\nUsage\n---\n\n### Start a client\n\n``` erlang\nok = application:ensure_started(erqwest),\nok = erqwest:start_client(default).\n```\n\nThis registers a client under the name `default`. The client maintains an\ninternal connection pool. \n\n### Synchronous interface\n\n#### No streaming\n\n ``` erlang\n {ok, #{status := 200, body := Body}} = \n     erqwest:get(default, \u003c\u003c\"https://httpbin.org/get\"\u003e\u003e),\n\n {ok, #{status := 200, body := Body1}} =\n     erqwest:post(default, \u003c\u003c\"https://httpbin.org/post\"\u003e\u003e,\n                  #{body =\u003e \u003c\u003c\"data\"\u003e\u003e}).\n ```\n \n#### Stream request body\n\n ``` erlang\n {handle, H} = erqwest:post(default, \u003c\u003c\"https://httpbin.org/post\"\u003e\u003e,\n                            #{body =\u003e stream}),\n ok = erqwest:send(H, \u003c\u003c\"data, \"\u003e\u003e),\n ok = erqwest:send(H, \u003c\u003c\"more data.\"\u003e\u003e),\n {ok, #{body := Body}} = erqwest:finish_send(H).\n ```\n\n#### Stream response body\n\n ``` erlang\n {ok, #{body := Handle}} = erqwest:get(default, \u003c\u003c\"https://httpbin.org/stream-bytes/1000\"\u003e\u003e,\n                                       #{response_body =\u003e stream}),\n ReadAll = fun Self() -\u003e\n               case erqwest:read(Handle, #{length =\u003e 0}) of\n                 {ok, Data} -\u003e\n                   [Data];\n                 {more, Data} -\u003e\n                   [Data|Self()]\n               end\n           end,\n 1000 = iolist_size(ReadAll()).\n ```\n\n#### Conditionally consume response body\n\n ``` erlang\n {ok, Resp} = erqwest:get(default, \u003c\u003c\"https://httpbin.org/status/200,500\"\u003e\u003e,\n                          #{response_body =\u003e stream}),\n case Resp of\n   #{status := 200, body := Handle} -\u003e\n     {ok, \u003c\u003c\u003e\u003e} = erqwest:read(Handle),\n   #{status := BadStatus, body := Handle} -\u003e\n     %% ensures the connection is closed/can be reused immediately\n     erqwest:cancel(Handle),\n     io:format(\"Status is ~p, not interested~n\", [BadStatus])\n end.\n ```\n\n\n### Asynchronous interface\n\n``` erlang\nerqwest_async:req(default, self(), Ref=make_ref(), \n                  #{method =\u003e get, url =\u003e \u003c\u003c\"https://httpbin.org/get\"\u003e\u003e}),\nreceive\n    {erqwest_response, Ref, reply, #{body := Body}} -\u003e Body\nend.\n```\n\nSee the [docs](https://hexdocs.pm/erqwest/) for more details and and the\n[test suite](https://github.com/dlesl/erqwest/tree/master/test/erqwest_SUITE.erl) \nfor more examples.\n\n[Docs](https://hexdocs.pm/erqwest/)\n----\n\n[Benchmarks](https://github.com/dlesl/erqwest/tree/master/bench)\n-------------------\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlesl%2Ferqwest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdlesl%2Ferqwest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlesl%2Ferqwest/lists"}