{"id":22075659,"url":"https://github.com/olaven/kall","last_synced_at":"2025-07-24T12:32:09.670Z","repository":{"id":40705956,"uuid":"277908143","full_name":"olaven/kall","owner":"olaven","description":"A lightweight fetch-wrapper for calling REST+JSON-APIs","archived":false,"fork":false,"pushed_at":"2024-04-07T09:31:51.000Z","size":149,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-18T15:15:32.233Z","etag":null,"topics":["deno","fetch","http","http-client","json","nodejs","typescript-library"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/olaven.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":"2020-07-07T19:47:18.000Z","updated_at":"2024-04-06T09:06:56.000Z","dependencies_parsed_at":"2024-04-07T10:29:00.955Z","dependency_job_id":"154478f3-045a-4a9a-90d0-ed7ec0654a97","html_url":"https://github.com/olaven/kall","commit_stats":{"total_commits":69,"total_committers":1,"mean_commits":69.0,"dds":0.0,"last_synced_commit":"7117f02496a5f315fa8b4f51e9fa3bb8bf28a1c0"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaven%2Fkall","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaven%2Fkall/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaven%2Fkall/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaven%2Fkall/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olaven","download_url":"https://codeload.github.com/olaven/kall/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227440822,"owners_count":17776660,"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":["deno","fetch","http","http-client","json","nodejs","typescript-library"],"created_at":"2024-11-30T22:10:29.474Z","updated_at":"2024-11-30T22:10:30.273Z","avatar_url":"https://github.com/olaven.png","language":"TypeScript","funding_links":["https://github.com/sponsors/olaven/"],"categories":[],"sub_categories":[],"readme":"[![Latest version](https://deno.land/badge/kall/version)](https://deno.land/x/kall)\n![Test](https://github.com/olaven/kall/workflows/Test/badge.svg)\n\n# Kall 🦜\n\nA small and intuitive wrapper around `fetch` for consuming REST+JSON-APIs.\n`kall` is compatible with [Deno](https://deno.land) and [Node](nodejs.org).\n\nIt provides functions for each HTTP Method and an easy API to read their response,\nas well as handy constants for different status codes.\n\n## Support/sponsor\n\nIf you or your company is benefitting from `kall`, consider becoming a [sponsor](https://github.com/sponsors/olaven/).\nThis way I can work on new features and continue to maintain it worry-free.\n\n## Getting started\n\n- Deno: just use URL's like in examples\n- Node: `yarn add node-kall`\n\n### Basic usage\n\n```ts\n//\"node-kall\" if using Node\nimport {\n  get,\n  STATUS_CODE,\n} from \"https://denopkg.com/olaven/kall@v1.0.8/mod.ts\";\n\n// Basic GET\nconst { status, todo } = await get(\n  \"https://jsonplaceholder.typicode.com/todos/1\",\n);\n\nconsole.log(\n  status === STATUS_CODE.OK\n    ? `Fetched Todo: ${todo}`\n    : `${status} when fetching todo..`,\n);\n```\n\n```ts\n//\"node-kall\" if using Node\nimport {\n  get,\n  STATUS_CODE,\n} from \"https://denopkg.com/olaven/kall@v1.0.8/mod.ts\";\n\n// Same as previous example, but with types\ntype Todo = { userId: number; id: number; title: string; completed: boolean }; //define the type the server is expected to return\nconst { status, todo } = await get\u003cTodo\u003e(\n  \"https://jsonplaceholder.typicode.com/todos/1\",\n); // pass as generic\n\nconsole.log(\n  status === STATUS_CODE.OK\n    ? `Fetched Todo: ${todo}`\n    : `${status} when fetching todo..`,\n);\n```\n\nEvery function (`get`, `put`, `patch`, `del`, `post`) returns the same format: `{ status, body, response }`.\n\n- `status`: is the status code.\n- `body`: is the JSON-object the API returns (if any)\n- `response`: is the response `fetch` would have returned, for when you need it\n\nSimilarly, the last argument of any function (2nd for `get` and `del`, and 3rd for `put`, `patch` and `post`) takes a `RequestInit`-object, for when you\nneed to pass custom headers etc.\n\n## Motivation\n\nThe `fetch`-API is quite straight forward. However, its semantics are confusing.\n\n\u003e \"fetch\"\n\u003e\n\u003e 1. to go and bring back; return with; get:\n\u003e    _to go up a hill to fetch a pail of water._\n\u003e 2. to cause to come; bring:\n\u003e    _to fetch a doctor._ \u003e [source](https://www.dictionary.com/browse/fetch)\n\nIn a [REST](https://en.wikipedia.org/wiki/Representational_state_transfer)-context, this makes sense for `GET`-methods, but\nit breaks down once you use methods like `POST` and `PATCH`. This causes friction that should usually be avoided.\nFurthermore, `fetch` exposes a lot of data that is not needed. **Most of the time**, the status code and JSON-body of the response\nis what's relevant. `kall` makes the most relevant data available quicky through a very simple API, at the expense of being highly coupled with REST.\nThis makes code easier to read and reason through.\n\nHowever, \"most of the time\" is not always. `kall` makes it possible to get the same information as `fetch` would in these situations.\nThe difference is that \"most of the time\" is prioritized.\n\nMake what you want of this :-) It's just a personal experiment that I want to use and share.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folaven%2Fkall","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folaven%2Fkall","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folaven%2Fkall/lists"}