Skip to content

Commit 93a17fc

Browse files
Merge pull request #6 from appwrite/dev
feat: update readme
2 parents 1d4bda5 + 1ed54ee commit 93a17fc

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,93 @@ Add this to your project's `pom.xml` file:
5454
```
5555

5656

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+
import io.appwrite.Client
65+
import io.appwrite.services.Account
66+
67+
suspend fun main() {
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+
import io.appwrite.Client
93+
import io.appwrite.services.Users
94+
95+
suspend fun main() {
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+
import io.appwrite.Client
117+
import io.appwrite.services.Users
118+
119+
suspend fun main() {
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)
139+
- πŸ“œ [Appwrite Docs](https://appwrite.io/docs)
140+
- πŸ’¬ [Discord Community](https://appwrite.io/discord)
141+
- πŸš‚ [Appwrite Kotlin Playground](https://github.com/appwrite/playground-for-kotlin)
142+
143+
57144
## Contribution
58145

59146
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

Comments
Β (0)