{"id":13649972,"url":"https://github.com/jacoborus/directus-lite-sdk","last_synced_at":"2025-07-05T02:03:51.170Z","repository":{"id":41192997,"uuid":"484906831","full_name":"jacoborus/directus-lite-sdk","owner":"jacoborus","description":"The unofficial Directus Lite SDK in less than 1Kb","archived":false,"fork":false,"pushed_at":"2022-05-01T01:09:52.000Z","size":22,"stargazers_count":20,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-02T11:19:39.893Z","etag":null,"topics":["client","directus","javascript","rest","rest-api","sdk","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/jacoborus.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}},"created_at":"2022-04-24T02:40:30.000Z","updated_at":"2024-12-30T00:13:42.000Z","dependencies_parsed_at":"2022-09-11T20:51:28.308Z","dependency_job_id":null,"html_url":"https://github.com/jacoborus/directus-lite-sdk","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jacoborus/directus-lite-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacoborus%2Fdirectus-lite-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacoborus%2Fdirectus-lite-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacoborus%2Fdirectus-lite-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacoborus%2Fdirectus-lite-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacoborus","download_url":"https://codeload.github.com/jacoborus/directus-lite-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacoborus%2Fdirectus-lite-sdk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263645557,"owners_count":23494005,"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":["client","directus","javascript","rest","rest-api","sdk","typescript"],"created_at":"2024-08-02T02:00:31.885Z","updated_at":"2025-07-05T02:03:51.153Z","avatar_url":"https://github.com/jacoborus.png","language":"TypeScript","funding_links":[],"categories":["Integration"],"sub_categories":["Community"],"readme":"# directus-lite-sdk\n\nThe unofficial [Directus](https://directus.io/) Lite SDK in less than 1Kb\n\n- ~750 bytes\n- It works on the browser, Deno and Node.js\n- Bring your own fetch\n\n## Install\n\nNode.js: `npm i directus-lite-sdk`\n\nDeno: -- just import it on your file\n\n## Usage\n\nCreate a new instance of the SDK passing the URL of your Directus API:\n\n```js\n// Deno\nimport DirectusLiteSdk from \"https://deno.land/x/directus_lite_sdk/lite-sdk.ts\";\n// Node\nimport DirectusLiteSdk from \"directus-lite-sdk\";\n\nconst sdk = new DirectusLiteSdk(\"your-api-url.com\");\n```\n\nThis instance exposes 2 methods: `query` and `fileUrl`.\n\n### `query`\n\nAccepts 2 arguments: the path of your request, and an optional object containing\nthe global params, and the `access_token`:\n\n```js\nfetch(\n  sdk.query(\"items/articles\", {\n    fields: [\n      \"id\",\n      \"title\",\n      \"author.name\",\n    ],\n    search: \"text\",\n    limit: 30,\n    page: 4,\n    filter: {\n      project: {\n        _eq: \"lite-sdk\",\n      },\n      \"year(pubdate)\": 2022,\n    },\n  }),\n);\n```\n\nQuery options:\n\n```typescript\ninterface QueryOptions {\n  access_token?: string;\n  filter?: DeepParam;\n  fields?: string | string[];\n  sort?: string | string[];\n  search?: string;\n  limit?: number;\n  offset?: number;\n  page?: number;\n  aggregate?: Record\u003cstring, string\u003e;\n  deep?: DeepParam;\n  alias?: Record\u003cstring, string\u003e;\n  export?: \"json\" | \"csv\" | \"xml\";\n  meta?: \"total_count\" | \"filter_count\" | \"*\";\n}\n\ninterface DeepParam {\n  [key: string]: string | number | DeepParam;\n}\n```\n\nCheck [Global Query Parameters](https://docs.directus.io/reference/query/) on\nDirectus docs for more info\n\n### `fileUrl`\n\nGet the full path of a file. Receives the id of the file, and optionally 2 more\narguments, the first one is an object containing the `access_token` and custom\ntransformations; the second is an array containing the advanced transformations.\n\n```js\nconst imageUrl = sdk.fileUrl(\n  \"1234-abcd\",\n  {\n    fit: \"cover\",\n    width: 100,\n    format: \"jpg\",\n  },\n  [\n    [\"blur\", 45],\n    [\"tint\", \"rgba(255, 0, 0)\"],\n    [\"expand\", { \"right\": 200, \"bottom\": 150 }],\n  ],\n);\n```\n\nFileUrl options:\n\n```typescript\n{\n  access_token?: string;\n  key?: string;\n  fit?: \"cover\" | \"contain\" | \"inside\" | \"outside\";\n  width?: number;\n  height?: number;\n  quality?: number;\n  withoutEnlargement?: boolean;\n  format?: \"jpg\" | \"png\" | \"webp\" | \"tiff\";\n}\n```\n\nCheck\n[Requesting a Thumbnail](https://docs.directus.io/reference/files/#requesting-a-thumbnail)\non the Directus docs for more info about custom and advanced transformations\n\n## Test\n\nUse Deno\n\n```sh\ndeno test\n```\n\n© 2022 [Jacobo Tabernero Rey](https://github.com/jacoborus) - Released under\n[MIT License](https://raw.github.com/jacoborus/hexterm/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacoborus%2Fdirectus-lite-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacoborus%2Fdirectus-lite-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacoborus%2Fdirectus-lite-sdk/lists"}