This video introduces Directus Connect — automatic REST and GraphQL APIs for your database and asset storage, highlighting key features such as resource-based URLs, query parameters, and the Directus JavaScript SDK.
Speaker 0: Part of the Directus data engine is Directus Connect. Automatic REST and GraphQL APIs for your database and asset storage. The REST API has predictable resource based URLs, relies on standard HTTP status codes, and uses JSON for input and output. To explain resource based URLs, let's use an example. Your project has a collection called posts.
The primary key is an auto incrementing number called id. Other fields include status, title, date published, and content. For this example, some of the available resource based endpoints include listing all posts, getting a single post by ID, creating a post while passing a payload, and so on. The URL path for working with items are dynamic based on the resources in your project, but they all follow a standard format. Most directives API endpoints can utilize a number of powerful query parameters to alter the data that is returned.
They include specifying which fields are returned, including relational fields. Filtering the returned items using the filter rules syntax, including logical operators and dynamic variables such as current user, sorting, paginating, and limiting the number of returned items, and applying aggregate functions either on the whole data set or on groups of data. Having a standard rest and graph ql API means that you can integrate a directus backend into any application in any language or framework by making an HTTP request. If you're building in a javascript the official directory's javascript sdk provides an improved developer experience. It's type safe, separated into several modules that provide granular control over which features include and then prune those that aren't at build time.
And does not require any external libraries. You can check out the directory's API reference. Every single operation that you can make is shown both with the rest example, the graphql example and the directivesdk example side by side. Using directives over API uses the same access control as the data studio. The permissions are the same, so you don't have to set anything up again or worry that your application will receive or be able to use data in ways it shouldn't be allowed to.
You can log in and use an access token which performs requests as your user or you can use a static token which is generated in your user profile and does not expire. If you make a request without an access token, it will use the configured public permissions, which are used when a user is unauthenticated. So this is a little bit about the APIs and the SDK. We have a load of tutorials inside of our documentation on Directus TV and on our YouTube channel in order to understand how to actually use the APIs and SDK to build real world projects. If you have any questions, feel free to reach out, and we'll see you in the next video.