{"id":13417879,"url":"https://github.com/libcpr/cpr","last_synced_at":"2026-04-10T10:02:19.896Z","repository":{"id":29616639,"uuid":"33157169","full_name":"libcpr/cpr","owner":"libcpr","description":"C++ Requests: Curl for People, a spiritual port of Python Requests.","archived":false,"fork":false,"pushed_at":"2026-02-27T08:52:22.000Z","size":2182,"stargazers_count":7282,"open_issues_count":80,"forks_count":1026,"subscribers_count":130,"default_branch":"master","last_synced_at":"2026-03-18T00:04:38.299Z","etag":null,"topics":["c-plus-plus","cpp","hacktoberfest","http","libcurl","library","requests"],"latest_commit_sha":null,"homepage":"https://docs.libcpr.dev/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/libcpr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"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,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2015-03-31T01:10:42.000Z","updated_at":"2026-03-17T17:57:42.000Z","dependencies_parsed_at":"2023-10-15T08:56:51.750Z","dependency_job_id":"a2d005e4-aee8-477c-91ba-75bbbc1d8454","html_url":"https://github.com/libcpr/cpr","commit_stats":{"total_commits":1519,"total_committers":159,"mean_commits":9.553459119496855,"dds":0.695852534562212,"last_synced_commit":"5f475522597b8f3721e2440daddeced7a969f24c"},"previous_names":["whoshuu/cpr"],"tags_count":52,"template":false,"template_full_name":null,"purl":"pkg:github/libcpr/cpr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libcpr%2Fcpr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libcpr%2Fcpr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libcpr%2Fcpr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libcpr%2Fcpr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libcpr","download_url":"https://codeload.github.com/libcpr/cpr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libcpr%2Fcpr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31637748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T07:40:12.752Z","status":"ssl_error","status_checked_at":"2026-04-10T07:40:11.664Z","response_time":98,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["c-plus-plus","cpp","hacktoberfest","http","libcurl","library","requests"],"created_at":"2024-07-30T22:00:54.671Z","updated_at":"2026-04-10T10:02:19.889Z","avatar_url":"https://github.com/libcpr.png","language":"C++","readme":"# C++ Requests: Curl for People \u003cimg align=\"right\" height=\"40\" src=\"http://i.imgur.com/d9Xtyts.png\"\u003e\n\n[![Documentation](https://img.shields.io/badge/docs-online-informational?style=flat\u0026link=https://docs.libcpr.dev/)](https://docs.libcpr.dev/)\n![CI](https://github.com/libcpr/cpr/workflows/CI/badge.svg)\n[![Gitter](https://badges.gitter.im/libcpr/community.svg)](https://gitter.im/libcpr/community?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n\n## Announcements\n\n* This project is being maintained by [Fabian Sauter](https://github.com/com8) and [Kilian Traub](https://github.com/KingKili).\n* For quick help, and discussion libcpr also offers a [gitter](https://gitter.im/libcpr/community?utm_source=share-link\u0026utm_medium=link\u0026utm_campaign=share-link) chat.\n\n## Supported Releases\n| Release                   | Min. C++ Standard | Status                   | Notes |\n|---------------------------|-------------------|--------------------------|-------|\n| master                    | `cpp17`           | ![alt text][preview]     |       |\n| 1.14.x                    | `cpp17`           | ![alt text][supported]   |       |\n| 1.10.x - 1.13.x           | `cpp17`           | ![alt text][unsupported] |       |\n| \u003c= 1.9.x                  | `cpp11`           | ![alt text][unsupported] |       |\n\n[unsupported]: https://img.shields.io/badge/-unsupported-red \"unsupported\"\n[supported]: https://img.shields.io/badge/-supported-green \"supported\"\n[preview]: https://img.shields.io/badge/-preview-orange \"preview\"\n\n## TLDR\n\nC++ Requests is a simple wrapper around [libcurl](http://curl.haxx.se/libcurl) inspired by the excellent [Python Requests](https://github.com/kennethreitz/requests) project.\n\nDespite its name, libcurl's easy interface is far from simple, and errors and frustration often arise from mistakes or misuse. By leveraging the more expressive features of `C++17` (or `C++11` if using cpr \u003c`= 1.9.x), this library distills the process of making network calls into a few clear and concise idioms.\n\nHere's a quick GET request:\n\n```c++\n#include \u003ccpr/cpr.h\u003e\n\nint main(int argc, char** argv) {\n    cpr::Response r = cpr::Get(cpr::Url{\"https://api.github.com/repos/whoshuu/cpr/contributors\"},\n                      cpr::Authentication{\"user\", \"pass\", cpr::AuthMode::BASIC},\n                      cpr::Parameters{{\"anon\", \"true\"}, {\"key\", \"value\"}});\n    r.status_code;                  // 200\n    r.header[\"content-type\"];       // application/json; charset=utf-8\n    r.text;                         // JSON text string\n    return 0;\n}\n```\n\nAnd here's [less functional, more complicated code, without cpr](https://gist.github.com/whoshuu/2dc858b8730079602044).\n\n## Documentation\n\n[![Documentation](https://img.shields.io/badge/docs-online-informational?style=for-the-badge\u0026link=https://docs.libcpr.dev/)](https://docs.libcpr.dev/)\nYou can find the latest documentation [here](https://docs.libcpr.dev/). It's a work in progress, but it should give you a better idea of how to use the library than the [tests](https://github.com/libcpr/cpr/tree/master/test) currently do.\n\n## Features\n\nC++ Requests currently supports:\n\n* Custom headers\n* URL-encoded parameters\n* URL-encoded POST values\n* Multipart form POST upload\n* File POST upload\n* Basic authentication\n* Bearer authentication\n* Digest authentication\n* NTLM authentication\n* Connection and request timeout specification\n* Timeout for low speed connection\n* Asynchronous requests\n* :cookie: support!\n* Proxy support\n* Callback interfaces\n* PUT methods\n* DELETE methods\n* HEAD methods\n* OPTIONS methods\n* PATCH methods\n* Thread Safe access to [libCurl](https://curl.haxx.se/libcurl/c/threadsafe.html)\n* OpenSSL and WinSSL support for HTTPS requests\n* Server Sent Events (SSE) handling\n\n## Planned\n\nFor a quick overview about the planned features, have a look at the next [Milestones](https://github.com/libcpr/cpr/milestones).\n\n## Usage\n\n### CMake\n\n#### fetch_content:\nIf you already have a CMake project you need to integrate C++ Requests with, the primary way is to use `fetch_content`.\nAdd the following to your `CMakeLists.txt`.\n\n\n```cmake\ninclude(FetchContent)\nFetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git\n                         GIT_TAG f091b2c061b307ee89b164c39976fc9202a1c79d.12.0) # Replace with your desired git commit from: https://github.com/libcpr/cpr/releases\nFetchContent_MakeAvailable(cpr)\n```\n\nThis will produce the target `cpr::cpr` which you can link against the typical way:\n\n```cmake\ntarget_link_libraries(your_target_name PRIVATE cpr::cpr)\n```\n\nThat should do it!\nThere's no need to handle `libcurl` yourself. All dependencies are taken care of for you.\nAll of this can be found in an example [**here**](https://github.com/libcpr/example-cmake-fetch-content).\n\n#### find_package():\nIf you prefer not to use `fetch_content`, you can download, build, and install the library and then use CMake `find_package()` function to integrate it into a project.\n\n**Note:** this feature is feasible only if CPR_USE_SYSTEM_CURL is set. (see [#645](https://github.com/libcpr/cpr/pull/645))\n```Bash\ngit clone https://github.com/libcpr/cpr.git\ncd cpr \u0026\u0026 mkdir build \u0026\u0026 cd build\ncmake .. -DCPR_USE_SYSTEM_CURL=ON\ncmake --build . --parallel\nsudo cmake --install .\n```\n#### Build Static Library\nAs an alternative if you want to switch between a static or shared version of cpr use ['-DBUILD_SHARED_LIBS=ON/OFF'](https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html).\n```Bash\ngit clone https://github.com/libcpr/cpr.git\ncd cpr \u0026\u0026 mkdir build \u0026\u0026 cd build\ncmake .. -DCPR_USE_SYSTEM_CURL=ON -DBUILD_SHARED_LIBS=OFF\ncmake --build . --parallel\nsudo cmake --install .\n```\n\nIn your `CMakeLists.txt`:\n```cmake\nfind_package(cpr REQUIRED)\nadd_executable(your_target_name your_target_name.cpp)\ntarget_link_libraries(your_target_name PRIVATE cpr::cpr)\n```\n\n#### Tests\n`cpr` provides a bunch of tests that can be executed via the following commands.\n```Bash\ngit clone https://github.com/libcpr/cpr.git\ncd cpr \u0026\u0026 mkdir build \u0026\u0026 cd build\ncmake .. -DCPR_BUILD_TESTS=ON # There are other test related options like 'CPR_BUILD_TESTS_SSL' and 'CPR_BUILD_TESTS_PROXY'\ncmake --build . --parallel\nctest -VV # -VV is optional since it enables verbose output\n```\n\n### Bazel\n`cpr` can be added as an extension by adding the following lines to your bazel MODULE file (tested with Bazel 8). Edit the versions as needed.\n```starlark\nbazel_dep(name = \"curl\", version = \"8.8.0.bcr.3\")\ngit_repository = use_repo_rule(\"@bazel_tools//tools/build_defs/repo:git.bzl\", \"git_repository\")\ngit_repository(\n    name = \"cpr\",\n    build_file = \"//path/to/build:cpr.BUILD\",\n    commit = \"516cb3e5f4e38bede088f69fcf122c6089e38f00\",\n    remote = \"https://github.com/libcpr/cpr.git\",\n    patches = [\"//path/to/patch:cpr.PATCH\"]\n)\n```\n\n```starlark\n// cpr.BUILD\ncc_library(\n    name = \"cpr\",\n    hdrs = glob([\"include/**/*.h\"]),\n    includes = [\"include\"],\n    visibility = [\"//visibility:public\"],\n\n    srcs = glob([\"cpr/**/*.cpp\"]),\n    deps = [\n        \"@curl//:curl\"\n    ],\n)\n```\n\n```starlark\n// Remove this line: cpr.PATCH\n--- include/cpr/cpr.h\n+++ include/cpr/cpr.h\n@@ -10,7 +10,6 @@\n #include \"cpr/connection_pool.h\"\n #include \"cpr/cookies.h\"\n #include \"cpr/cprtypes.h\"\n-#include \"cpr/cprver.h\"\n #include \"cpr/curl_container.h\"\n #include \"cpr/curlholder.h\"\n #include \"cpr/error.h\"\n```\n\n### Packages for Linux Distributions\n\nAlternatively, you may install a package specific to your Linux distribution. Since so few distributions currently have a package for cpr, most users will not be able to run your program with this approach.\n\nCurrently, we are aware of packages for the following distributions:\n\n* [Arch Linux (AUR)](https://aur.archlinux.org/packages/cpr)\n* [Fedora Linux](https://src.fedoraproject.org/rpms/cpr)\n\nIf there's no package for your distribution, try making one! If you do, and it is added to your distribution's repositories, please submit a pull request to add it to the list above. However, please only do this if you plan to actively maintain the package.\n\n### NuGet Package\n\nFor Windows, there is also a libcpr NuGet package available. Currently, x86 and x64 builds are supported with release and debug configuration.\n\nThe package can be found here: [NuGet.org](https://www.nuget.org/packages/libcpr/)\n\n### Port for macOS\n\nOn macOS you may install cpr via [MacPorts.org](https://ports.macports.org/port/cpr) (arm64, x86_64, powerpc)\n\n### FreeBSD Port\n\nOn FreeBSD, you can issue `pkg install cpr` or use the Ports tree to install it.\n\n## Requirements\n\nThe only explicit requirements are:\n\n* A `C++17` compatible compiler such as Clang or GCC. The minimum required version of GCC is unknown, so if anyone has trouble building this library with a specific version of GCC, do let us know.\n* In case you only have a `C++11` compatible compiler available, all versions below cpr 1.9.x are for you. The 1.10.0 release of cpr switches to `C++17` as a requirement.\n* If you would like to perform https requests `OpenSSL` and its development libraries are required.\n* If you do not use the built-in version of [curl](https://github.com/curl/curl) but instead use your systems version, make sure you use a version `\u003e= 7.71.0`. Lower versions are not supported. This means you need Debian `\u003e= 11` or Ubuntu `\u003e= 22.04 LTS`.\n* [`The Meson Build System`](https://mesonbuild.com/) is required build PSL from source ([PSL support for curl](https://everything.curl.dev/build/deps.html#libpsl)). For more information take a look at the `CPR_CURL_USE_LIBPSL` and `CPR_USE_SYSTEM_LIB_PSL` CMake options.\n\n## Building cpr - Using vcpkg\n\nYou can download and install cpr using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:\n```Bash\ngit clone https://github.com/Microsoft/vcpkg.git\ncd vcpkg\n./bootstrap-vcpkg.sh\n./vcpkg integrate install\n./vcpkg install cpr\n```\nThe `cpr` port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.\n\n## Building cpr - Using Conan\n\nYou can download and install `cpr` using the [Conan](https://conan.io/) package manager. Setup your CMakeLists.txt (see [Conan documentation](https://docs.conan.io/en/latest/integrations/build_system.html) on how to use MSBuild, Meson and others).\nAn example can be found [**here**](https://github.com/libcpr/example-cmake-conan).\n\nThe `cpr` package in Conan is kept up to date by Conan contributors. If the version is out of date, please [create an issue or pull request](https://github.com/conan-io/conan-center-index) on the `conan-center-index` repository.\n","funding_links":[],"categories":["TODO scan for Android support in followings","C++","C/C++ 程序设计","Networking","Programming Languages"],"sub_categories":["网络服务_其他","C++"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibcpr%2Fcpr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibcpr%2Fcpr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibcpr%2Fcpr/lists"}