{"id":13508315,"url":"https://github.com/swelham/ivar","last_synced_at":"2025-08-18T15:06:46.371Z","repository":{"id":57508896,"uuid":"82699293","full_name":"swelham/ivar","owner":"swelham","description":"Ivar is an adapter based HTTP client that provides the ability to build composable HTTP requests.","archived":false,"fork":false,"pushed_at":"2017-10-05T14:11:23.000Z","size":77,"stargazers_count":16,"open_issues_count":4,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-26T23:11:44.544Z","etag":null,"topics":["composable","elixir","http","http-client"],"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/swelham.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":"2017-02-21T16:02:39.000Z","updated_at":"2024-01-28T16:02:29.000Z","dependencies_parsed_at":"2022-08-30T01:30:12.078Z","dependency_job_id":null,"html_url":"https://github.com/swelham/ivar","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swelham%2Fivar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swelham%2Fivar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swelham%2Fivar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swelham%2Fivar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swelham","download_url":"https://codeload.github.com/swelham/ivar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248674674,"owners_count":21143760,"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":["composable","elixir","http","http-client"],"created_at":"2024-08-01T02:00:51.318Z","updated_at":"2025-04-13T06:32:15.051Z","avatar_url":"https://github.com/swelham.png","language":"Elixir","funding_links":[],"categories":["HTTP"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/swelham/ivar.svg?branch=master)](https://travis-ci.org/swelham/ivar) [![Deps Status](https://beta.hexfaktor.org/badge/all/github/swelham/ivar.svg?branch=master)](https://beta.hexfaktor.org/github/swelham/ivar) [![Hex Version](https://img.shields.io/hexpm/v/ivar.svg)](https://hex.pm/packages/ivar) [![Join the chat at https://gitter.im/swelham/ivar](https://badges.gitter.im/swelham/ivar.svg)](https://gitter.im/swelham/ivar?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n# Ivar\n\nIvar is an adapter based HTTP client that provides the ability to build composable HTTP requests.\n\nThe key goals of Ivar are to allow requests to be constructed in a composable manner (pipeline friendly) and to simplify building, sending and receiving requests for a number of well known\nhttp clients.\n\n## Supported Adapters\n\n| HTTP Client | Adapter |\n| ----------- | ------- |\n| HTTPoison | [ivar_httpoison](https://github.com/swelham/ivar_httpoison) |\n\n## Usage\n\nAdd `ivar` to your list of dependencies in `mix.exs`, plus the http adapter you are going to use:\n\n```elixir\ndef deps do\n  [\n    {:ivar, \"~\u003e 0.9.0\"},\n    {:ivar_httpoison, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\nSetup up the config for your chosen adapater\n\n```elixir\nconfig :ivar,\n  adapter: Ivar.HTTPoison\n```\n\n### Basic usage\n\n\n```elixir\nIvar.get(\"https://example.com\")\n|\u003e Ivar.send\n|\u003e Ivar.unpack\n# {\"\u003c!doctype html\u003e\\n\u003chtml\u003e...\", %HTTPoison.Response{}}\n```\n\n### JSON encoding/decoding\n\nIvar uses the `Poison` library for encoding and decoding JSON, so make sure you\nhave it listed along side Ivar in your `mix.exs`.\n\n```elixir\ndef deps do\n  [\n    {:ivar, \"~\u003e 0.9.0\"},\n    {:poison, \"~\u003e 3.0\"},\n    ...\n  ]\nend\n```\nYou can then specify that you want to send JSON when putting the request body. If \nthe response contains the `application/json` content type header, the `Ivar.unpack` \nfunction will then decode the response for you.\n\n```elixir\nIvar.post(\"https://some-echo-server\")\n|\u003e Ivar.put_body(%{some: \"data\"}, :json)\n|\u003e Ivar.send\n|\u003e Ivar.unpack\n# {%{some: \"data\"}, %HTTPoison.Response{}}\n```\n\n\n### Real world example\n\nThis is simplified extract from a real world application where Ivar is being used to\nsend email via the mailgun service.\n\n```elixir\nurl = \"https://api.mailgun.net/v3/domain.com/messages\"\nmail_data = %{to: \"someone@example.com\", ...}\nfiles = [{\"inline\", File.read!(\"elixir.png\"), \"elixir.png\"}, ...]\n\nIvar.new(:post, url)\n|\u003e Ivar.put_auth({\"api\", \"mailgun_api_key\"}, :basic)\n|\u003e Ivar.put_body(mail_data, :url_encoded)\n|\u003e Ivar.put_files(files)\n|\u003e Ivar.send\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswelham%2Fivar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswelham%2Fivar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswelham%2Fivar/lists"}