{"id":29605501,"url":"https://github.com/bufbuild/knit-ts","last_synced_at":"2025-07-20T16:05:57.793Z","repository":{"id":161667499,"uuid":"636258356","full_name":"bufbuild/knit-ts","owner":"bufbuild","description":"TypeScript client for Knit","archived":false,"fork":false,"pushed_at":"2025-02-13T11:06:08.000Z","size":745,"stargazers_count":27,"open_issues_count":28,"forks_count":1,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-29T21:06:02.272Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bufbuild.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-05-04T12:58:13.000Z","updated_at":"2025-03-21T04:10:27.000Z","dependencies_parsed_at":"2023-06-09T11:15:11.403Z","dependency_job_id":"d7b94c92-6916-4658-84b6-2cf1c8c82f41","html_url":"https://github.com/bufbuild/knit-ts","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/bufbuild/knit-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufbuild%2Fknit-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufbuild%2Fknit-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufbuild%2Fknit-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufbuild%2Fknit-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bufbuild","download_url":"https://codeload.github.com/bufbuild/knit-ts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufbuild%2Fknit-ts/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264564867,"owners_count":23628848,"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":"2025-07-20T16:05:55.682Z","updated_at":"2025-07-20T16:05:57.786Z","avatar_url":"https://github.com/bufbuild.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🧶 Knit\n\n[![License](https://img.shields.io/github/license/bufbuild/knit-ts?color=blue)][badges_license]\n[![NPM Version](https://img.shields.io/npm/v/@bufbuild/knit/latest?color=green\u0026label=%40bufbuild%2Fknit)][npm_knit]\n[![NPM Version](https://img.shields.io/npm/v/@bufbuild/protoc-gen-knit-ts/latest?color=green\u0026label=%40bufbuild%2Fprotoc-gen-knit-ts)][npm_protoc-gen-knit-ts]\n[![Slack](https://img.shields.io/badge/slack-buf-%23e01563)][badges_slack]\n\n**Knit brings GraphQL-like capabilities to RPCs. Knit has type-safe and\ndeclarative queries that shape the response, batching support to eliminate\nthe N+1 problem, and first-class support for error handling with partial\nresponses. It is built on top of Protobuf and Connect.**\n\n**[Knit] is currently in alpha (α), and looking for feedback. Learn more\nabout it at the [Knit] repo, and learn how to use it with the [Tutorial].**\n\n---\n\nThis repo houses TypeScript packages for Knit:\n\n- [@bufbuild/knit](https://npmjs.com/@bufbuild/knit) - The TypeScript client package.\n- [@bufbuild/protoc-gen-knit-ts](https://npmjs.com/@bufbuild/protoc-gen-knit-ts) - The schema generator.\n\n## Quick example\n\nTo demonstrate the querying capabilities of Knit we've made a Protobuf equivalent of the star wars API at [swapi.dev](https://swapi.dev).\nThe definitions are available [here](https://buf.build/bufbuild/knit-demo).\n\nRun the following command to install the runtime package and schema for the star wars APIs:\n\n```sh\nnpm i @bufbuild/knit @buf/bufbuild_knit-demo.bufbuild_knit-es\n```\n\nIn a TypeScript file write the following query:\n\n```ts\nimport { createClient } from \"@bufbuild/knit\";\nimport type { FilmsService } from \"@buf/bufbuild_knit-demo.bufbuild_knit-es/buf/knit/demo/swapi/film/v1/film_knit\";\nimport type {} from \"@buf/bufbuild_knit-demo.bufbuild_knit-es/buf/knit/demo/swapi/relations/v1/relations_knit\";\n\nconst client = createClient\u003cFilmsService\u003e({\n  baseUrl: \"https://knit-demo.connect.build\", // The gateway-url\n});\n\n// Construct a query.\n//\n// The type system will ensure a query is valid.\nconst filmsResult = await client.fetch({\n  // The fully qualified service name of the RPC you want to invoke.\n  \"buf.knit.demo.swapi.film.v1.FilmService\": {\n    // The camelCase name of the RPC you want to invoke.\n    getFilms: {\n      // $ is the request message for the RPC.\n      $: { ids: [\"1\"] },\n      // The fields you want to select from the result.\n      films: {\n        id: {},\n        title: {},\n        director: {},\n        releaseDate: {},\n        // Include the relation you want to use.\n        // This field is not part of the original\n        // proto definition of a `Film`, it comes\n        // from `.../relations_knit`.\n        characters: {\n          // Relations can accept additional parameters.\n          // In this case it accepts a limit parameter\n          // to limit the number of characters returned.\n          $: { limit: 10 }\n          // The fields you want to select from the characters.\n          id: {},\n          name: {},\n        },\n      },\n    },\n  },\n});\n\n// The result is a strongly typed object that matches the query.\nconsole.log(JSON.strigify(filmsResult, null, 2));\n/**\n * This will print:\n * {\n *   \"buf.knit.demo.swapi.film.v1.FilmService\": {\n *     \"getFilms\": {\n *        \"films\": [\n *           {\n *             \"id\": \"1\",\n *             \"title\": \"A New Hope\",\n *             \"director\": \"George Lucas\",\n *             \"releaseDate\": \"1977-05-25\",\n *             \"characters\": [{\n *               { \"id\": \"1\", \"name\": \"Luke Skywalker\" },\n *               { \"id\": \"2\", \"name\": \"C-3PO\" },\n *               ...\n *             }]\n *           }\n *        ]\n *     }\n *   }\n * }\n */\n```\n\n## Status: Alpha\n\nKnit is undergoing initial development and is not yet stable.\n\n## Legal\n\nOffered under the [Apache 2 license][license].\n\n[badges_license]: https://github.com/bufbuild/knit-ts/blob/main/LICENSE\n[badges_slack]: https://buf.build/links/slack\n[license]: https://github.com/bufbuild/knit-ts/blob/main/LICENSE\n[npm_knit]: https://www.npmjs.com/package/@bufbuild/knit\n[npm_protoc-gen-knit-ts]: https://www.npmjs.com/package/@bufbuild/protoc-gen-knit-ts\n[knit]: https://github.com/bufbuild/knit\n[tutorial]: https://github.com/bufbuild/knit/tree/main/tutorial\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbufbuild%2Fknit-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbufbuild%2Fknit-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbufbuild%2Fknit-ts/lists"}