{"id":17491767,"url":"https://github.com/fidr/peppermint","last_synced_at":"2025-04-22T20:14:00.645Z","repository":{"id":57530922,"uuid":"265908445","full_name":"fidr/peppermint","owner":"fidr","description":"Simple Elixir HTTP client build on MInt","archived":false,"fork":false,"pushed_at":"2020-07-15T14:39:28.000Z","size":25,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-22T20:13:54.149Z","etag":null,"topics":["elixir","elixir-lang","http-client","http2"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fidr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-21T17:17:47.000Z","updated_at":"2025-04-05T21:07:38.000Z","dependencies_parsed_at":"2022-09-05T09:51:17.037Z","dependency_job_id":null,"html_url":"https://github.com/fidr/peppermint","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fidr%2Fpeppermint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fidr%2Fpeppermint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fidr%2Fpeppermint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fidr%2Fpeppermint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fidr","download_url":"https://codeload.github.com/fidr/peppermint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250316058,"owners_count":21410476,"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":["elixir","elixir-lang","http-client","http2"],"created_at":"2024-10-19T08:04:52.178Z","updated_at":"2025-04-22T20:14:00.624Z","avatar_url":"https://github.com/fidr.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Peppermint\n\nSimple Elixir HTTP client build on [Mint](https://github.com/elixir-mint/mint). It supports both HTTP/1 and HTTP/2 requests.\n\nPeppermint aims to provide a simple interface build on the modern low-level Mint library. It provides a pool-less architecture, but it can be used to build your own connection pools easily.\n\nCurrently peppermint requires elixir `~\u003e 1.10`\n\n## Installation\n\nAdd to your `mix.exs` and run `mix deps.get`:\n\n```elixir\ndef deps do\n  [\n    {:peppermint, \"~\u003e 0.3.0\"},\n    {:castore, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\n## Usage\n\n### Examples\n\nFire a one-off request. Connects to the host, executes the request and disconnects.\n\n#### GET\n```elixir\n{:ok, %{status: 200, headers: headers, body: body}} =\n  Peppermint.get(\"http://httpbin.org/get?foo=bar\")\n```\n\n#### GET with params (sent as query in the path)\n```elixir\n{:ok, %{status: 200, headers: headers, body: body}} =\n  Peppermint.get(\"http://httpbin.org/get\", params: %{foo: \"bar\"})\n```\n\n#### POST with params\n```elixir\n{:ok, %{status: 200, headers: headers, body: body}} =\n  Peppermint.post(\"http://httpbin.org/post\", params: %{foo: \"bar\"})\n```\n\n#### POST JSON\n```elixir\n{:ok, %{status: 200, headers: headers, body: body}} =\n  Peppermint.post(\"http://httpbin.org/post\",\n    headers: [{\"Content-Type\", \"application/json\"}],\n    body: Jason.encode!(%{foo: \"bar\"})\n  )\n```\n\n#### Other methods\n\n`put`, `patch`, `delete`, `head`, `options` and `trace`\n\n#### Timeouts\n\n - `transport_options`: [See mint docs](https://hexdocs.pm/mint/Mint.HTTP.html#connect/4-transport-options) - The `timeout` here specifies the connect timeout (defaults to `30_000`)\n - `receive_timeout` - Trigger timeout if no data received for x ms (defaults to `5_000`)\n\n```elixir\nPeppermint.get(\"http://httpbin.org/get\",\n  receive_timeout: 1_000,\n  transport_options: [timeout: 5_000]\n)\n```\n\n#### Reuse connection\n\nTo reuse a connection, the `Peppermint.Connection` provides a simple GenServer to handle a connection and\nsimultanious requests over HTTP/2 (multiplexing) or sequentially over HTTP/1:\n\n```elixir\n{:ok, conn} = Peppermint.Connection.open(\"http://httpbin.org\")\n{:ok, response} = Peppermint.Connection.request(conn, :get, \"/get?foo=bar\")\n{:ok, response} = Peppermint.Connection.request(conn, :post, \"/post\", params: %{foo: \"bar\"})\n:ok = Peppermint.Connection.close(conn)\n```\n\n\n## Acknowledgements\n\n - Check out [Mint](https://github.com/elixir-mint/mint) for more low-level and advanced usecases\n - Check out [Mojito](https://github.com/appcues/mojito) if you need connection pooling\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffidr%2Fpeppermint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffidr%2Fpeppermint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffidr%2Fpeppermint/lists"}