{"id":13736995,"url":"https://github.com/treeform/puppy","last_synced_at":"2025-04-03T12:16:19.067Z","repository":{"id":37571975,"uuid":"342803810","full_name":"treeform/puppy","owner":"treeform","description":"Puppy fetches via HTTP and HTTPS","archived":false,"fork":false,"pushed_at":"2024-03-01T13:17:11.000Z","size":2760,"stargazers_count":190,"open_issues_count":11,"forks_count":26,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-02-09T01:38:50.784Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Nim","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/treeform.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":"2021-02-27T08:07:14.000Z","updated_at":"2024-12-28T00:33:02.000Z","dependencies_parsed_at":"2024-01-06T12:02:59.915Z","dependency_job_id":"49215985-3d85-478b-b09d-aa7660b209de","html_url":"https://github.com/treeform/puppy","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":"treeform/nimtemplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeform%2Fpuppy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeform%2Fpuppy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeform%2Fpuppy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeform%2Fpuppy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/treeform","download_url":"https://codeload.github.com/treeform/puppy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246998229,"owners_count":20866696,"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-08-03T03:01:33.262Z","updated_at":"2025-04-03T12:16:19.036Z","avatar_url":"https://github.com/treeform.png","language":"Nim","readme":"\u003cimg src=\"docs/puppyBanner.png\"\u003e\n\n# Puppy - Fetch resources via HTTP and HTTPS.\n\n`nimble install puppy`\n\n![Github Actions](https://github.com/treeform/puppy/actions/workflows/build.yml/badge.svg)\n\n[API reference](https://treeform.github.io/puppy)\n\n## About\n\nPuppy makes HTTP requests easy!\n\nWith Puppy you can make HTTP requests without needing to pass the `-d:ssl` flag or shipping extra `*.dll`s and `cacerts.pem` on Windows. Puppy avoids these gotchas by using system APIs instead of Nim's HTTP stack.\n\nSome other highlights of Puppy are:\n\n* Supports gzip'ed responses out of the box\n* Make an HTTP request using a one-line `proc` call\n\nOS    |  Method\n----- | ---------------------------\nWin32 | WinHttp WinHttpRequest\nmacOS | AppKit NSMutableURLRequest\nLinux | libcurl easy_perform\n\n*Curently does not support async*\n\n## Easy mode\n\n```nim\necho fetch(\"http://neverssl.com/\")\n```\n\nA call to `fetch` will raise PuppyError if the response status code is not 200.\n\n## More request types\n\nMake a basic GET request:\n\n```nim\nimport puppy\n\nlet response = get(\"https://www.google.com/\")\n```\n\nNeed to pass headers?\n\n```nim\nimport puppy\n\nlet response = get(\n  \"http://neverssl.com/\",\n  headers = @[(\"User-Agent\", \"Nim 1.0\")]\n)\n```\n\nEasy one-line procs for your favorite verbs:\n\n```nim\ndiscard get(url, headers)\ndiscard post(url, headers, body)\ndiscard put(url, headers, body)\ndiscard patch(url, headers, body)\ndiscard delete(url, headers)\ndiscard head(url, headers)\n```\n\n## Working with responses\n\n```nim\nResponse* = ref object\n  headers*: HttpHeaders\n  code*: int\n  body*: string\n```\n\n```nim\nimport puppy\n\nlet response = get(\"http://www.istrolid.com\", @[(\"Auth\", \"1\")])\necho response.code\necho response.headers\necho response.body.len\n```\n\n```nim\nimport puppy\n\nlet body = \"{\\\"json\\\":true}\"\n\nlet response = post(\n    \"http://api.website.com\",\n    @[(\"Content-Type\", \"application/json\")],\n    body\n)\necho response.code\necho response.headers\necho response.body.len\n```\n\n## More examples\n\nUsing multipart/form-data:\n\n```nim\nvar entries: seq[MultipartEntry]\nentries.add MultipartEntry(\n  name: \"input_text\",\n  fileName: \"input.txt\",\n  contentType: \"text/plain\",\n  payload: \"foobar\"\n)\nentries.add MultipartEntry(\n  name: \"options\",\n  payload: \"{\\\"utf8\\\":true}\"\n)\n\nlet (contentType, body) = encodeMultipart(entries)\n\nvar headers: HttpHeaders\nheaders[\"Content-Type\"] = contentType\n\nlet response = post(\"Your API endpoint here\", headers, body)\n```\n\nSee the [examples/](https://github.com/treeform/puppy) folder for more examples.\n\n## Always use libcurl\n\nYou can pass `-d:puppyLibcurl` to force use of `libcurl` even on Windows and macOS. This is useful if for some reason the native OS API is not working.\n\nLibcurl is typically ready-to-use on macOS and Linux. On Windows you'll need to grab the latest libcurl DLL from https://curl.se/windows/, rename it to libcurl.dll, and put it in the same directory as your executable.\n","funding_links":[],"categories":["Web"],"sub_categories":["Protocols"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreeform%2Fpuppy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftreeform%2Fpuppy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreeform%2Fpuppy/lists"}