1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <!DOCTYPE topic SYSTEM "https://resources.jetbrains.com/writerside/1.0/xhtml-entities.dtd">
3
+ <topic xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : noNamespaceSchemaLocation =" https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd"
5
+ id =" Dungeon-Hub-API" title =" Dungeon Hub API" >
6
+ <chapter title =" What is the Dungeon Hub API" id =" what-is-the-dungeon-hub-api" >
7
+ <p >The Dungeon Hub API hosts all data that is used in the <a href =" Dungeon-Hub-Bot.md" />. <br />The <a
8
+ href =" Dungeon-Hub-Bot.md" /> itself only serves as a client to interact with the API - it does not have
9
+ any database access and only persists data through the API. A documentation with all endpoints and their
10
+ usage can be found at <a href =" https://api.dungeon-hub.net/" />.</p >
11
+ </chapter >
12
+ <chapter title =" Authentication" id =" authentication" >
13
+ <p >Most endpoints of the Dungeon Hub API require authentication. <br />The API uses bearer tokens for
14
+ authentication, meaning an Authorization header containing the JWT token must be attached
15
+ to the request. <br />The header should look like: <code >Authorization: Bearer < token> </code >. <br />A
16
+ token can be obtained from the authentication server, which is hosted separately to the API
17
+ at <a href =" https://auth.dungeon-hub.net/" />.</p >
18
+ <chapter title =" Logging in as a user" id =" logging-in-as-a-user" >
19
+ <p ><code >Coming soon</code ></p >
20
+ </chapter >
21
+ <chapter title =" Logging in as a client" id =" logging-in-as-a-client" >
22
+ <warning >
23
+ <p >This requires a client to be registered manually. If you're interested in this, please contact <a
24
+ href =
" mailto:[email protected] " >the administration</
a >.
25
+ </p >
26
+ </warning >
27
+ <p >To log in as a client, you need to send a <code >POST</code > request to
28
+ <code >https://auth.dungeon-hub.net/realms/dungeon-hub/protocol/openid-connect/token</code >. <br />The
29
+ request body should be a multipart form containing the following fields:</p >
30
+ <list >
31
+ <li ><code >client_id</code >: <code >dh-server</code ></li >
32
+ <li ><code >grant_type</code >: <code >client_credentials</code ></li >
33
+ </list >
34
+ <p >As the Authorization header, you should use basic authentication with the client's credentials (client id
35
+ as username,
36
+ client secret as password).</p >
37
+ </chapter >
38
+ </chapter >
39
+ <chapter title =" Connecting to the API" id =" connecting-to-the-api" >
40
+ <p >All API endpoints are reachable under <a href =" https://api.dungeon-hub.net/" />. A simple documentation of
41
+ all endpoints is available there. <br />To ease the connection to the API, a Kotlin/JVM library containing
42
+ all models that the API uses in requests and responses, as well as a library to send requests to all
43
+ possible endpoints is available at <a href =" https://github.com/dungeon-hub/dungeon-hub-api" />.</p >
44
+ <chapter title =" Importing the client library" id =" importing-client" >
45
+ <tabs >
46
+ <tab id =" gradle-kotlin-import" title =" Gradle (Kotlin)" >
47
+ <p >First of all, add a dependency to your <code >gradle/libs.versions.toml</code > file.</p >
48
+ <p >This file is used to declare the versions of libraries you use in one central place.</p >
49
+
50
+ <!-- suppress WrsCodeBlockWidthInspection -->
51
+ <code-block lang =" toml" >
52
+ [versions]
53
+ dungeon-hub-api-client = "%client-version%"
54
+
55
+ [libraries]
56
+ dungeon-hub-api-client = {module = "net.dungeon-hub.api:client", version.ref = "dungeon-hub-api-client" }
57
+ </code-block >
58
+
59
+ <p >Then, you can simply add the dependency to your <code >build.gradle.kts</code > file.</p >
60
+
61
+ <code-block lang =" kotlin" >
62
+ repositories {
63
+ // other repositories
64
+
65
+ mavenCentral()
66
+ }
67
+
68
+ dependencies {
69
+ // other dependencies
70
+
71
+ implementation(libs.dungeon.hub.api.client)
72
+ }
73
+ </code-block >
74
+ </tab >
75
+
76
+ <tab id =" gradle-groovy-import" title =" Gradle (Groovy)" >
77
+ <p >First of all, add a dependency to your <code >gradle/libs.versions.toml</code > file.</p >
78
+ <p >This file is used to declare the versions of libraries you use in one central place.</p >
79
+
80
+ <!-- suppress WrsCodeBlockWidthInspection -->
81
+ <code-block lang =" toml" >
82
+ [versions]
83
+ dungeon-hub-api-client = "%client-version%"
84
+
85
+ [libraries]
86
+ dungeon-hub-api-client = {module = "net.dungeon-hub.api:client", version.ref = "dungeon-hub-api-client" }
87
+ </code-block >
88
+
89
+ <p >Then, you can simply add the dependency to your <code >build.gradle</code > file.</p >
90
+
91
+ <code-block lang =" groovy" >
92
+ repositories {
93
+ // other repositories
94
+
95
+ mavenCentral()
96
+ }
97
+
98
+ dependencies {
99
+ // other dependencies
100
+
101
+ implementation(libs.dungeon.hub.api.client)
102
+ }
103
+ </code-block >
104
+ </tab >
105
+
106
+ <tab id =" maven-import" title =" Maven" >
107
+ Please add the following to your `pom.xml`:
108
+ <code-block lang =" xml" >
109
+ < dependencies>
110
+ < dependency>
111
+ < groupId> net.dungeon-hub.api< /groupId>
112
+ < artifactId> client< /artifactId>
113
+ < version> %client-version%< /version>
114
+ < /dependency>
115
+ < /dependencies>
116
+ </code-block >
117
+ </tab >
118
+ </tabs >
119
+ </chapter >
120
+ </chapter >
121
+ </topic >
0 commit comments