{"id":13640562,"url":"https://github.com/softwaremill/sttp","last_synced_at":"2025-05-13T21:11:09.734Z","repository":{"id":37406167,"uuid":"95900154","full_name":"softwaremill/sttp","owner":"softwaremill","description":"The Scala HTTP client you always wanted!","archived":false,"fork":false,"pushed_at":"2025-05-09T00:42:42.000Z","size":11274,"stargazers_count":1474,"open_issues_count":14,"forks_count":319,"subscribers_count":38,"default_branch":"master","last_synced_at":"2025-05-09T01:33:03.836Z","etag":null,"topics":["akka-http","asynchronous","cats","client","distributed-tracing","http","http-client","httpclient","interpolator","monix","okhttp","reactive-streams","scala","scalaz","synchronous","uri","zipkin","zipkin-brave"],"latest_commit_sha":null,"homepage":"https://sttp.softwaremill.com","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/softwaremill.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":"docs/support.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-06-30T15:15:07.000Z","updated_at":"2025-05-09T00:42:45.000Z","dependencies_parsed_at":"2023-12-04T10:31:30.887Z","dependency_job_id":"933bc662-2c2b-4638-8884-8ed738835ac4","html_url":"https://github.com/softwaremill/sttp","commit_stats":null,"previous_names":[],"tags_count":293,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softwaremill%2Fsttp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softwaremill%2Fsttp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softwaremill%2Fsttp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softwaremill%2Fsttp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softwaremill","download_url":"https://codeload.github.com/softwaremill/sttp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254029002,"owners_count":22002283,"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":["akka-http","asynchronous","cats","client","distributed-tracing","http","http-client","httpclient","interpolator","monix","okhttp","reactive-streams","scala","scalaz","synchronous","uri","zipkin","zipkin-brave"],"created_at":"2024-08-02T01:01:12.359Z","updated_at":"2025-05-13T21:11:04.721Z","avatar_url":"https://github.com/softwaremill.png","language":"Scala","readme":"![sttp](https://github.com/softwaremill/sttp/raw/master/banner.png)\n\n[![Ideas, suggestions, problems, questions](https://img.shields.io/badge/Discourse-ask%20question-blue)](https://softwaremill.community/c/sttp-client)\n[![CI](https://github.com/softwaremill/sttp/workflows/CI/badge.svg)](https://github.com/softwaremill/sttp/actions?query=workflow%3ACI+branch%3Amaster)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.softwaremill.sttp.client4/core_3/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.softwaremill.sttp.client4/core_3)\n\n# The Scala HTTP client you always wanted!\n\n## Welcome!\n\nsttp client is an open-source HTTP client for Scala, supporting various approaches to writing Scala code: synchronous (direct-style), `Future`-based, and using functional effect systems (cats-effect, ZIO, Monix, Kyo, scalaz).\n\nThe library is available for Scala 2.12, 2.13 and 3. Supported platforms are the JVM (Java 11+), Scala.JS and Scala Native.\n\nHere's a quick example of sttp client in action, runnable using [scala-cli](https://scala-cli.virtuslab.org):\n\n```scala\n//\u003e using dep com.softwaremill.sttp.client4::core:4.0.3\n\nimport sttp.client4.quick.*\n\n@main def run(): Unit =\n  println(quickRequest.get(uri\"http://httpbin.org/ip\").send())\n```\n\nsttp client addresses common HTTP client use cases, such as interacting with JSON APIs (with automatic serialization of request bodies and deserialization of response bodies), uploading and downloading files, submitting form data, handling multipart requests, and working with WebSockets.\n\nThe driving principle of sttp client's design is to provide a clean, programmer-friendly API to describe HTTP requests, along with response handling. This ensures that resources, such as HTTP connections, are used safely, also in the presence of errors.\n\nsttp client integrates with a number of lower-level Scala and Java HTTP client implementations through backends (using Java's `HttpClient`, Akka HTTP, Pekko HTTP, http4s, OkHttp, Armeria), offering a wide range of choices when it comes to protocol support, connectivity settings and programming stack compatibility. \n\nAdditionally, sttp client seamlessly integrates with popular libraries for JSON handling (e.g., circe, uPickle, jsoniter, json4s, play-json, ZIO Json), logging, metrics, and tracing (e.g., slf4j, scribe, OpenTelemetry, Prometheus). It also supports streaming libraries (e.g., fs2, ZIO Streams, Akka Streams, Pekko Streams) and provides tools for testing HTTP interactions.\n\nSome more features: URI interpolation, a self-managed backend, and type-safe HTTP error/success representation, are demonstrated by the below example:\n\n```scala\n//\u003e using dep com.softwaremill.sttp.client4::core:4.0.3\n\nimport sttp.client4.*\n\n@main def sttpDemo(): Unit =\n  val sort: Option[String] = None\n  val query = \"http language:scala\"\n\n  // the `query` parameter is automatically url-encoded\n  // `sort` is removed, as the value is not defined\n  val request = basicRequest.get(\n    uri\"https://api.github.com/search/repositories?q=$query\u0026sort=$sort\")\n\n  val backend = DefaultSyncBackend()\n  val response = request.send(backend)\n\n  // response.header(...): Option[String]\n  println(response.header(\"Content-Length\")) \n\n  // response.body: read into an Either[String, String] to indicate failure or success \n  println(response.body)\n```\n\nBut that's just a small glimpse of sttp client's features! For more examples, see the [usage examples](https://sttp.softwaremill.com/en/latest/examples.html). \n\n## Documentation\n\nsttp (v4) documentation is available at [sttp.softwaremill.com](https://sttp.softwaremill.com).\n\nsttp (v3) documentation is available at [sttp.softwaremill.com/en/v3](https://sttp.softwaremill.com/en/v3).\n\nsttp (v2) documentation is available at [sttp.softwaremill.com/en/v2](https://sttp.softwaremill.com/en/v2).\n\nsttp (v1) documentation is available at [sttp.softwaremill.com/en/v1](https://sttp.softwaremill.com/en/v1).\n\nscaladoc is available at [https://www.javadoc.io](https://www.javadoc.io/doc/com.softwaremill.sttp.client4/core_3/4.0.3)\n\n## Quickstart with scala-cli\n\nAdd the following directive to the top of your scala file to add the core sttp dependency:\nIf you are using [scala-cli](https://scala-cli.virtuslab.org), you can quickly start experimenting with sttp by copy-pasting the following:\n\n```\n//\u003e using dep \"com.softwaremill.sttp.client4::core:4.0.3\"\nimport sttp.client4.quick.*\nquickRequest.get(uri\"http://httpbin.org/ip\").send()\n```\n\nThe `quick` package import brings in the sttp API and a pre-configured, global synchronous backend instance.\n\n## Quickstart with Ammonite\n\nSimilarly, using [Ammonite](http://ammonite.io):\n\n```scala\nimport $ivy.`com.softwaremill.sttp.client4::core:4.0.3`\nimport sttp.client4.quick.*\nquickRequest.get(uri\"http://httpbin.org/ip\").send()\n```\n\n## Quickstart with sbt\n\nAdd the following dependency:\n\n```scala\n\"com.softwaremill.sttp.client4\" %% \"core\" % \"4.0.3\"\n```\n\nThen, import:\n\n```scala\nimport sttp.client4.*\n```\n\nType `basicRequest.` and see where your IDE’s auto-complete gets you!\n\n## Other sttp projects\n\nsttp is a family of Scala HTTP-related projects, and currently includes:\n\n* sttp client: this project\n* [sttp tapir](https://github.com/softwaremill/tapir): rapid development of self-documenting APIs\n* [sttp model](https://github.com/softwaremill/sttp-model): simple HTTP model classes (used by client \u0026 tapir)\n* [sttp shared](https://github.com/softwaremill/sttp-shared): shared web socket, FP abstractions, capabilities and streaming code.\n* [sttp apispec](https://github.com/softwaremill/sttp-apispec): OpenAPI, AsyncAPI and JSON Schema models.\n* [sttp openai](https://github.com/softwaremill/sttp-openai): Scala client wrapper for OpenAI and OpenAI-compatible APIs. Use the power of ChatGPT inside your code!\n\n## Contributing\n\nIf you have a question, suggestion, or hit a problem, feel free to ask on our [discourse forum](https://softwaremill.community/c/sttp-client)!\n\nOr, if you encounter a bug, something is unclear in the code or documentation, don’t hesitate and open an issue on GitHub.\n\nWe are also always looking for contributions and new ideas, so if you’d like to get into the project, check out the [open issues](https://github.com/softwaremill/sttp/issues), or post your own suggestions!\n\nNote that running the default `test` task will run the tests using both the JVM and JS backends, and is likely to run out of memory.\nIf you'd like to run the tests using *only* the JVM backend, execute: `sbt rootJVM/test`.\n\nWhen you have a PR ready, take a look at our [\"How to prepare a good PR\" guide](https://softwaremill.community/t/how-to-prepare-a-good-pr-to-a-library/448). Thanks! :)\n\n### Importing into IntelliJ\n\nBy default, when importing to IntelliJ or Metals, only the Scala 2.13/JVM subprojects will be imported. This is controlled by the `ideSkipProject` setting in `build.sbt` (inside `commonSettings`).\n\nIf you'd like to work on a different platform or Scala version, simply change this setting temporarily so that the correct subprojects are imported. For example:\n\n```\n// import only Scala 2.13, JS projects\nideSkipProject := (scalaVersion.value != scala2_13) || !thisProjectRef.value.project.contains(\"JS\")\n\n// import only Scala 3, JVM projects\nideSkipProject := (scalaVersion.value != scala3) || thisProjectRef.value.project.contains(\"JS\") || thisProjectRef.value.project.contains(\"Native\"),\n\n// import only Scala 2.13, Native projects\nideSkipProject := (scalaVersion.value != scala2_13) || !thisProjectRef.value.project.contains(\"Native\")\n```\n\n### Modifying documentation\n\nThe documentation is typechecked using [mdoc](https://scalameta.org/mdoc/). The sources for the documentation exist in `docs`. Don't modify the generated documentation in `generated-docs`, as these files will get overwritten!\n\nWhen generating documentation, it's best to set the version to the current one, so that the generated doc files don't include modifications with the current snapshot version. \n\nThat is, in sbt run: `set ThisBuild/version := \"4.0.3\"`, before running `mdoc` in `docs`.\n\n### Testing the Scala.JS backend\n\nIn order to run tests against JS backend you will need to install [Google Chrome](https://www.google.com/chrome/).\n\n### Building \u0026 testing the scala-native backend\n\nBy default, sttp-native will **not** be included in the aggregate build of the root project. To include it, define the `STTP_NATIVE` environmental variable before running sbt, e.g.:\n\n```\nSTTP_NATIVE=1 sbt\n```\n\nYou might need to install some additional libraries, see the [scala native](http://www.scala-native.org/en/latest/user/setup.html) documentation site. On macos, you might additionally need:\n\n```\nln -s /usr/local/opt/openssl/lib/libcrypto.dylib /usr/local/lib/\nln -s /usr/local/opt/openssl/lib/libssl.dylib /usr/local/lib/\n```\n\n## Commercial Support\n\nWe offer commercial support for sttp and related technologies, as well as development services. [Contact us](https://softwaremill.com) to learn more about our offer!\n\n## Copyright\n\nCopyright (C) 2017-2025 SoftwareMill [https://softwaremill.com](https://softwaremill.com).\n","funding_links":[],"categories":["HTTP","Scala","Web Development","Table of Contents","网络编程"],"sub_categories":["HTTP"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftwaremill%2Fsttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftwaremill%2Fsttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftwaremill%2Fsttp/lists"}