{"id":14990039,"url":"https://github.com/oatpp/oatpp-curl","last_synced_at":"2025-04-12T02:03:19.679Z","repository":{"id":64004997,"uuid":"155787407","full_name":"oatpp/oatpp-curl","owner":"oatpp","description":"RequestExecutor for oatpp's ApiClient based on libcurl. Supports both Sync and Async APIs.","archived":false,"fork":false,"pushed_at":"2024-05-16T21:12:19.000Z","size":95,"stargazers_count":10,"open_issues_count":4,"forks_count":14,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-10-29T22:53:38.120Z","etag":null,"topics":["cloud","cpp11","libcurl","oatpp","rest-client","web-client"],"latest_commit_sha":null,"homepage":"https://oatpp.io/","language":"C++","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/oatpp.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":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-01T23:17:17.000Z","updated_at":"2024-06-08T15:42:12.000Z","dependencies_parsed_at":"2023-01-14T18:30:25.185Z","dependency_job_id":"2c54ec66-3e3c-4693-bc43-adf29e8f0cf4","html_url":"https://github.com/oatpp/oatpp-curl","commit_stats":{"total_commits":53,"total_committers":1,"mean_commits":53.0,"dds":0.0,"last_synced_commit":"4f7038597191409fa777789fcfd603ddc3d2e18c"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oatpp%2Foatpp-curl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oatpp%2Foatpp-curl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oatpp%2Foatpp-curl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oatpp%2Foatpp-curl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oatpp","download_url":"https://codeload.github.com/oatpp/oatpp-curl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239753995,"owners_count":19691225,"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":["cloud","cpp11","libcurl","oatpp","rest-client","web-client"],"created_at":"2024-09-24T14:19:22.291Z","updated_at":"2025-02-20T15:30:52.854Z","avatar_url":"https://github.com/oatpp.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# oatpp-curl [![Build Status](https://dev.azure.com/lganzzzo/lganzzzo/_apis/build/status/oatpp.oatpp-curl?branchName=master)](https://dev.azure.com/lganzzzo/lganzzzo/_build?definitionId=5\u0026branchName=master)\n\n**oatpp-curl** is a wrapper over the libcurl. It adapts libcurl to be used as a `RequestExecutor` in the oatpp's `ApiClient`.  \nIt supports all features of oatpp ApiClient together with Synchronous and Asynchronous oatpp's APIs.\n\nMore about Oat++:\n- [Oat++ Website](https://oatpp.io/)\n- [Api Client Documentation](https://oatpp.io/docs/component/api-client)\n- [Api Client Demo](https://github.com/oatpp/oatpp-examples/tree/master/ApiClient-Demo)\n\n**Please note:**\n*it is recommended to use native out-of-the-box `oatpp::web::client::HttpRequestExecutor`. It is better integrated \nwith oatpp and supports additional features like connection pools, retries, streaming of large data, and custom transport substitution.*  \n*oatpp-curl provided mostly for demo purposes, documentation, and rare cases where functionality of oatpp native executor is not enough.*\n\n## Requires\n\nlibcurl installed.\n\n## oatpp ApiClient ?\n\noatpp ```ApiClient``` is a mechanism which enables you to generate Web Api Clients in declarative manner.\nUnder the hood it uses provided ```RequestExecutor``` (ex.: ```oatpp::curl::RequestExecutor```) to perform http requests. Thus you are abstracted from the low-level http-client library implementation and can substitute any other http-client library at any time with zero code changes.  \n*Roughly you may treat oatpp ```ApiClient``` as Java Retrofit for C++.*\n\n### Example\n\n*This example is partially taken from [oatpp-consul](https://github.com/oatpp/oatpp-consul) implementation*  \n\n#### Declare ApiClient\n\nDeclare ```ApiClient``` for remote service using code-generation\n\n```c++\nclass MyApiClient : public oatpp::web::client::ApiClient {\n#include OATPP_CODEGEN_BEGIN(ApiClient)\n  \n  API_CLIENT_INIT(DemoApiClient)\n  \n  API_CALL(\"GET\", \"v1/kv/{key}\", kvGet, PATH(String, key))\n  API_CALL(\"GET\", \"v1/kv/{key}\", kvGetInDC, PATH(String, key), QUERY(String, datacenter, \"dc\"))\n  \n  API_CALL(\"GET\", \"v1/kv/{key}?raw\", kvGetRaw, PATH(String, key))\n  API_CALL(\"GET\", \"v1/kv/{key}?raw\u0026dc={dc}\", kvGetRawInDC, PATH(String, key), PATH(String, datacenter, \"dc\"))\n  \n  API_CALL(\"PUT\", \"v1/kv/{key}\", kvPut, PATH(String, key), BODY_STRING(String, data))\n  API_CALL(\"PUT\", \"v1/kv/{key}\", kvPutInDC, PATH(String, key), BODY_STRING(String, data), QUERY(String, datacenter, \"dc\"))\n  \n#include OATPP_CODEGEN_END(ApiClient)\n};\n```\n\n#### Create ApiClient instance\n\nCreate MyApiClient instance and configure it to use ```oatpp::curl::RequestExecutor```\n\n```c++\n/* Create ObjectMapper for serialization of DTOs  */\nauto objectMapper = oatpp::parser::json::mapping::ObjectMapper::createShared();\n\n/* Create oatpp-curl RequestExecutor with baseUrl */\nauto requestExecutor = oatpp::curl::RequestExecutor::createShared(\"http://localhost:8500/\");\n\n/* Instantiate MyApiClient */\nauto myApiClient = MyApiClient::createShared(requestExecutor, objectMapper);\n```\n\n#### Make calls\n\n```c++\n\n// like that...\n\nauto value = myApiClient-\u003ekvGetRaw(\"key\")-\u003ereadBodyToString();\nOATPP_LOGD(\"response\", \"value='%s'\", value-\u003ec_str());\n\n// or like that...\n\nauto response = myApiClient-\u003ekvPut(\"key\", \"some-value\");\nif(response-\u003estatusCode == 200){\n  auto body = response-\u003ereadBodyToString();\n  if(body \u0026\u0026 body == \"true\") {\n    OATPP_LOGD(\"response\", \"value successfully saved\");\n  }\n}\n```\n\n## More\n\n- [oatpp-examples/ApiClient-Demo](https://github.com/oatpp/oatpp-examples/tree/master/ApiClient-Demo) - Full example project. ApiClient to ```http://httpbin.org/``` API with Sync and Async examples.\n- [oatpp-consul](https://github.com/oatpp/oatpp-consul) - oatpp-consul integration based on ```ApiClient```.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foatpp%2Foatpp-curl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foatpp%2Foatpp-curl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foatpp%2Foatpp-curl/lists"}