explaingit

libcpr/cpr

7,329C++Audience · developerComplexity · 2/5Setup · moderate

TLDR

A C++ library that makes HTTP requests simple, GET, POST, file uploads, with a clean one-line function call instead of the dozens of lines of setup code that libcurl normally requires.

Mindmap

mindmap
  root((repo))
    What it does
      HTTP requests
      Simple interface
      Wraps libcurl
    Request Types
      GET
      POST
      DELETE
    Features
      Authentication
      Async requests
      Proxy support
    Tech Stack
      C++
      libcurl
      CMake
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Fetch JSON data from a REST API in a C++ application with a single readable GET call instead of libcurl boilerplate

USE CASE 2

Send POST requests with form fields or file uploads to a web server from a C++ program

USE CASE 3

Make asynchronous HTTP requests in a multi-threaded C++ application so the rest of the program keeps running while waiting for a response

Tech stack

C++libcurlCMake

Getting it running

Difficulty · moderate Time to first run · 30min

Requires a C++17-compatible compiler, CMake integration pulls in libcurl automatically as a dependency.

In plain English

CPR (C++ Requests) is a C++ library for making HTTP requests, the kind of network call an application makes when it needs to talk to a web server or external API. The library wraps an older, lower-level tool called libcurl, which works reliably but requires a lot of boilerplate code to use directly. CPR hides that complexity behind a simpler interface, modeled after Python's popular Requests library. In practice this means that fetching data from a web address, sending form data, or uploading a file goes from dozens of lines of configuration code down to a single readable function call. The library supports all common request types: GET (fetch data), POST (submit data), PUT (update), DELETE, and others used in web APIs. It also handles authentication (Basic, Bearer, Digest, and NTLM), cookies, proxy servers, connection timeouts, and HTTPS encryption. Requests can be made synchronously, where your program waits for the response before continuing, or asynchronously, where the request runs in the background and a callback is triggered when the response arrives. The library is built to work safely when multiple parts of a program are making requests at the same time, which is a requirement in multi-threaded applications. Installation is available through several routes. C++ projects using CMake can pull CPR in automatically as a dependency without managing libcurl separately. Package managers exist for Arch Linux, Fedora, Windows (NuGet), macOS (MacPorts), and FreeBSD. A C++17-compatible compiler is required for current versions, though older releases supported C++11.

Copy-paste prompts

Prompt 1
I'm writing a C++ app with CMake and want to use CPR to call a REST API endpoint and parse the JSON response. Show me how to add CPR as a CMake dependency and write a GET request that prints the response body.
Prompt 2
I need to POST form data with a file attachment to an HTTP endpoint from my C++ program using CPR. Show me the code to build the request with form fields and a file upload.
Prompt 3
I want to make async HTTP GET requests in my multi-threaded C++ app using CPR so the main thread isn't blocked. Show me how to use CPR's async API and handle the response in a callback.
Open on GitHub → Explain another repo

← libcpr on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.