Gathering detailed insights and metrics for @directus/sdk
Gathering detailed insights and metrics for @directus/sdk
Gathering detailed insights and metrics for @directus/sdk
Gathering detailed insights and metrics for @directus/sdk
@directus/extensions-sdk
A toolkit to develop extensions to extend Directus
@directus/sdk-js
Directus SDK for JavaScript (Node and Browser)
pc-directus-interface
Internal implementation of generic Directus methods to interact with Directus
directus-sdk-typegen
CLI and library to generate TypeScript types from Directus collections for use with Directus SDK.
The flexible backend for all your projects 🐰 Turn your DB into a headless CMS, admin panels, or apps with a custom UI, instant APIs, auth & more.
npm install @directus/sdk
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (71.84%)
Vue (26.21%)
SCSS (0.8%)
Liquid (0.38%)
JavaScript (0.36%)
CSS (0.36%)
Dockerfile (0.03%)
HTML (0.02%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
31,662 Stars
13,018 Commits
4,300 Forks
324 Watchers
213 Branches
463 Contributors
Updated on Jul 15, 2025
Latest Version
20.0.0
Package Id
@directus/sdk@20.0.0
Unpacked Size
538.02 kB
Size
94.17 kB
File Count
9
NPM Version
10.9.2
Node Version
22.16.0
Published on
Jun 25, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
The client is split up in separate features you can mix and match to compose a client with only the features you need or want.
1const client = createDirectus<Schema>('https://api.directus.io');
This client is currently an empty wrapper without any functionality. Before you can do anything with it you'll need to add some features. The following composables are available/in progress:
rest()
REST request functions
.request(...)
on the clientgraphql()
GraphQL request functions
.query(...)
on the clientstaticToken()
authentication functions
.getToken()
and .setToken()
on the clientauthenticate()
authentication functions
.login({ email, password })
, .logout()
, .refresh()
on the client.getToken()
and .setToken()
on the clientrealtime()
websocket connectivity
.subscribe(...)
, .sendMessage(...)
, .onWebsocket('message', (message) => {})
on the clientFor this example we'll build a client including rest
and graphql
:
1const client = createDirectus<Schema>('https://api.directus.io').with(rest()).with(graphql()); 2 3// do a REST request 4const restResult = await client.request(readItems('articles')); 5 6// do a GraphQL request 7const gqlResult = await client.query<OutputType>(` 8 query { 9 articles { 10 id 11 title 12 author { 13 first_name 14 } 15 } 16 } 17`);
1const client = createDirectus<Schema>('https://api.directus.io').with(rest()).with(authentication('json')); 2 3await client.login('admin@example.com', 'd1r3ctu5'); 4 5// do authenticated requests
1const client = createDirectus<Schema>('https://api.directus.io').with(rest()).with(staticToken('super-secure-token')); 2 3// do authenticated requests
The realtime()
extension allows you to work with a Directus REST WebSocket.
Subscribing to updates:
1const client = createDirectus<Schema>('https://api.directus.io').with( 2 realtime({ 3 authMode: 'public', 4 }), 5); 6 7const { subscription, unsubscribe } = await client.subscribe('test', { 8 query: { fields: ['*'] }, 9}); 10 11for await (const item of subscription) { 12 console.log('subscription', { item }); 13} 14 15// unsubscribe()
Receive/Send messages:
1const client = createDirectus<Schema>('https://api.directus.io').with( 2 realtime({ 3 authMode: 'public', 4 }), 5); 6 7const stop = client.onWebSocket('message', (message) => { 8 if ('type' in message && message['type'] === 'pong') { 9 console.log('PONG received'); 10 stop(); 11 } 12}); 13 14client.sendMessage({ type: 'ping' });
1// The main schema type containing all collections available 2interface MySchema { 3 collection_a: CollectionA[]; // regular collections are array types 4 collection_b: CollectionB[]; 5 collection_c: CollectionC; // this is a singleton 6 // junction collections are collections too 7 collection_a_b_m2m: CollectionAB_Many[]; 8 collection_a_b_m2a: CollectionAB_Any[]; 9} 10 11// collection A 12interface CollectionA { 13 id: number; 14 status: string; 15 // relations 16 m2o: number | CollectionB; 17 o2m: number[] | CollectionB[]; 18 m2m: number[] | CollectionAB_Many[]; 19 m2a: number[] | CollectionAB_Any[]; 20} 21 22// Many-to-Many junction table 23interface CollectionAB_Many { 24 id: number; 25 collection_a_id: CollectionA; 26 collection_b_id: CollectionB; 27} 28 29// Many-to-Any junction table 30interface CollectionAB_Any { 31 id: number; 32 collection_a_id: CollectionA; 33 collection: 'collection_b' | 'collection_c'; 34 item: string | CollectionB | CollectionC; 35} 36 37// collection B 38interface CollectionB { 39 id: number; 40 value: string; 41} 42 43// singleton collection 44interface CollectionC { 45 id: number; 46 app_settings: string; 47 something: string; 48}
No vulnerabilities found.
Reason
30 commit(s) and 6 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
packaging workflow detected
Details
Reason
Found 29/30 approved changesets -- score normalized to 9
Reason
license file detected
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
security policy file detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
13 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More