{"id":13737055,"url":"https://github.com/mishankov/yahttp","last_synced_at":"2025-04-03T13:47:03.190Z","repository":{"id":208318486,"uuid":"720852728","full_name":"mishankov/yahttp","owner":"mishankov","description":"⛵ Awesome simple HTTP client for Nim","archived":false,"fork":false,"pushed_at":"2025-02-24T13:25:40.000Z","size":197,"stargazers_count":25,"open_issues_count":7,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T14:34:13.919Z","etag":null,"topics":["http-client","nim","nim-lang"],"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/mishankov.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":"2023-11-19T19:45:18.000Z","updated_at":"2025-02-24T13:50:56.000Z","dependencies_parsed_at":"2023-11-25T16:23:58.220Z","dependency_job_id":"ab4adeae-9df6-4452-a80e-d0b40f228526","html_url":"https://github.com/mishankov/yahttp","commit_stats":null,"previous_names":["mishankov/yahttp"],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mishankov%2Fyahttp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mishankov%2Fyahttp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mishankov%2Fyahttp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mishankov%2Fyahttp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mishankov","download_url":"https://codeload.github.com/mishankov/yahttp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247014506,"owners_count":20869371,"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":["http-client","nim","nim-lang"],"created_at":"2024-08-03T03:01:34.329Z","updated_at":"2025-04-03T13:47:03.137Z","avatar_url":"https://github.com/mishankov.png","language":"Nim","readme":"# ⛵ yahttp - Awesome simple HTTP client for Nim\n\n[![GitHub Release](https://img.shields.io/github/v/release/mishankov/yahttp?sort=semver\u0026display_name=tag\u0026logo=nim\u0026label=latest%20release\u0026color=%23FFE953)](https://github.com/mishankov/yahttp/releases/latest)\n[![CI](https://github.com/mishankov/yahttp/actions/workflows/ci.yml/badge.svg)](https://github.com/mishankov/yahttp/actions/workflows/ci.yml)\n\n\n- Based on Nim [std/httpclient](https://nim-lang.org/docs/httpclient.html)\n- No additional dependencies\n- API focused on DX\n\n# Installation\n\n```shell\nnimble install yahttp\n```\n\n# Examples\n\n\u003e more examples [here](examples/examples.nim)\n\n## Get HTTP status code\n\n```nim\nimport yahttp\n\necho get(\"https://www.google.com/\").status\n```\n## Send query params and parse response to JSON\n\n```nim\nimport json\nimport yahttp\n\nlet laptopsJson = get(\"https://dummyjson.com/products/search\", query = {\"q\": \"Laptop\"}).json()\necho laptopsJson[\"products\"][0][\"title\"].getStr()\n```\n# API\n\n## Method procedures\n\n```nim\nget(\"http://api\")\nput(\"http://api\")\npost(\"http://api\")\npatch(\"http://api\")\ndelete(\"http://api\")\nhead(\"http://api\")\noptions(\"http://api\")\n```\nArguments:\n- `url` - request URL. The only required argument\n- `headers` - request HTTP headers. Example: `{\"header1\": \"val\", \"header2\": \"val2\"}`\n- `query` - request query params. Example: `{\"param1\": \"val\", \"param2\": \"val2\"}`\n- `encodeQueryParams` - parameters for `encodeQuery` function that encodes query params. [More](https://nim-lang.org/docs/uri.html#encodeQuery%2CopenArray%5B%5D%2Cchar)\n- `body` - request body as a string. Example: `\"{\\\"key\\\": \\\"value\\\"}\"`. Is not available for `get`, `head` and `options` procedures\n- `files` - array of files to upload. Every file is a tuple of multipart name, file name, content type and content\n- `sreamingFiles` - array of files to stream from disc and upload. Every file is a tuple of multipart name and file path\n- `auth` - login and password for basic authorization. Example: `(\"login\", \"password\")`\n- `timeout` - stop waiting for a response after a given number of milliseconds. `-1` for no timeout, which is default value\n- `ignoreSsl` - no certificate verification if `true`\n- `sslContext` - SSL context for TLS/SSL connections. See [newContext](https://nim-lang.org/docs/net.html#newContext%2Cstring%2Cstring%2Cstring%2Cstring)\n\n## General procedure\n\n```nim\nrequest(\"http://api\")\n```\n\nHas the same arguments as method procedures and one additional:\n- `httpMethod` - HTTP method. `Method.GET` by default. Example: `Method.POST`\n\n## Response object\n\nAll procedures above return `Response` object with fields:\n- `status` - HTTP status code\n- `body` - response body as a string\n- `headers` - table, where keys are header keys and values are sequences of header values for a key\n- `request` - object with request data processed by `yahttp`\n  - `url` - stores full url with query params\n  - `headers` - stores HTTP headers with `Authorization` for basic authorization\n  - `httpMethod` - HTTP method\n  - `body` - request body as a string\n\n`Response` object has some helper procedures:\n- `Response.json()` - returns response body as JSON\n- `Response.html()` - returns response body as HTML\n- `Response.to(t)` - converts response body to JSON and unmarshals it to type `t`\n- `Response.ok()` - returns `true` if `status` is greater than 0 and less than 400\n- `Response.raiseForStatus()` - throws `HttpError` exceptions if status is 400 or above\n\n## Other helper functions\n\n`object.toJsonString()` - converts object of any type to json string. Helpful to use for `body` argument\n","funding_links":[],"categories":["Web"],"sub_categories":["Protocols"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmishankov%2Fyahttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmishankov%2Fyahttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmishankov%2Fyahttp/lists"}