{"id":15030434,"url":"https://github.com/elixir-tesla/tesla","last_synced_at":"2025-05-14T09:06:21.422Z","repository":{"id":28834275,"uuid":"32357916","full_name":"elixir-tesla/tesla","owner":"elixir-tesla","description":"The flexible HTTP client library for Elixir, with support for middleware and multiple adapters.","archived":false,"fork":false,"pushed_at":"2025-05-02T17:43:42.000Z","size":2296,"stargazers_count":2034,"open_issues_count":29,"forks_count":352,"subscribers_count":48,"default_branch":"master","last_synced_at":"2025-05-07T08:04:15.566Z","etag":null,"topics":["elixir","hackney","http","http-client","ibrowse","json","middleware"],"latest_commit_sha":null,"homepage":"","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/elixir-tesla.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-03-16T22:55:37.000Z","updated_at":"2025-05-06T11:49:06.000Z","dependencies_parsed_at":"2023-01-14T09:41:46.503Z","dependency_job_id":"9b43013c-f701-4f2d-9618-4062128eb73e","html_url":"https://github.com/elixir-tesla/tesla","commit_stats":{"total_commits":1006,"total_committers":158,"mean_commits":6.367088607594937,"dds":0.584493041749503,"last_synced_commit":"4dd0852c161f9cb2dd9ca48fb74e3477781a4ace"},"previous_names":["teamon/tesla"],"tags_count":64,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-tesla%2Ftesla","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-tesla%2Ftesla/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-tesla%2Ftesla/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-tesla%2Ftesla/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elixir-tesla","download_url":"https://codeload.github.com/elixir-tesla/tesla/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254043292,"owners_count":22004915,"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","hackney","http","http-client","ibrowse","json","middleware"],"created_at":"2024-09-24T20:13:19.987Z","updated_at":"2025-05-14T09:06:21.363Z","avatar_url":"https://github.com/elixir-tesla.png","language":"Elixir","readme":"# Tesla\n\n[![Test](https://github.com/elixir-tesla/tesla/actions/workflows/test.yml/badge.svg)](https://github.com/elixir-tesla/tesla/actions/workflows/test.yml)\n[![Hex.pm](https://img.shields.io/hexpm/v/tesla.svg)](https://hex.pm/packages/tesla)\n[![Hexdocs.pm](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/tesla/)\n[![Hex.pm](https://img.shields.io/hexpm/dt/tesla.svg)](https://hex.pm/packages/tesla)\n[![Hex.pm](https://img.shields.io/hexpm/dw/tesla.svg)](https://hex.pm/packages/tesla)\n[![codecov](https://codecov.io/gh/elixir-tesla/tesla/branch/master/graph/badge.svg)](https://codecov.io/gh/elixir-tesla/tesla)\n\n`Tesla` is an HTTP client that leverages middleware to streamline HTTP requests\nand responses over a common interface for various adapters.\n\nIt simplifies HTTP communication by providing a flexible and composable\nmiddleware stack. Developers can easily build custom API clients by stacking\nmiddleware components that handle tasks like authentication, logging, and\nretries. `Tesla` supports multiple HTTP adapters such as `Mint`, `Finch`,\n`Hackney`, etc.\n\n`Tesla` is ideal for developers who need a flexible and efficient HTTP client.\nIts ability to swap out HTTP adapters and create custom middleware pipelines\nempowers you to make different architectural decisions and build tools tailored\nto your application's needs with minimal effort.\n\nInspired by [Faraday](https://github.com/lostisland/faraday) from Ruby.\n\n## Getting started\n\nAdd `:tesla` as dependency in `mix.exs`:\n\n```elixir\ndefp deps do\n  [\n     # or latest version\n    {:tesla, \"~\u003e 1.11\"},\n    # optional, required by JSON middleware\n    {:jason, \"~\u003e 1.4\"},\n    # optional, required by Mint adapter, recommended\n    {:mint, \"~\u003e 1.0\"}\n  ]\nend\n```\n\n\u003e #### :httpc as default Adapter {: .error}\n\u003e The default adapter is erlang's built-in `httpc`, primarily to avoid\n\u003e additional\n\u003e dependencies when using `Tesla` in a new project. But it is not recommended to\n\u003e use it in production environment as it does not validate SSL certificates\n\u003e [among other issues](https://github.com/elixir-tesla/tesla/issues?utf8=%E2%9C%93\u0026q=is%3Aissue+label%3Ahttpc+).\n\u003e Instead, consider using `Mint`, `Finch`, or `Hackney` adapters.\n\u003e We believe that such security issues should be addressed by `:httpc` itself\n\u003e and we are not planning to fix them in `Tesla` due to backward compatibility.\n\nConfigure default adapter in `config/config.exs`.\n\n```elixir\n# config/config.exs\n\n# Make sure to install `mint` package as well, recommended\nconfig :tesla, adapter: Tesla.Adapter.Mint\n```\n\nTo make a simple GET request, run `iex -S mix` and execute:\n\n    iex\u003e Tesla.get!(\"https://httpbin.org/get\").status\n    # =\u003e 200\n\nThat will not include any middleware and will use the global default adapter.\nCreate a client to compose middleware and reuse it across requests.\n\n    iex\u003e client = Tesla.client([\n    ...\u003e  {Tesla.Middleware.BaseUrl, \"https://httpbin.org/\"},\n    ...\u003e  Tesla.Middleware.JSON,\n    ...\u003e ])\n\n    iex\u003e Tesla.get!(client, \"/json\").body\n    # =\u003e %{\"slideshow\" =\u003e ...}\n\nLastly, you can enforce the adapter to be used by a specific client:\n\n    iex\u003e client = Tesla.client([], {Tesla.Adapter.Hackney, pool: :my_pool})\n\nHappy hacking!\n\n## What to do next?\n\nCheck out the following sections to learn more about `Tesla`:\n\n### Explanations\n\n- [Client](./guides/explanations/0.client.md)\n- [Testing](./guides/explanations/1.testing.md)\n- [Middleware](./guides/explanations/2.middleware.md)\n- [Adapter](./guides/explanations/3.adapter.md)\n\n### Howtos\n\n#### Migrations\n\n- [Migrating from v0 to v1.x](./guides/howtos/migrations/v0-to-v1.md)\n\n### References\n\n- [General Cheatsheet](./guides/cheatsheets/general.cheatmd)\n- [Cookbook](https://github.com/elixir-tesla/tesla/wiki)\n\n#### Middleware\n\n`Tesla` is built around the concept of composable middlewares.\n\n- `Tesla.Middleware.BaseUrl` - set base URL.\n- `Tesla.Middleware.Headers` - set request headers.\n- `Tesla.Middleware.Query` - set query parameters.\n- `Tesla.Middleware.Opts` - set request options.\n- `Tesla.Middleware.FollowRedirects` - follow HTTP 3xx redirects.\n- `Tesla.Middleware.MethodOverride` - set `X-Http-Method-Override` header.\n- `Tesla.Middleware.Logger` - log requests (method, url, status, and time).\n- `Tesla.Middleware.KeepRequest` - keep request `body` and `headers`.\n- `Tesla.Middleware.PathParams` - use templated URLs.\n\n##### Formats\n\n- `Tesla.Middleware.FormUrlencoded` - URL encode POST body, useful for POSTing a\n  map/keyword list.\n- `Tesla.Middleware.JSON` - encode/decode JSON request/response body.\n- `Tesla.Middleware.Compression` - compress request/response body using\n  `gzip` and `deflate`.\n- `Tesla.Middleware.DecodeRels` - decode `Link` header into `opts[:rels]` field\n  in response.\n\n##### Auth\n\n- `Tesla.Middleware.BasicAuth` - HTTP Basic Auth.\n- `Tesla.Middleware.BearerAuth` - HTTP Bearer Auth.\n- `Tesla.Middleware.DigestAuth`] - Digest access authentication.\n\n##### Error handling\n\n- `Tesla.Middleware.Timeout` - timeout request after X milliseconds despite of\n  server response.\n- `Tesla.Middleware.Retry` - retry few times in case of connection refused.\n- `Tesla.Middleware.Fuse` - fuse circuit breaker integration.\n\n#### Adapters\n\nTesla supports multiple HTTP adapter that do the actual HTTP request processing.\n\n- `Tesla.Adapter.Httpc` - the default, built-in Erlang [httpc][0] adapter.\n- `Tesla.Adapter.Hackney` - [hackney][1], simple HTTP client in Erlang.\n- `Tesla.Adapter.Ibrowse` - [ibrowse][2], Erlang HTTP client.\n- `Tesla.Adapter.Gun` - [gun][3], HTTP/1.1, HTTP/2 and Websocket client for\n  Erlang/OTP.\n- `Tesla.Adapter.Mint` - [mint][4], Functional HTTP client for Elixir with\n  support for HTTP/1 and HTTP/2.\n- `Tesla.Adapter.Finch` - [finch][5], An HTTP client with a focus on\n  performance, built on top of [Mint][4] and [NimblePool][6].\n\n## Sponsors\n\n- [ubots - Ultimate Productivity Made Easy with Slack](https://ubots.co/)\n\n[0]: https://erlang.org/doc/man/httpc.html\n[1]: https://github.com/benoitc/hackney\n[2]: https://github.com/cmullaparthi/ibrowse\n[3]: https://github.com/ninenines/gun\n[4]: https://github.com/elixir-mint/mint\n[5]: https://github.com/keathley/finch\n[6]: https://github.com/dashbitco/nimble_pool\n","funding_links":[],"categories":["Elixir"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-tesla%2Ftesla","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felixir-tesla%2Ftesla","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-tesla%2Ftesla/lists"}