{"id":13476093,"url":"https://github.com/mattn/zig-curl","last_synced_at":"2025-04-30T18:09:03.349Z","repository":{"id":50450851,"uuid":"519123058","full_name":"mattn/zig-curl","owner":"mattn","description":"cURL binding for Zig","archived":false,"fork":false,"pushed_at":"2022-07-30T14:26:22.000Z","size":20,"stargazers_count":36,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-30T18:08:56.390Z","etag":null,"topics":["curl","http-client","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-29T07:32:07.000Z","updated_at":"2025-02-26T13:04:25.000Z","dependencies_parsed_at":"2022-08-12T21:21:26.040Z","dependency_job_id":null,"html_url":"https://github.com/mattn/zig-curl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattn%2Fzig-curl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattn%2Fzig-curl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattn%2Fzig-curl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattn%2Fzig-curl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattn","download_url":"https://codeload.github.com/mattn/zig-curl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251758170,"owners_count":21638989,"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":["curl","http-client","zig"],"created_at":"2024-07-31T16:01:26.489Z","updated_at":"2025-04-30T18:09:03.323Z","avatar_url":"https://github.com/mattn.png","language":"Zig","readme":"# zig-curl\n\ncURL binding for Zig\n\n## Usage\n\n```zig\nvar allocator = std.heap.page_allocator;\nvar f = struct {\n    fn f(data: []const u8) anyerror!usize {\n        try std.io.getStdOut().writeAll(data);\n        return data.len;\n    }\n}.f;\nvar res = try curl.get(\"https://google.com/\", .{ .allocator = allocator, .cb = f });\nif (res != 0) {\n    var msg = try curl.strerrorAlloc(allocator, res);\n    defer allocator.free(msg);\n    std.log.warn(\"{s}\", .{msg});\n}\n```\n\n## Requirements\n\n* libcurl\n\n## Installation\n\n```\n$ zig build\n```\n\n## Link to zig-curl\n\nadd following function into your build.zig.\n\n```zig\nfn linkToCurl(step: *std.build.LibExeObjStep) void {\n    var libs = if (builtin.os.tag == .windows) [_][]const u8{ \"c\", \"curl\", \"bcrypt\", \"crypto\", \"crypt32\", \"ws2_32\", \"wldap32\", \"ssl\", \"psl\", \"iconv\", \"idn2\", \"unistring\", \"z\", \"zstd\", \"nghttp2\", \"ssh2\", \"brotlienc\", \"brotlidec\", \"brotlicommon\" } else [_][]const u8{ \"c\", \"curl\" };\n    for (libs) |i| {\n        step.linkSystemLibrary(i);\n    }\n    if (builtin.os.tag == .linux) {\n        step.linkSystemLibraryNeeded(\"libcurl\");\n    }\n    if (builtin.os.tag == .windows) {\n        step.include_dirs.append(.{ .raw_path = \"c:/msys64/mingw64/include\" }) catch unreachable;\n        step.lib_paths.append(\"c:/msys64/mingw64/lib\") catch unreachable;\n    }\n}\n```\n\nThen, call for the step.\n\n```zig\nconst exe = b.addExecutable(\"zig-curl-example\", \"src/main.zig\");\nexe.setTarget(target);\nexe.setBuildMode(mode);\npkgs.addAllTo(exe);\nlinkToCurl(exe); // DO THIS\nexe.install();\n```\n\n## License\n\nMIT\n\n## Author\n\nYasuhiro Matsumoto (a.k.a. mattn)\n","funding_links":[],"categories":["Zig"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattn%2Fzig-curl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattn%2Fzig-curl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattn%2Fzig-curl/lists"}