{"id":23582484,"url":"https://github.com/rezwanahmedsami/ipapi-cpp","last_synced_at":"2025-11-02T18:30:34.507Z","repository":{"id":267520496,"uuid":"901512648","full_name":"rezwanahmedsami/ipapi-cpp","owner":"rezwanahmedsami","description":"A C++ library to query IP addresses using the https://ipquery.io API.","archived":false,"fork":false,"pushed_at":"2024-12-11T10:00:06.000Z","size":149,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-27T01:11:56.445Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/rezwanahmedsami.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":"2024-12-10T19:49:19.000Z","updated_at":"2024-12-25T23:59:11.000Z","dependencies_parsed_at":"2024-12-10T20:36:34.272Z","dependency_job_id":"e3077085-e678-41c3-a7e6-27f5c5fa1cc8","html_url":"https://github.com/rezwanahmedsami/ipapi-cpp","commit_stats":null,"previous_names":["rezwanahmedsami/ipapi-cpp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezwanahmedsami%2Fipapi-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezwanahmedsami%2Fipapi-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezwanahmedsami%2Fipapi-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rezwanahmedsami%2Fipapi-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rezwanahmedsami","download_url":"https://codeload.github.com/rezwanahmedsami/ipapi-cpp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239399809,"owners_count":19632022,"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":[],"created_at":"2024-12-27T01:11:44.792Z","updated_at":"2025-02-18T02:44:52.503Z","avatar_url":"https://github.com/rezwanahmedsami.png","language":"C++","readme":"# ipapi\n\nA C++ library to query IP addresses using the [ipquery.io](https://ipquery.io) API.\n\n## Features\n\n- Query details for a specific IP address\n- Bulk query multiple IP addresses\n- Fetch your own public IP address\n\n## Installation\n\nTo use this library, include the `ipapi.h` and link the necessary dependencies for HTTP requests (e.g., libcurl).\n\n### Prerequisites\n\n- A C++17 or later compiler\n- `libcurl` for making HTTP requests\n\nInstall `libcurl`:\n```bash\n# Ubuntu\nsudo apt-get install libcurl4-openssl-dev\n\n# macOS (using Homebrew)\nbrew install curl\n```\n\nInclude the following files in your project:\n- `ipapi.h`\n- `ipapi.cpp`\n\n## Usage\n\n### Query a Specific IP Address\n\nThe `query_ip` function retrieves information about a specific IP address, including its ISP, location, and risk data.\n\n```cpp\n#include \u003ciostream\u003e\n#include \"ipapi.h\"\n\nint main() {\n    auto ip_info = ipapi::query_ip(\"8.8.8.8\");\n    if (ip_info) {\n        std::cout \u003c\u003c *ip_info \u003c\u003c std::endl;\n    } else {\n        std::cerr \u003c\u003c \"Failed to fetch IP information.\" \u003c\u003c std::endl;\n    }\n    return 0;\n}\n```\n\n#### Output Example\n```plaintext\nIPInfo {\n    ip: \"8.8.8.8\",\n    isp: { asn: \"AS15169\", org: \"Google LLC\", isp: \"Google LLC\" },\n    location: {\n        country: \"United States\",\n        country_code: \"US\",\n        city: \"Mountain View\",\n        state: \"California\",\n        zipcode: \"94035\",\n        latitude: 37.386,\n        longitude: -122.0838,\n        timezone: \"America/Los_Angeles\",\n        localtime: \"2024-11-09T12:45:32\"\n    },\n    risk: {\n        is_mobile: false,\n        is_vpn: false,\n        is_tor: false,\n        is_proxy: false,\n        is_datacenter: true,\n        risk_score: 0\n    }\n}\n```\n\n### Bulk Query Multiple IP Addresses\n\nThe `query_bulk` function allows you to query information for multiple IP addresses at once.\n\n```cpp\n#include \u003ciostream\u003e\n#include \"ipapi.h\"\n\nint main() {\n    std::vector\u003cstd::string\u003e ips = {\"8.8.8.8\", \"1.1.1.1\"};\n    auto ip_infos = ipapi::query_bulk(ips);\n    for (const auto\u0026 info : ip_infos) {\n        std::cout \u003c\u003c info \u003c\u003c std::endl;\n    }\n    return 0;\n}\n```\n\n#### Output Example\n```plaintext\nIPInfo {\n    ip: \"8.8.8.8\",\n    ...\n}\nIPInfo {\n    ip: \"1.1.1.1\",\n    ...\n}\n```\n\n### Fetch Your Own Public IP Address\n\nThe `query_own_ip` function retrieves the public IP address of the current machine.\n\n```cpp\n#include \u003ciostream\u003e\n#include \"ipapi.h\"\n\nint main() {\n    auto ip = ipapi::query_own_ip();\n    if (ip) {\n        std::cout \u003c\u003c \"Your IP Address: \" \u003c\u003c *ip \u003c\u003c std::endl;\n    } else {\n        std::cerr \u003c\u003c \"Failed to fetch public IP address.\" \u003c\u003c std::endl;\n    }\n    return 0;\n}\n```\n\n#### Output Example\n```plaintext\nYour IP Address: 203.0.113.45\n```\n\n## API Documentation\n\n### 1. `query_ip`\n\n#### Signature\n```cpp\nstd::optional\u003cIPInfo\u003e query_ip(const std::string\u0026 ip);\n```\n\n#### Description\nFetches detailed information about a specific IP address, including its ISP, location, and risk information.\n\n#### Parameters\n- `ip`: A `std::string` representing the IP address to query.\n\n#### Returns\n- `std::optional\u003cIPInfo\u003e` containing details about the IP address on success.\n- `std::nullopt` if the network request fails.\n\n---\n\n### 2. `query_bulk`\n\n#### Signature\n```cpp\nstd::vector\u003cIPInfo\u003e query_bulk(const std::vector\u003cstd::string\u003e\u0026 ips);\n```\n\n#### Description\nFetches information for multiple IP addresses at once. Useful for batch processing.\n\n#### Parameters\n- `ips`: A `std::vector\u003cstd::string\u003e` containing the list of IP addresses to query.\n\n#### Returns\n- A `std::vector\u003cIPInfo\u003e` containing details for each IP address.\n\n---\n\n### 3. `query_own_ip`\n\n#### Signature\n```cpp\nstd::optional\u003cstd::string\u003e query_own_ip();\n```\n\n#### Description\nFetches the public IP address of the current machine.\n\n#### Returns\n- `std::optional\u003cstd::string\u003e` containing the public IP address on success.\n- `std::nullopt` if the network request fails.\n\n---\n\n## Running Tests\n\nTo run tests for this library, include and execute the `tests.cpp` file:\n```bash\n# initialize the cmake build first\ncmake -S . -B build\n\n# Build and test\ncmake --build build\ncd build \u0026\u0026 ctest\n```\n\n## Contributing\n\nContributions are welcome! Feel free to open issues or submit pull requests on the [GitHub repository](https://github.com/rezwanahmedsami/ipapi-cpp).\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frezwanahmedsami%2Fipapi-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frezwanahmedsami%2Fipapi-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frezwanahmedsami%2Fipapi-cpp/lists"}