Directus Java SDK — Software Development Kit for Java and Android
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
gradle/wrapper
src
target
README.md
build.gradle
build.sbt
git_push.sh
gradle.properties
gradlew
gradlew.bat
pom.xml
settings.gradle

README.md

Directus Logo

Directus Java SDK

WebsiteDocsAPI ReferenceUser GuideDemoContribute

 

This codebase is a work-in-progress. The repo is here as a placeholder for anyone interested in contributing to the software development kit. Pull-requests and contributions are welcome!

 

Requirements

Building the API client library requires Maven to be installed.

Installation

To install the API client library to your local Maven repository, simply execute:

mvn install

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

mvn deploy

Refer to the official documentation for more information.

Maven users

Add this dependency to your project's POM:

<dependency>
    <groupId>io.directus</groupId>
    <artifactId>directus-sdk</artifactId>
    <version>1.1.1</version>
    <scope>compile</scope>
</dependency>

Gradle users

Add this dependency to your project's build file:

compile "io.directus:directus-sdk:1.1.1"

Others

At first generate the JAR by executing:

mvn package

Then manually install the following JARs:

  • target/directus-sdk-1.1.1.jar
  • target/lib/*.jar

Getting Started

Please follow the installation instruction and execute the following Java code:

import io.directus.client.*;
import io.directus.client.auth.*;
import io.directus.client.model.*;
import io.swagger.client.api.ActivityApi;

import java.io.File;
import java.util.*;

public class ActivityApiExample {

    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        
        // Configure API key authorization: api_key
        ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key");
        api_key.setApiKey("YOUR API KEY");
        // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
        //api_key.setApiKeyPrefix("Token");

        defaultClient.setBasePath("https://myinstance.directus.io/api/1.1");

        ActivityApi apiInstance = new ActivityApi();
        try {
            GetActivity result = apiInstance.getActivity();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling ActivityApi#getActivity");
            e.printStackTrace();
        }
    }
}

Documentation for API Endpoints

All URIs are relative to https://myinstance.directus.io/api/1.1

Class Method HTTP request Description
ActivityApi getActivity GET /activity Returns activity
BookmarksApi addBookmark POST /bookmarks Create a column in a given table
BookmarksApi deleteBookmark DELETE /bookmarks/{bookmarkId} Deletes specific bookmark
BookmarksApi getBookmark GET /bookmarks/{bookmarkId} Returns specific bookmark
BookmarksApi getBookmarks GET /bookmarks Returns bookmarks
BookmarksApi getBookmarksSelf GET /bookmarks/self Returns bookmarks of current user
FilesApi createFile POST /files Creates file
FilesApi getFile GET /files/{fileId} Returns specific file by id
FilesApi getFiles GET /files Returns files
FilesApi updateFile PUT /files/{fileId} Creates file
GroupsApi addGroup POST /groups Add a new group
GroupsApi addPrivilege POST /privileges/{groupId} Create new table privileges for the specified user group
GroupsApi getGroup GET /groups/{groupId} Returns specific group
GroupsApi getGroups GET /groups Returns groups
GroupsApi getPrivileges GET /privileges/{groupId} Returns group privileges
GroupsApi getPrivilegesForTable GET /privileges/{groupId}/{tableNameOrPrivilegeId} Returns group privileges by tableName
GroupsApi updatePrivileges PUT /privileges/{groupId}/{tableNameOrPrivilegeId} Update privileges by privilegeId
MessagesApi getMessage GET /messages/{messageId} Returns specific message
MessagesApi getMessages GET /messages/self Returns messages
PreferencesApi getPreferences GET /tables/{tableId}/preferences Returns table preferences
PreferencesApi updatePreferences PUT /tables/{tableId}/preferences Update table preferences
SettingsApi getSettings GET /settings Returns settings
SettingsApi getSettingsFor GET /settings/{collectionName} Returns settings for collection
SettingsApi updateSettings PUT /settings/{collectionName} Update settings
TablesApi addColumn POST /tables/{tableId}/columns Create a column in a given table
TablesApi addRow POST /tables/{tableId}/rows Add a new row
TablesApi addTable POST /tables Add a new table
TablesApi deleteColumn DELETE /tables/{tableId}/columns/{columnName} Delete row
TablesApi deleteRow DELETE /tables/{tableId}/rows/{rowId} Delete row
TablesApi deleteTable DELETE /tables/{tableId} Delete Table
TablesApi getTable GET /tables/{tableId} Returns specific table
TablesApi getTableColumn GET /tables/{tableId}/columns/{columnName} Returns specific table column
TablesApi getTableColumns GET /tables/{tableId}/columns Returns table columns
TablesApi getTableRow GET /tables/{tableId}/rows/{rowId} Returns specific table row
TablesApi getTableRows GET /tables/{tableId}/rows Returns table rows
TablesApi getTables GET /tables Returns tables
TablesApi updateColumn PUT /tables/{tableId}/columns/{columnName} Update column
TablesApi updateRow PUT /tables/{tableId}/rows/{rowId} Update row
UtilsApi getHash POST /hash Get a hashed value
UtilsApi getRandom POST /random Returns random alphanumeric string

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

api_key

  • Type: API key
  • API key parameter name: access_token
  • Location: URL query string

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

 


Directus is released under the GPLv3 license. RANGER Studio LLC owns all Directus trademarks and logos on behalf of our project's community. Copyright © 2006-2018, RANGER Studio LLC.