{"id":13478547,"url":"https://github.com/http-rs/surf","last_synced_at":"2025-05-14T03:08:16.322Z","repository":{"id":35080025,"uuid":"195634777","full_name":"http-rs/surf","owner":"http-rs","description":"Fast and friendly HTTP client framework for async Rust","archived":false,"fork":false,"pushed_at":"2023-09-11T14:52:24.000Z","size":374,"stargazers_count":1462,"open_issues_count":99,"forks_count":120,"subscribers_count":17,"default_branch":"main","last_synced_at":"2024-10-29T15:04:20.255Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.rs/surf","language":"Rust","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/http-rs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-07-07T09:48:40.000Z","updated_at":"2024-10-29T10:58:54.000Z","dependencies_parsed_at":"2024-02-03T21:50:37.017Z","dependency_job_id":null,"html_url":"https://github.com/http-rs/surf","commit_stats":{"total_commits":230,"total_committers":45,"mean_commits":5.111111111111111,"dds":0.7173913043478262,"last_synced_commit":"de0e5e5eee442325d03cc6c6f4e1066d61e9cf4e"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/http-rs%2Fsurf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/http-rs%2Fsurf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/http-rs%2Fsurf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/http-rs%2Fsurf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/http-rs","download_url":"https://codeload.github.com/http-rs/surf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248261935,"owners_count":21074226,"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":[],"created_at":"2024-07-31T16:01:58.563Z","updated_at":"2025-04-10T17:19:50.560Z","avatar_url":"https://github.com/http-rs.png","language":"Rust","funding_links":[],"categories":["Rust","Programming Languages"],"sub_categories":["Rust"],"readme":"\u003ch1 align=\"center\"\u003eSurf\u003c/h1\u003e\n\u003cdiv align=\"center\"\u003e\n \u003cstrong\u003e\n   Surf the web\n \u003c/strong\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003c!-- Crates version --\u003e\n  \u003ca href=\"https://crates.io/crates/surf\"\u003e\n    \u003cimg src=\"https://img.shields.io/crates/v/surf.svg?style=flat-square\"\n    alt=\"Crates.io version\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Downloads --\u003e\n  \u003ca href=\"https://crates.io/crates/surf\"\u003e\n    \u003cimg src=\"https://img.shields.io/crates/d/surf.svg?style=flat-square\"\n      alt=\"Download\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- docs.rs docs --\u003e\n  \u003ca href=\"https://docs.rs/surf\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square\"\n      alt=\"docs.rs docs\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch3\u003e\n    \u003ca href=\"https://docs.rs/surf\"\u003e\n      API Docs\n    \u003c/a\u003e\n    \u003cspan\u003e | \u003c/span\u003e\n    \u003ca href=\"https://github.com/http-rs/surf/blob/main/.github/CONTRIBUTING.md\"\u003e\n      Contributing\n    \u003c/a\u003e\n    \u003cspan\u003e | \u003c/span\u003e\n    \u003ca href=\"https://discord.com/invite/x2gKzst\"\u003e\n      Chat\n    \u003c/a\u003e\n  \u003c/h3\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003csub\u003eBuilt with 🌊 by \u003ca href=\"https://github.com/http-rs\"\u003eThe http-rs team\u003c/a\u003e\n\u003c/div\u003e\n\n\u003cbr/\u003e\n\n### Surf the web - HTTP client framework\n\nSurf is a Rust HTTP client built for ease-of-use and multi-HTTP-backend flexibility.\nWhether it's a quick script, or a cross-platform SDK, Surf will make it work.\n\n- Extensible through a powerful middleware system\n- Multiple HTTP back-ends that can be chosen\n- Reuses connections through a configurable `Client` interface\n- Fully streaming requests and responses\n- TLS enabled by default (native tls or rustls)\n- Built on async-std (with optional tokio support)\n\n## Examples\n```rust\nlet mut res = surf::get(\"https://httpbin.org/get\").await?;\ndbg!(res.body_string().await?);\n```\n\nIt's also possible to skip the intermediate `Response`, and access the response type directly.\n```rust\ndbg!(surf::get(\"https://httpbin.org/get\").recv_string().await?);\n```\n\nBoth sending and receiving JSON is real easy too.\n```rust\n#[derive(Deserialize, Serialize)]\nstruct Ip {\n    ip: String\n}\n\nlet uri = \"https://httpbin.org/post\";\nlet data = \u0026Ip { ip: \"129.0.0.1\".into() };\nlet res = surf::post(uri).body_json(data)?.await?;\nassert_eq!(res.status(), 200);\n\nlet uri = \"https://api.ipify.org?format=json\";\nlet Ip { ip } = surf::get(uri).recv_json().await?;\nassert!(ip.len() \u003e 10);\n```\n\nAnd even creating streaming proxies is no trouble at all.\n\n```rust\nlet req = surf::get(\"https://img.fyi/q6YvNqP\").await?;\nlet body = surf::http::Body::from_reader(req, None);\nlet res = surf::post(\"https://box.rs/upload\").body(body).await?;\n```\n\nSetting configuration on a client is also straightforward.\n\n```rust\nuse std::convert::TryInto;\nuse std::time::Duration;\nuse surf::{Client, Config};\nuse surf::Url;\n\nlet client: Client = Config::new()\n    .set_base_url(Url::parse(\"http://example.org\")?)\n    .set_timeout(Some(Duration::from_secs(5)))\n    .try_into()?;\n\nlet mut res = client.get(\"/\").await?;\nprintln!(\"{}\", res.body_string().await?);\n```\n\n## Features\nThe following features are available. The default features are\n`curl-client`, `middleware-logger`, and `encoding`\n- __`curl-client` (default):__ use `curl` (through `isahc`) as the HTTP backend.\n- __`h1-client`:__ use `async-h1` as the HTTP backend with native TLS for HTTPS.\n- __`h1-client-rustls`:__ use `async-h1` as the HTTP backend with `rustls` for HTTPS.\n- __`hyper-client`:__ use `hyper` (hyper.rs) as the HTTP backend.\n- __`wasm-client`:__ use `window.fetch` as the HTTP backend.\n- __`middleware-logger` (default):__ enables logging requests and responses using a middleware.\n- __`encoding` (default):__ enables support for body encodings other than utf-8.\n\n## Installation\n\nInstall OpenSSL - \n- Ubuntu - ``` sudo apt install libssl-dev ```\n- Fedora - ``` sudo dnf install openssl-devel ```\n\nMake sure your rust is up to date using: \n``` rustup update ```\n\nWith [cargo add](https://github.com/killercup/cargo-edit#Installation) installed :\n```sh\n$ cargo add surf\n```\n\n## Safety\n\nThis crate makes use of a single instance of `unsafe` in order to make the WASM\nbackend work despite the `Send` bounds. This is safe because WASM targets\ncurrently have no access to threads. Once they do we'll be able to drop this\nimplementation, and use a parked thread instead and move to full multi-threading\nin the process too.\n\n## Contributing\n\nWant to join us? Check out our [\"Contributing\" guide][contributing] and take a\nlook at some of these issues:\n\n- [Issues labeled \"good first issue\"][good-first-issue]\n- [Issues labeled \"help wanted\"][help-wanted]\n\n## See Also\n\n- [http-rs/http-client](https://github.com/http-rs/http-client)\n- [http-rs/http-service](https://github.com/http-rs/http-service)\n- [http-rs/tide](https://github.com/http-rs/tide)\n\n## Thanks\n\nSpecial thanks to [prasannavl](https://github.com/prasannavl) for donating the\ncrate name, and [sagebind](https://github.com/sagebind) for creating an easy to\nuse `async` curl client that saved us countless hours.\n\n## License\n\n[MIT](./LICENSE-MIT) OR [Apache-2.0](./LICENSE-APACHE)\n\n[1]: https://img.shields.io/crates/v/surf.svg?style=flat-square\n[2]: https://crates.io/crates/surf\n[3]: https://img.shields.io/travis/http-rs/surf/main.svg?style=flat-square\n[4]: https://travis-ci.org/http-rs/surf\n[5]: https://img.shields.io/crates/d/surf.svg?style=flat-square\n[6]: https://crates.io/crates/surf\n[7]: https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square\n[8]: https://docs.rs/surf\n[releases]: https://github.com/http-rs/surf/releases\n[contributing]: https://github.com/http-rs/surf/blob/main/.github/CONTRIBUTING.md\n[good-first-issue]: https://github.com/http-rs/surf/labels/good%20first%20issue\n[help-wanted]: https://github.com/http-rs/surf/labels/help%20wanted\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhttp-rs%2Fsurf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhttp-rs%2Fsurf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhttp-rs%2Fsurf/lists"}