All Projects → wojtekmach → req

wojtekmach / req

Licence: other
Req is a batteries-included HTTP client for Elixir.

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to req

Elastic
An Elasticsearch REST API client for Rust
Stars: ✭ 248 (-45.25%)
Mutual labels:  http-client
Rump
REST client for Java that allows for easy configuration and default values. Allows for quick request construction and a huge range of modifications by using response/request interceptors, adjusting default values related to HTTP requests and creating custom instances for when you need multiple API connection setups.
Stars: ✭ 55 (-87.86%)
Mutual labels:  http-client
go-sse
Fully featured, spec-compliant HTML5 server-sent events library
Stars: ✭ 165 (-63.58%)
Mutual labels:  http-client
Http
HTTP (The Gem! a.k.a. http.rb) is an easy-to-use client library for making requests from Ruby. It uses a simple method chaining system for building requests, similar to Python's Requests.
Stars: ✭ 2,800 (+518.1%)
Mutual labels:  http-client
EthernetWebServer SSL
Simple TLS/SSL Ethernet WebServer, HTTP Client and WebSocket Client library for for AVR, Portenta_H7, Teensy, SAM DUE, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, nRF52 and RASPBERRY_PI_PICO boards using Ethernet shields W5100, W5200, W5500, ENC28J60 or Teensy 4.1 NativeEthernet/QNEthernet. It now supports Ethernet TLS/SSL Client. The library supports …
Stars: ✭ 40 (-91.17%)
Mutual labels:  http-client
pawn-requests
pawn-requests provides an API for interacting with HTTP(S) JSON APIs.
Stars: ✭ 56 (-87.64%)
Mutual labels:  http-client
Punchclock
Make sure your asynchronous operations show up to work on time
Stars: ✭ 235 (-48.12%)
Mutual labels:  http-client
android-http-client
Simple and lightweight HTTP client for Android
Stars: ✭ 13 (-97.13%)
Mutual labels:  http-client
typesense-dart
Dart client for Typesense
Stars: ✭ 50 (-88.96%)
Mutual labels:  http-client
sugar
Declarative HTTP client for Golang
Stars: ✭ 25 (-94.48%)
Mutual labels:  http-client
Httpie
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie
Stars: ✭ 53,052 (+11611.26%)
Mutual labels:  http-client
cpphttpstack
c++ api for http client & server
Stars: ✭ 30 (-93.38%)
Mutual labels:  http-client
hackernews
📰 HackerNews API
Stars: ✭ 40 (-91.17%)
Mutual labels:  http-client
Csaguzzlebundle
A bundle integrating Guzzle >=4.0 in Symfony
Stars: ✭ 248 (-45.25%)
Mutual labels:  http-client
direwolf
Package direwolf is a convenient and easy to use http client written in Golang.
Stars: ✭ 44 (-90.29%)
Mutual labels:  http-client
Urllib3
Python HTTP library with thread-safe connection pooling, file post support, user friendly, and more.
Stars: ✭ 2,857 (+530.68%)
Mutual labels:  http-client
http
ponylang HTTP client library 🐴 🕸️
Stars: ✭ 38 (-91.61%)
Mutual labels:  http-client
hedgedhttp
Hedged HTTP client which helps to reduce tail latency at scale.
Stars: ✭ 103 (-77.26%)
Mutual labels:  http-client
matador
Take your appclication by the horns
Stars: ✭ 59 (-86.98%)
Mutual labels:  http-client
simplehttp
HTTP client for Elixir without dependencies
Stars: ✭ 16 (-96.47%)
Mutual labels:  http-client

Req

CI

Docs

Req is a batteries-included HTTP client for Elixir.

Features

Usage

The easiest way to use Req is with Mix.install/2 (requires Elixir v1.12+):

Mix.install([
  {:req, "~> 0.3"}
])

Req.get!("https://api.github.com/repos/elixir-lang/elixir").body["description"]
#=> "Elixir is a dynamic, functional language designed for building scalable and maintainable applications"

If you want to use Req in a Mix project, you can add the above dependency to your mix.exs.

If you are planning to make several similar requests, you can build up a request struct with desired common options and re-use it:

req = Req.new(base_url: "https://api.github.com")

Req.get!(req, url: "/repos/sneako/finch").body["description"]
#=> "Elixir HTTP client, focused on performance"

Req.get!(req, url: "/repos/elixir-mint/mint").body["description"]
#=> "Functional HTTP client for Elixir with support for HTTP/1 and HTTP/2."

See Req.request/1 for more information on available options.

Virtually all of Req's features are broken down into individual pieces - steps. Req works by running the request struct through these steps. You can easily reuse or rearrange built-in steps or write new ones. Importantly, steps are just regular functions. Here is another example where we append a request step that inspects the URL just before requesting it:

req =
  Req.new(base_url: "https://api.github.com")
  |> Req.Request.append_request_steps(
    debug_url: fn request ->
      IO.inspect(URI.to_string(request.url))
      request
    end
  )

Req.get!(req, url: "/repos/wojtekmach/req").body["description"]
# Outputs: "https://api.github.com/repos/wojtekmach/req"
#=> "Req is a batteries-included HTTP client for Elixir."

Custom steps can be packaged into plugins so that they are even easier to use by others. Here are some examples:

And here is how they can be used:

Mix.install([
  {:req, "~> 0.3.0"},
  {:req_easyhtml, "~> 0.1.0"},
  {:req_s3, "~> 0.1.0"},
  {:req_hex, "~> 0.1.0"},
  {:req_github_oauth, "~> 0.1.0"}
])

req =
  (Req.new(http_errors: :raise)
  |> ReqEasyHTML.attach()
  |> ReqS3.attach()
  |> ReqHex.attach()
  |> ReqGitHubOAuth.attach())

Req.get!(req, url: "https://elixir-lang.org").body[".entry-summary h5"]
#=>
# #EasyHTML[<h5>
#    Elixir is a dynamic, functional language for building scalable and maintainable applications.
#  </h5>]

Req.get!(req, url: "s3://ossci-datasets").body
#=>
# [
#   "mnist/",
#   "mnist/t10k-images-idx3-ubyte.gz",
#   "mnist/t10k-labels-idx1-ubyte.gz",
#   "mnist/train-images-idx3-ubyte.gz",
#   "mnist/train-labels-idx1-ubyte.gz"
# ]

Req.get!(req, url: "https://repo.hex.pm/tarballs/req-0.1.0.tar").body["metadata.config"]["links"]
#=> %{"GitHub" => "https://github.com/wojtekmach/req"}

Req.get!(req, url: "https://api.github.com/user").body["login"]
# Outputs:
# paste this user code:
#
#   6C44-30A8
#
# at:
#
#   https://github.com/login/device
#
# open browser window? [Yn]
# 15:22:28.350 [info] response: authorization_pending
# 15:22:33.519 [info] response: authorization_pending
# 15:22:38.678 [info] response: authorization_pending
#=> "wojtekmach"

Req.get!(req, url: "https://api.github.com/user").body["login"]
#=> "wojtekmach"

See Req.Request module documentation for more information on low-level API, request struct, and developing plugins.

Acknowledgments

Req is built on top of Finch and is inspired by cURL, Requests, Tesla, and many other HTTP clients - thank you!

License

Copyright (c) 2021 Wojtek Mach

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].