You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+87Lines changed: 87 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,93 @@ Add this to your project's `pom.xml` file:
54
54
```
55
55
56
56
57
+
## Getting Started
58
+
59
+
### Init your SDK
60
+
61
+
Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key project API keys section.
62
+
63
+
```kotlin
64
+
importio.appwrite.Client
65
+
importio.appwrite.services.Account
66
+
67
+
suspendfunmain() {
68
+
val client =Client(context)
69
+
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
70
+
.setProject("5df5acd0d48c2") // Your project ID
71
+
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
72
+
.setSelfSigned(true) // Use only on dev mode with a self-signed SSL cert
73
+
}
74
+
```
75
+
76
+
### Make Your First Request
77
+
78
+
Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
79
+
80
+
```kotlin
81
+
val users =Users(client)
82
+
val response = users.create(
83
+
email ="email@example.com",
84
+
password ="password",
85
+
)
86
+
val json = response.body?.string()
87
+
```
88
+
89
+
### Full Example
90
+
91
+
```kotlin
92
+
importio.appwrite.Client
93
+
importio.appwrite.services.Users
94
+
95
+
suspendfunmain() {
96
+
val client =Client(context)
97
+
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
98
+
.setProject("5df5acd0d48c2") // Your project ID
99
+
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
100
+
.setSelfSigned(true) // Use only on dev mode with a self-signed SSL cert
101
+
102
+
val users =Users(client)
103
+
val response = users.create(
104
+
email ="email@example.com",
105
+
password ="password",
106
+
)
107
+
val json = response.body?.string()
108
+
}
109
+
```
110
+
111
+
### Error Handling
112
+
113
+
The Appwrite Kotlin SDK raises `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example.
114
+
115
+
```kotlin
116
+
importio.appwrite.Client
117
+
importio.appwrite.services.Users
118
+
119
+
suspendfunmain() {
120
+
val users =Users(client)
121
+
try {
122
+
val response = users.create(
123
+
email ="email@example.com",
124
+
password ="password",
125
+
)
126
+
var jsonString = response.body?.string() ?:""
127
+
128
+
} catch (e:AppwriteException) {
129
+
println(e)
130
+
}
131
+
}
132
+
```
133
+
134
+
### Learn more
135
+
136
+
You can use following resources to learn more and get help
137
+
138
+
- π [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
This library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request.
0 commit comments