{"id":15099196,"url":"https://github.com/mmaarij/secure-libcurl-json","last_synced_at":"2026-01-06T16:56:43.817Z","repository":{"id":200701237,"uuid":"706091809","full_name":"mmaarij/Secure-LibCurl-Json","owner":"mmaarij","description":"A C++ wrapper library that provides a convenient and secure way to make HTTP API requests, while handling JSON data. Built on top of libcurl for robust networking capabilities and nlohmann/json for JSON data processing.","archived":false,"fork":false,"pushed_at":"2023-10-18T11:47:51.000Z","size":7084,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"windows","last_synced_at":"2025-02-01T17:46:03.960Z","etag":null,"topics":["api","certificates","cpp","crud","https","json","libcurl","linux","ssl","windows"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmaarij.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2023-10-17T09:37:09.000Z","updated_at":"2023-10-18T08:55:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"ecf822ab-b674-4770-93ef-397037f6203a","html_url":"https://github.com/mmaarij/Secure-LibCurl-Json","commit_stats":{"total_commits":19,"total_committers":1,"mean_commits":19.0,"dds":0.0,"last_synced_commit":"dfd88447639ca81fb92ff6f6a78f8697d5076f53"},"previous_names":["mmaarij/secure-libcurl-json"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmaarij%2FSecure-LibCurl-Json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmaarij%2FSecure-LibCurl-Json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmaarij%2FSecure-LibCurl-Json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmaarij%2FSecure-LibCurl-Json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmaarij","download_url":"https://codeload.github.com/mmaarij/Secure-LibCurl-Json/tar.gz/refs/heads/windows","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245855196,"owners_count":20683469,"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":["api","certificates","cpp","crud","https","json","libcurl","linux","ssl","windows"],"created_at":"2024-09-25T17:07:30.601Z","updated_at":"2026-01-06T16:56:43.783Z","avatar_url":"https://github.com/mmaarij.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Secure [LibCurl](https://curl.se) Wrapper in C++ for HTTP(S) API Calls with [Nlohmann Json](https://github.com/nlohmann/json) Support\n\nThis project uses 2 simple files to create the wrapper with `SecureLibCurlJson.h` containing the definitions and `SecureLibCurlJson.cpp` containing all the implementaions.\n\nThis repository has 2 branches:\n\n1. [Windows](https://github.com/mmaarij/Secure-LibCurl-Json/tree/windows)\n2. [Linux](https://github.com/mmaarij/Secure-LibCurl-Json/tree/linux)\n\n### Table of Contents\n\n- [Windows (Visual Studio 2022)](#windows-visual-studio-2022)\n- [Linux (Tested on Ubuntu 22.04 LTS)](#linux-tested-on-ubuntu-2204-lts)\n- [Usage](#usage)\n\n---\n\n## Windows (Visual Studio 2022)\n\nThe entire Visual Studio 2022 Project is contained in the [Windows Branch](https://github.com/mmaarij/Secure-LibCurl-Json/tree/windows)\n\n### Project Settings for Libcurl\n\nNote : These steps have already been performed in the visual studio project included in this repo, but, they are documented if you need to setup a new project.\n\n- Download [Curl for Windows](https://curl.se/windows/)\n- Extract:\n  - The `include` and `lib` folders and keep them in a new folder called `[your-curl-dir]` (it is named `curl-8.4.0_3-win64-mingw` in this repo's case)\n  - The `bin/libcurl-x64.dll` file inside and keep it in your project directory.\n- Download [CA certificate extracted from Mozilla](https://curl.se/docs/caextract.html) `cacert.pem` and place it inside your project directory.\n- Add {your-curl-dir}/include to Configuration Properties -\u003e VC++ Directories -\u003e Include Directories.\n- Add {your-curl-dir}/lib to Configuration Properties -\u003e VC++ Directories -\u003e Library Directories.\n- In Configuration Properties -\u003e Linker -\u003e Input -\u003e Additional Dependencies, add these followings lines:\n\n```plaintext\n{your-curl-dir}/lib/libcurl_a.lib\nWs2_32.lib\nWldap32.lib\nCrypt32.lib\nNormaliz.lib\n```\n\n- In Configuration Properties -\u003e Build Events -\u003e Post-Build Event -\u003e Command Line add the following lines to copy necessary files when the .exe is generated:\n\n```plaintext\ncopy \"libcurl-x64.dll\" \"$(SolutionDir)$(Platform)\\$(Configuration)\\libcurl-x64.dll\"\ncopy \"cacert.pem\" \"$(SolutionDir)$(Platform)\\$(Configuration)\\cacert.pem\"\n```\n\n### Project Settings for Nlohmann Json\n\n- Download `json.hpp` from [Nlohmann Json](https://github.com/nlohmann/json/releases) and keep it in a folder called `nlohmann` in your project directory\n- You can now use the library as follows:\n\n```cpp\n#include \"nlohmann/json.hpp\"\n\nusing json = nlohmann::json;\n```\n\n### Directory Structure\n\nThis is what the directory structure should look like after setting up\n\n```plaintext\n.\n├── curl-8.4.0_3-win64-mingw/\n│   ├── include/\n│   │   └── [all the files inside include as-is]\n│   └── lib/\n│       └── [all the files inside lib as-is]\n├── nlohmann/\n│   └── json.hpp\n├── cacert.pem\n├── libcurl-x64.dll\n├── SecureLibCurlJson.h\n├── SecureLibCurlJson.cpp\n└── Source.cpp\n```\n\n---\n\n## Linux (Tested on Ubuntu 22.04 LTS)\n\nThe Linux code is contained in the [Linux Branch](https://github.com/mmaarij/Secure-LibCurl-Json/tree/linux)\n\n### Install Prerequisites (Libcurl and Nlohmann JSON)\n\nRun the following commands in the terminal\n\n```bash\nsudo apt update\nsudo apt upgrade\nsudo apt install libcurl4-openssl-dev\nsudo apt install nlohmann-json3-dev\n```\n\n### Download the updated [CA certificate extracted from Mozilla](https://curl.se/docs/caextract.html)\n\nRun the following command in the terminal from inside the directory with the source code\n\n```bash\ncurl --etag-compare etag.txt --etag-save etag.txt --remote-name https://curl.se/ca/cacert.pem\n```\n\n### Directory Structure\n\nThis is what the directory structure should look like\n\n```plaintext\n.\n├── cacert.pem\n├── etag.txt\n├── SecureLibCurlJson.h\n├── SecureLibCurlJson.cpp\n└── Source.cpp\n```\n\n### Compile\n\n```bash\ng++ -o SLCJ.out Source.cpp SecureLibCurlJson.cpp -lcurl\n```\n\n### Run the program\n\n```bash\n./SLCJ.out\n```\n\n---\n\n## Usage\n\nExample usage is provided in `Source.cpp`\n\n```cpp\n  SecureLibCurlJson curlLib(true);\n\n  std::string apiUrl = \"https://api.publicapis.org/entries\";\n  std::string requestType = \"GET\";\n\n  std::map\u003cstd::string, std::string\u003e queryParameters;\n  /*  EXAMPLE USAGE OF QUERY PARAMETERS\n  *   queryParameters[\"key\"] = \"abcxyz123\";\n  *   queryParameters[\"query\"] = \"helloworld\";\n  */\n\n  json bodyParameters;\n  /*  EXAMPLE USAGE OF BODY PARAMETERS\n  *   bodyParameters[\"value1\"] = \"one\";\n  *   bodyParameters[\"value2\"] = \"two\";\n  *   -- if json objects need to be nested --\n  *   json nestedValues;\n  *   nestedValues[\"nestedValue1\"] = \"n_one\";\n  *   nestedValues[\"nestedValue2\"] = \"n_two\";\n  *   bodyParameters[\"nested\"] = nestedValues;\n  */\n\n  json responseData = curlLib.MakeApiRequest(apiUrl, requestType, queryParameters, bodyParameters);\n\n  if (!responseData.empty())\n  {\n      std::cout \u003c\u003c \"Response Data: \" \u003c\u003c responseData.dump(2) \u003c\u003c std::endl;\n  }\n  else\n  {\n      std::cerr \u003c\u003c \"API request failed.\" \u003c\u003c std::endl;\n  }\n```\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmaarij%2Fsecure-libcurl-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmaarij%2Fsecure-libcurl-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmaarij%2Fsecure-libcurl-json/lists"}