Appearance
Quickstart Guide
This quickstart guide is designed to get you up and running with a d9 Project in a snap. Along the way, you will better understand what d9 is, get a hands-on introduction to the App and API, and find more resources to deep-dive into.
1. Install & Start d9
The fastest way to get started is with Docker:
bash
docker run -d \
-p 8055:8055 \
-e KEY=some-random-key \
-e SECRET=another-random-key \
-e ADMIN_EMAIL=admin@example.com \
-e ADMIN_PASSWORD=your-password \
-e DB_CLIENT=sqlite3 \
-e DB_FILENAME=/directus/database/data.db \
ghcr.io/lawebcapsule/directus9:latestOr with npm:
bash
npm init @wbce-d9/directus-project@latestOnce running, open http://localhost:8055 in your browser and log in with the admin credentials you set above.
Learn More About Self-Hosting
2. Create a Collection
Once logged in, you're greeted with the option to create your first Collection.
- Navigate into the Content Module.
- Click "Create Collection" and a side menu will appear.
- Fill in a Name.
For the sake of this demo, we'll call oursarticles, but feel free to make it your own! - Leave the other options at default. Click arrow_forward and the "Optional System Fields" menu will open.
Keep the values in this menu at the default, toggled off, for now. You can adjust them later. - Click check in the menu header.
Learn More About Collections
- The Content Module
- Create and Manage a Collection
- Build Relationships Between Collections
3. Create a Field
With your first Collection created, it's time to start adding some Fields.
- Navigate to Settings Module > Data Model >
Collection-Name. - Click the "Create Field" button and select the "Input" Field type.
- Fill in a Field name under Key. We'll be calling our Field
title.
d9 offers powerful Field customization options, but let's stick to the defaults for now. - Select "Save".
Learn More About Fields
4. Create an Item
Now that we have a Collection with a Field configured, it's time to add an Item.
- Navigate to the Content Module.
- Click add in the page header to open the Item Page.
- Fill in the Field Value(s) as desired.
- Click check in the top-right to save your Item.
Learn More About Items
5. Set Roles & Permissions
d9 comes with two built-in roles: Public and Admin. The Public Role determines what data is returned to non-authenticated users. Public comes with all permissions turned off and can be reconfigured with fully granular control to expose exactly what you want unauthenticated Users to see. The Admin role has full permissions and this cannot be changed. Aside from these built-in Roles, any number of new Roles can be created, all with fully customized, granular permissions.
By Default, content entered into d9 will be considered private. So permissions always start off set to the default of block No Access, with full ability to reconfigure as desired. So, in order to have the API return our Items, let's add some read permissions. For simplicity's sake, we'll do this on the Public Role, instead of creating a new Role.
- Navigate to Settings Module > Roles & Permissions > Public.
- Click block under the visibility icon on the desired Collection.
In our case, the Collection name isarticle. - Click "All Access" to give the Public Role full read permissions to the Items in this Collection.
Learn More About Roles & Permissions
6. Connect to the API
Now that your Project has some content in it which is exposed to the Public, it's time to start using this content externally! Data can be accessed in a number of ways, including the REST and GraphQL API endpoints. In this case, we'll use the /items/ REST API endpoint to retrieve the Item we just created.
- Open
http://localhost:8055/items/articles.
You can use the browser or an API tool like Postman or Paw
And there it is! The Article Item you just created is being served in beautiful JSON, ready to be used anywhere and everywhere!
json
{
"data": [
{
"id": 1,
"title": "Hello World!"
}
]
}In this example, we made a super-simple read request with the API, but there's more! The REST and GraphQL APIs provide exhaustive endpoints for the data model and every single action that you can do in the App can be done via the API. In fact, the App is just a GUI powered by the API.
Learn More About The API