How do I connect a REST API with C++?

This page summarizes the projects mentioned and recommended in the original post on /r/cpp_questions

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • boost

    My personal boost mirror to be submoduled by my projects (by darwin)

  • If you have the ability to use third-party libraries (though if you can't this project is going to be a nightmare, lol...) I would recommend using the Beast library from the Boost collection of libraries. It's a little bit more verbose than some options, but not that much more, and it's better maintained. REST webservices are built on top of the HTTP framework, so it's just a matter of sending a HTTP GET request to a server (or POST/UPDATE/DELETE, depending on how exactly the api on the other end is implemented) and reading the response you get back. This is a very basic sample of a client sending a GET request to a server. If you need to change this to do a POST (or some other kind of request), there's only two real changes that need to be made:

  • restclient-cpp

    C++ client for making HTTP/REST requests

  • You just need something to talk to a REST API. There are lots of choices. E.g. https://github.com/mrtazz/restclient-cpp or libcurl if you want something lower level.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • beauty

    A Simple C++ Http server/client above Boost.Beast

  • You can try this one that I have written based on Boost.Beast. https://github.com/dfleury2/beauty

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts