### Full Example: Initialize SDK and Register User Source: https://github.com/appwrite/sdk-for-react-native/blob/main/README.md A complete example demonstrating SDK initialization and user registration. ```javascript import { Client, Account } from 'react-native-appwrite'; // Init your React Native SDK const client = new Client(); client .setEndpoint('http://localhost/v1') // Your Appwrite Endpoint .setProject('455x34dfkj') .setPlatform('com.example.myappwriteapp') // YOUR application ID ; const account = new Account(client); // Register User account.create(ID.unique(), 'me@example.com', 'password', 'Jane Doe') .then(function (response) { console.log(response); }, function (error) { console.log(error); }); ``` -------------------------------- ### Install Appwrite React Native SDK Source: https://github.com/appwrite/sdk-for-react-native/blob/main/README.md Install the Appwrite React Native SDK and the URL polyfill package using Expo's package manager. ```bash npx expo install react-native-appwrite react-native-url-polyfill ``` -------------------------------- ### Register User Source: https://github.com/appwrite/sdk-for-react-native/blob/main/README.md Example of registering a new user with the Appwrite SDK. Requires a pre-initialized client. ```javascript const account = new Account(client); // Register User account.create(ID.unique(), 'me@example.com', 'password', 'Jane Doe') .then(function (response) { console.log(response); }, function (error) { console.log(error); }); ``` -------------------------------- ### List Files in a Bucket Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/storage/list-files.md This example demonstrates how to list all files within a specified bucket. You can optionally filter results using search terms or specify if you need the total count. ```APIDOC ## listFiles ### Description Retrieves a list of files stored in a specific bucket. This method allows for optional search and pagination parameters. ### Method Signature ```javascript storage.listFiles({ bucketId: string, queries?: string[], search?: string, total?: boolean }): Promise ``` ### Parameters #### Path Parameters - **bucketId** (string) - Required - The ID of the bucket to list files from. #### Query Parameters - **queries** (string[]) - Optional - An array of Appwrite query strings to filter or sort the results. - **search** (string) - Optional - A string to search for within file names or metadata. - **total** (boolean) - Optional - If set to `true`, the response will include the total number of files matching the query. Defaults to `false`. ### Request Example ```javascript import { Client, Storage } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const storage = new Storage(client); const result = await storage.listFiles({ bucketId: '', queries: [], // optional search: '', // optional total: false // optional }); console.log(result); ``` ### Response #### Success Response (200) - **files** (array) - An array of file objects, each containing file metadata. - **total** (integer) - The total number of files found (only included if `total` is true in the request). #### Response Example ```json { "files": [ { "$id": "file1_id", "bucketId": "", "name": "example.jpg", "size": 1024, "mimeType": "image/jpeg", "createdAt": "2023-01-01T12:00:00.000+00:00", "updatedAt": "2023-01-01T12:00:00.000+00:00" } ], "total": 1 } ``` ``` -------------------------------- ### Upsert Row Example Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/tablesdb/upsert-row.md This example demonstrates how to use the `upsertRow` method to add or update a row in a specific table within a database. It includes parameters for database ID, table ID, row ID, data, permissions, and transaction ID. ```APIDOC ## Upsert Row ### Description Upserts a row in a specified table within a database. If the row ID exists, it updates the row; otherwise, it creates a new row. ### Method `tablesDB.upsertRow(params)` ### Parameters #### Path Parameters - **databaseId** (string) - Required - The ID of the database. - **tableId** (string) - Required - The ID of the table. - **rowId** (string) - Required - The ID of the row to upsert. #### Request Body - **data** (object) - Optional - The data to be inserted or updated in the row. Keys are attribute names and values are attribute values. - **permissions** (array) - Optional - An array of permission strings to apply to the row. - **transactionId** (string) - Optional - The ID of the transaction to associate with this operation. ### Request Example ```javascript const result = await tablesDB.upsertRow({ databaseId: '', tableId: '', rowId: '', data: { "username": "walter.obrien", "email": "walter.obrien@example.com", "fullName": "Walter O'Brien", "age": 33, "isAdmin": false }, // optional permissions: ["read(\"any\")"], // optional transactionId: '' // optional }); console.log(result); ``` ### Response #### Success Response (200) Returns the updated or created row object. ``` -------------------------------- ### Get a File from Storage Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/storage/get-file.md Use this snippet to retrieve a file from your Appwrite storage. Ensure you have initialized the Appwrite client and storage services with your project details. ```javascript import { Client, Storage } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const storage = new Storage(client); const result = await storage.getFile({ bucketId: '', fileId: '' }); console.log(result); ``` -------------------------------- ### Get Team Preferences using JavaScript Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/teams/get-prefs.md Use the `getPrefs` method from the Teams service to fetch preferences for a given team. Ensure your client is initialized with your project details. ```javascript import { Client, Teams } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); const result = await teams.getPrefs({ teamId: '' }); console.log(result); ``` -------------------------------- ### Get Team Details Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/teams/get.md Use the `get` method from the `Teams` class to retrieve a team's information. Replace placeholders with your actual API endpoint, project ID, and the team ID you wish to fetch. ```javascript import { Client, Teams } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); const result = await teams.get({ teamId: '' }); console.log(result); ``` -------------------------------- ### Disable MFA for User Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/account/update-mfa.md This example demonstrates how to disable MFA for the current user account. ```APIDOC ## Disable MFA ### Description Disables Multi-Factor Authentication for the current user. ### Method `account.updateMFA({ mfa: false })` ### Parameters #### Request Body - **mfa** (boolean) - Required - Set to `false` to disable MFA. ### Request Example ```json { "mfa": false } ``` ### Response #### Success Response (200) Returns the updated user object. #### Response Example ```json { "$id": "60a7b0b0b0b0b0b0b0b0b0b0", "name": "John Doe", "email": "john.doe@example.com", "registration": "2023-01-01T10:00:00.000+00:00", "level": "", "emailVerification": true, "mfa": false, "prefs": {}, "sessions": [] } ``` ``` -------------------------------- ### Get File Download Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/storage/get-file-download.md Use this method to get a download URL for a file stored in Appwrite. Ensure you have initialized the Appwrite client and storage instance. ```javascript import { Client, Storage } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const storage = new Storage(client); const result = storage.getFileDownload({ bucketId: '', fileId: '', token: '' // optional }); console.log(result); ``` -------------------------------- ### Get File Preview with Optional Parameters Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/storage/get-file-preview.md Use this method to generate a preview of a file. You can customize the preview by specifying width, height, gravity, quality, border, opacity, rotation, background color, and output format. Ensure you have the correct bucket ID, file ID, and project credentials. ```javascript import { Client, Storage, ImageGravity, ImageFormat } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const storage = new Storage(client); const result = storage.getFilePreview({ bucketId: '', fileId: '', width: 0, // optional height: 0, // optional gravity: ImageGravity.Center, // optional quality: -1, // optional borderWidth: 0, // optional borderColor: '', // optional borderRadius: 0, // optional opacity: 0, // optional rotation: -360, // optional background: '', // optional output: ImageFormat.Jpg, // optional token: '' // optional }); console.log(result); ``` -------------------------------- ### Get File Preview Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/storage/get-file-preview.md Retrieves a preview of a file from storage. You can specify various parameters to customize the preview, such as dimensions, quality, and output format. ```APIDOC ## Get File Preview ### Description Retrieves a preview of a file from storage. This method allows for customization of the preview through various optional parameters. ### Method `getFilePreview` ### Parameters #### Path Parameters - **bucketId** (string) - Required - The ID of the bucket the file belongs to. - **fileId** (string) - Required - The ID of the file to get the preview for. #### Query Parameters - **width** (integer) - Optional - The desired width of the preview in pixels. Defaults to 0 (original width). - **height** (integer) - Optional - The desired height of the preview in pixels. Defaults to 0 (original height). - **gravity** (string) - Optional - The image gravity to use for cropping or resizing. Possible values are constants from `ImageGravity` (e.g., `ImageGravity.Center`). - **quality** (integer) - Optional - The quality of the preview image (0-100). Defaults to -1 (original quality). - **borderWidth** (integer) - Optional - The width of the border to add around the preview in pixels. Defaults to 0. - **borderColor** (string) - Optional - The color of the border in hexadecimal format (e.g., '#FFFFFF'). Defaults to an empty string. - **borderRadius** (integer) - Optional - The radius of the border corners in pixels. Defaults to 0. - **opacity** (float) - Optional - The opacity of the preview image (0.0-1.0). Defaults to 0. - **rotation** (integer) - Optional - The rotation angle in degrees. Defaults to -360. - **background** (string) - Optional - The background color of the preview in hexadecimal format (e.g., '#000000'). Defaults to an empty string. - **output** (string) - Optional - The desired output format for the preview. Possible values are constants from `ImageFormat` (e.g., `ImageFormat.Jpg`). - **token** (string) - Optional - A security token for accessing the file preview. ### Request Example ```javascript const result = await storage.getFilePreview({ bucketId: '', fileId: '', width: 500, height: 300, gravity: ImageGravity.Center, quality: 80, output: ImageFormat.Png }); ``` ### Response #### Success Response (200) Returns the file preview as a binary stream or a URL depending on the SDK implementation and context. ``` -------------------------------- ### Update Presence Example Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/presences/update.md Updates an existing presence. You can optionally modify its status, expiration time, metadata, and permissions. Ensure the client and presences service are initialized before use. ```javascript import { Client, Presences, Permission, Role } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const presences = new Presences(client); const result = await presences.update({ presenceId: '', status: '', // optional expiresAt: '2020-10-15T06:38:00.000+00:00', // optional metadata: {}, // optional permissions: ["read(\"any\")"], // optional purge: false // optional }); console.log(result); ``` -------------------------------- ### Get a Function Execution Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/functions/get-execution.md Use this method to retrieve the details of a specific function execution. Ensure you have initialized the Appwrite client and functions service with your project details. ```javascript import { Client, Functions } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const functions = new Functions(client); const result = await functions.getExecution({ functionId: '', executionId: '' }); console.log(result); ``` -------------------------------- ### Performing Multiple Create Operations Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/databases/create-operations.md This example demonstrates how to use the `createOperations` method to perform multiple create actions within a single transaction. It includes creating a document with specific data in a given collection and database. ```APIDOC ## createOperations ### Description Performs a list of operations within a single transaction. This allows for atomic operations, ensuring that either all operations succeed or none of them do. ### Method `databases.createOperations(params: { transactionId: string, operations: Array<{ action: 'create', databaseId: string, collectionId: string, documentId?: string, data: object }> })` ### Parameters #### Body Parameters - **transactionId** (string) - Required - The ID of the transaction to associate these operations with. - **operations** (Array) - Required - An array of operations to perform. Each operation object must have: - **action** (string) - Required - The type of action to perform. Must be 'create'. - **databaseId** (string) - Required - The ID of the database where the collection is located. - **collectionId** (string) - Required - The ID of the collection where the document will be created. - **documentId** (string) - Optional - The ID to assign to the newly created document. If not provided, Appwrite will generate one. - **data** (object) - Required - The data to be stored in the document. ### Request Example ```javascript const result = await databases.createOperations({ transactionId: '', operations: [ { "action": "create", "databaseId": "", "collectionId": "", "documentId": "", // Optional "data": { "name": "Walter O'Brien" } } ] }); ``` ### Response #### Success Response (200) Returns the result of the operations performed within the transaction. ``` -------------------------------- ### Get Favicon using Appwrite SDK for React Native Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/avatars/get-favicon.md Initialize the Appwrite client and use the Avatars service to get a favicon for a specified URL. Ensure you replace placeholders with your actual API endpoint and project ID. ```javascript import { Client, Avatars } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const avatars = new Avatars(client); const result = avatars.getFavicon({ url: 'https://example.com' }); console.log(result); ``` -------------------------------- ### Get File View using Storage SDK Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/storage/get-file-view.md Use the `getFileView` method from the Storage class to retrieve a file. Ensure you have initialized the Appwrite client with your endpoint and project ID. The `token` parameter is optional. ```javascript import { Client, Storage } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const storage = new Storage(client); const result = storage.getFileView({ bucketId: '', fileId: '', token: '' // optional }); console.log(result); ``` -------------------------------- ### Get Document by ID Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/databases/get-document.md Use this snippet to fetch a document using its unique ID. Ensure your client is initialized with your project's endpoint and ID. The `databaseId`, `collectionId`, and `documentId` are required parameters. ```javascript import { Client, Databases } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const databases = new Databases(client); const result = await databases.getDocument({ databaseId: '', collectionId: '', documentId: '', queries: [], // optional transactionId: '' // optional }); console.log(result); ``` -------------------------------- ### Get Presence Information Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/presences/get.md Use this snippet to retrieve a specific presence record by its ID. Ensure you have initialized the Appwrite client and Presences service with your project details. ```javascript import { Client, Presences } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const presences = new Presences(client); const result = await presences.get({ presenceId: '' }); console.log(result); ``` -------------------------------- ### Get Team Membership Details Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/teams/get-membership.md Use the `getMembership` method to retrieve details of a specific team member. Ensure you have initialized the Appwrite client with your endpoint and project ID. ```javascript import { Client, Teams } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); const result = await teams.getMembership({ teamId: '', membershipId: '' }); console.log(result); ``` -------------------------------- ### Update Membership Status Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/teams/update-membership-status.md This example demonstrates how to update the status of a team membership. You need to provide the team ID, membership ID, user ID, and a secret to authenticate the request. ```APIDOC ## Update Membership Status ### Description Updates the status of a team membership. This is typically used to accept or decline an invitation. ### Method `teams.updateMembershipStatus` ### Parameters #### Request Body - **teamId** (string) - Required - The ID of the team. - **membershipId** (string) - Required - The ID of the membership to update. - **userId** (string) - Required - The ID of the user associated with the membership. - **secret** (string) - Required - The secret associated with the membership invitation or action. ### Request Example ```json { "teamId": "", "membershipId": "", "userId": "", "secret": "" } ``` ### Response #### Success Response (200) Returns the updated membership object. - **$id** (string) - Membership unique ID. - **teamId** (string) - Team unique ID. - **userId** (string) - User unique ID. - **invited** (integer) - Timestamp of the invitation. - **joined** (integer) - Timestamp of when the user joined the team. - **status** (string) - Membership status ('pending', 'accepted', 'declined', 'blocked'). - **role** (string) - Membership role within the team. #### Response Example ```json { "$id": "60a5c1f1b3f1f1f1f1f1f1f1", "teamId": "60a5c1f1b3f1f1f1f1f1f1f2", "userId": "60a5c1f1b3f1f1f1f1f1f1f3", "invited": 1621570001, "joined": 1621570001, "status": "accepted", "role": "member" } ``` ``` -------------------------------- ### List All Countries - React Native Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/locale/list-countries.md Use the `listCountries` method from the `Locale` service to get a list of all supported countries. Ensure your Appwrite client is initialized with your project's endpoint and ID. ```javascript import { Client, Locale } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const locale = new Locale(client); const result = await locale.listCountries(); console.log(result); ``` -------------------------------- ### Get Current Locale Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/locale/get.md Retrieve the current locale settings for your project. This includes the default locale, currency, and other localization-related information. Ensure your Appwrite client is initialized with your project's endpoint and ID. ```javascript import { Client, Locale } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const locale = new Locale(client); const result = await locale.get(); console.log(result); ``` -------------------------------- ### Get Transaction by ID Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/databases/get-transaction.md Use this snippet to fetch a specific transaction by its unique ID. Make sure to initialize the Appwrite client with your endpoint and project ID, and then create a Databases instance. ```javascript import { Client, Databases } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const databases = new Databases(client); const result = await databases.getTransaction({ transactionId: '' }); console.log(result); ``` -------------------------------- ### Get Browser Icon using Avatars Service Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/avatars/get-browser.md Use the `getBrowser` method from the Avatars service to retrieve a browser icon. You can specify the browser code, width, height, and quality. The `Browser.AvantBrowser` constant is used here as an example. ```javascript import { Client, Avatars, Browser } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const avatars = new Avatars(client); const result = avatars.getBrowser({ code: Browser.AvantBrowser, width: 0, // optional height: 0, // optional quality: -1 // optional }); console.log(result); ``` -------------------------------- ### Execute GraphQL Query with Appwrite SDK Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/graphql/query.md This snippet shows how to initialize the Appwrite client, set the endpoint and project, and then execute a GraphQL query. Ensure you replace placeholders with your actual API Endpoint and Project ID. ```javascript import { Client, Graphql } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const graphql = new Graphql(client); const result = await graphql.query({ query: {} }); console.log(result); ``` -------------------------------- ### List Currencies with React Native SDK Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/locale/list-currencies.md Initialize the Appwrite client and use the Locale service to fetch a list of all available currencies. Ensure you have set your API endpoint and project ID. ```javascript import { Client, Locale } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const locale = new Locale(client); const result = await locale.listCurrencies(); console.log(result); ``` -------------------------------- ### Get Transaction Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/databases/get-transaction.md Fetches a transaction using its unique ID. ```APIDOC ## Get Transaction ### Description Retrieves a specific transaction by its ID. ### Method `getTransaction` ### Parameters #### Path Parameters - **transactionId** (string) - Required - The unique identifier of the transaction to retrieve. ### Request Example ```javascript const result = await databases.getTransaction({ transactionId: '' }); ``` ### Response #### Success Response (200) - **transaction** (object) - The transaction object containing details of the transaction. #### Response Example ```json { "$id": "60c72b2f96715", "$createdAt": "2023-10-27T10:00:00.000+00:00", "$updatedAt": "2023-10-27T10:00:00.000+00:00", "collectionId": "60c72b2f96715", "databaseId": "60c72b2f96715", "amount": 1000, "currency": "USD", "status": "completed", "userId": "60c72b2f96715" } ``` ``` -------------------------------- ### Create User Account Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/account/create.md Use this snippet to create a new user account. Ensure you have initialized the Appwrite client with your endpoint and project ID. The userId, email, and password are required fields. ```javascript import { Client, Account } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); const result = await account.create({ userId: '', email: 'email@example.com', password: 'password', name: '' // optional }); console.log(result); ``` -------------------------------- ### Get Transaction by ID Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/tablesdb/get-transaction.md Fetches a transaction using its unique identifier. ```APIDOC ## Get Transaction ### Description Retrieves a specific transaction by its ID. ### Method `getTransaction` ### Parameters #### Path Parameters - **transactionId** (string) - Required - The unique identifier of the transaction to retrieve. ### Request Example ```javascript const result = await tablesDB.getTransaction({ transactionId: '' }); ``` ### Response #### Success Response (200) - **transaction** (object) - The transaction object containing details of the transaction. - **$id** (string) - The unique identifier of the transaction. - **$createdAt** (string) - The timestamp when the transaction was created. - **$updatedAt** (string) - The timestamp when the transaction was last updated. - **amount** (integer) - The amount of the transaction. - **currency** (string) - The currency of the transaction. - **status** (string) - The status of the transaction (e.g., 'pending', 'completed', 'failed'). - **paymentMethod** (string) - The payment method used for the transaction. - **description** (string) - A description of the transaction. - **userId** (string) - The ID of the user associated with the transaction. - **collectionId** (string) - The ID of the collection the transaction belongs to. - **databaseId** (string) - The ID of the database the transaction belongs to. #### Response Example ```json { "$id": "60c72b2f9b1e4c001f8e4c7a", "$createdAt": "2023-10-27T10:00:00.000+00:00", "$updatedAt": "2023-10-27T10:00:00.000+00:00", "amount": 1000, "currency": "USD", "status": "completed", "paymentMethod": "credit_card", "description": "Payment for order #123", "userId": "60c72b2f9b1e4c001f8e4c7a", "collectionId": "60c72b2f9b1e4c001f8e4c7a", "databaseId": "60c72b2f9b1e4c001f8e4c7a" } ``` ``` -------------------------------- ### Get Team by ID Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/teams/get.md Retrieves a specific team using its unique ID. ```APIDOC ## Get Team ### Description Retrieves a specific team using its unique ID. ### Method `teams.get({ teamId: '' })` ### Parameters #### Path Parameters - **teamId** (string) - Required - The unique identifier of the team to retrieve. ### Request Example ```javascript const result = await teams.get({ teamId: '' }); ``` ### Response #### Success Response (200) - **$id** (string) - The team's unique identifier. - **name** (string) - The name of the team. - **createdAt** (string) - The date the team was created. - **updatedAt** (string) - The date the team was last updated. - **membersCount** (integer) - The number of members in the team. - **total** (integer) - The total number of teams available (used for pagination, though not directly applicable to this 'get' operation). #### Response Example ```json { "$id": "60a9b1c3f1b2c3d4e5f6", "name": "Example Team", "createdAt": "2023-01-01T12:00:00.000+00:00", "updatedAt": "2023-01-01T12:00:00.000+00:00", "membersCount": 5, "total": 1 } ``` ``` -------------------------------- ### List Transactions Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/databases/list-transactions.md Use this snippet to fetch all transactions. Ensure you have initialized the Appwrite client and Databases service with your project details. ```javascript import { Client, Databases } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const databases = new Databases(client); const result = await databases.listTransactions({ queries: [] // optional }); console.log(result); ``` -------------------------------- ### List Teams with React Native SDK Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/teams/list.md Initialize the Appwrite client and use the Teams service to list all teams. Optional queries, search terms, and total count can be specified. ```javascript import { Client, Teams } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); const result = await teams.list({ queries: [], // optional search: '', // optional total: false // optional }); console.log(result); ``` -------------------------------- ### Get Session Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/account/get-session.md Use the `getSession` method to retrieve session details using the session ID. ```APIDOC ## Get Session ### Description Retrieves a user's session by its ID. ### Method `account.getSession(sessionId: string)` ### Parameters #### Path Parameters - **sessionId** (string) - Required - The ID of the session to retrieve. ### Request Example ```javascript const result = await account.getSession({ sessionId: '' }); console.log(result); ``` ### Response #### Success Response (200) - **session** (object) - The session object. - **$id** (string) - Session ID. - **userId** (string) - User ID. - **$createdAt** (string) - Timestamp when the session was created. - **$updatedAt** (string) - Timestamp when the session was last updated. - **ip** (string) - IP address of the client. - **userAgent** (string) - User agent of the client. - **platform** (string) - Platform of the client. - **os** (string) - Operating system of the client. - **client** (string) - Client type. - **client_id** (string) - Client ID. - ** காரணங்கள்** (string) - Reason for session creation. - **secret** (string) - Secret associated with the session. #### Response Example ```json { "$id": "60a9b1c3f0e1a2b3c4d5e6f7", "userId": "60a9b1c3f0e1a2b3c4d5e6f7", "$createdAt": "2021-05-25T10:00:00.000+00:00", "$updatedAt": "2021-05-25T10:00:00.000+00:00", "ip": "192.168.1.1", "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", "platform": "Windows", "os": "Windows 10", "client": "Chrome", "client_id": "chrome_90", " காரணங்கள்": "login", "secret": "your_session_secret" } ``` ``` -------------------------------- ### Initialize Appwrite SDK Source: https://github.com/appwrite/sdk-for-react-native/blob/main/README.md Initialize the React Native SDK with your Appwrite server endpoint, project ID, and application ID. ```javascript import { Client } from 'react-native-appwrite'; // Init your React Native SDK const client = new Client(); client .setEndpoint('http://localhost/v1') // Your Appwrite Endpoint .setProject('455x34dfkj') // Your project ID .setPlatform('com.example.myappwriteapp') // Your application ID or bundle ID. ; ``` -------------------------------- ### Get Account Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/account/get.md Retrieves the current user's account information. Requires the user to be logged in. ```APIDOC ## Get Account ### Description Retrieves the current user's account information. Requires the user to be logged in. ### Method GET ### Endpoint /account ### Parameters None ### Request Example None ### Response #### Success Response (200) - **$id** (string) - The user's unique ID. - **name** (string) - The user's name. - **email** (string) - The user's email address. - **registration** (string) - The timestamp of user registration. - **prefs** (object) - User preferences. #### Response Example ```json { "$id": "63f7c7a7e1f1f1f1f1f1f1f1", "name": "John Doe", "email": "john.doe@example.com", "registration": "2023-02-23T10:00:00.000+00:00", "prefs": {} } ``` ``` -------------------------------- ### List Files in a Bucket - React Native Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/storage/list-files.md Use this snippet to list files in a specified bucket. Ensure you have initialized the Appwrite client and storage service. Optional parameters for queries and search can be provided. ```javascript import { Client, Storage } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const storage = new Storage(client); const result = await storage.listFiles({ bucketId: '', queries: [], // optional search: '', // optional total: false // optional }); console.log(result); ``` -------------------------------- ### Get Flag Image Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/avatars/get-flag.md Retrieves the image of a country flag. You can specify the desired width, height, and quality of the image. ```APIDOC ## GET /v1/avatars/flag ### Description Retrieves the image of a country flag. You can specify the desired width, height, and quality of the image. ### Method GET ### Endpoint /v1/avatars/flag ### Parameters #### Query Parameters - **code** (string) - Required - Country ISO 3166-1 alpha-2 code. Use the `Flag` enum for available codes. - **width** (integer) - Optional - Width of the image in pixels. Defaults to 100. - **height** (integer) - Optional - Height of the image in pixels. Defaults to 100. - **quality** (integer) - Optional - Quality of the image. Defaults to 100. Minimum is 0, maximum is 100. ### Response #### Success Response (200) - **image** (file) - The flag image file. ### Request Example ```javascript const avatars = new Avatars(client); const result = avatars.getFlag({ code: Flag.Afghanistan, width: 128, height: 128, quality: 80 }); ``` ``` -------------------------------- ### Get Account Preferences Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/account/get-prefs.md Fetches the current user's account preferences. This method requires the user to be authenticated. ```APIDOC ## GET /account/prefs ### Description Retrieves the user's account preferences. ### Method GET ### Endpoint /account/prefs ### Response #### Success Response (200) - **prefs** (object) - An object containing the user's preferences. ### Request Example ```javascript const result = await account.getPrefs(); console.log(result); ``` ### Response Example ```json { "prefs": { "exampleKey": "exampleValue" } } ``` ``` -------------------------------- ### Get Team Preferences Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/teams/get-prefs.md Retrieves the preferences object for a specific team. This allows you to access custom settings configured for a team. ```APIDOC ## GET /teams/{teamId}/prefs ### Description Retrieves the preferences object for a specific team. ### Method GET ### Endpoint /teams/{teamId}/prefs ### Parameters #### Path Parameters - **teamId** (string) - Required - The unique identifier of the team whose preferences are to be retrieved. ### Response #### Success Response (200) - **prefs** (object) - An object containing the team's preferences. ### Response Example ```json { "prefs": { "customKey": "customValue" } } ``` ``` -------------------------------- ### Update User Preferences Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/account/update-prefs.md Use the `updatePrefs` method to set or update user-specific preferences. Ensure the client and account are initialized with your project details. ```javascript import { Client, Account } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); const result = await account.updatePrefs({ prefs: { "language": "en", "timezone": "UTC", "darkTheme": true } }); console.log(result); ``` -------------------------------- ### Get Team Membership Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/teams/get-membership.md Use the `getMembership` method to fetch a team membership by providing the team ID and membership ID. ```APIDOC ## Get Team Membership ### Description Retrieves a specific team membership by its ID. ### Method ```javascript teams.getMembership({teamId: '', membershipId: ''}) ``` ### Parameters #### Path Parameters - **teamId** (string) - Required - The ID of the team. - **membershipId** (string) - Required - The ID of the membership. ### Request Example ```javascript const result = await teams.getMembership({ teamId: '', membershipId: '' }); ``` ### Response #### Success Response (200) Returns the membership object. ```json { "$id": "membership_id", "$createdAt": "timestamp", "$updatedAt": "timestamp", "userId": "user_id", "teamId": "team_id", "invited": "timestamp", "joined": "timestamp", "role": "string" } ``` ``` -------------------------------- ### Get Locale Information Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/locale/get.md Retrieves the current locale information for the project. This includes the default locale, locales available, and other localization-related settings. ```APIDOC ## GET /locale ### Description Retrieves the current locale information for the project. ### Method GET ### Endpoint /locale ### Parameters None ### Request Example None ### Response #### Success Response (200) - **default** (string) - The default locale code. - **localeCodes** (array) - An array of available locale codes. #### Response Example { "result": { "default": "en", "localeCodes": ["en", "es", "fr"] } } ``` -------------------------------- ### List Documents in React Native Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/databases/list-documents.md Use this snippet to fetch documents from a collection. Ensure your client is initialized with your project's endpoint and ID. Optional parameters like `queries`, `transactionId`, `total`, and `ttl` can be provided. ```javascript import { Client, Databases } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const databases = new Databases(client); const result = await databases.listDocuments({ databaseId: '', collectionId: '', queries: [], // optional transactionId: '', // optional total: false, // optional ttl: 0 // optional }); console.log(result); ``` -------------------------------- ### Get Credit Card Icon Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/avatars/get-credit-card.md Generates a credit card icon based on the provided card code and optional dimensions and quality. ```APIDOC ## Get Credit Card Icon ### Description Generates a credit card icon. You can specify the card code (e.g., Visa, Mastercard, American Express) and optionally provide width, height, and quality parameters. ### Method ```javascript avatars.getCreditCard({ code: CreditCard.AmericanExpress, width: 0, height: 0, quality: -1 }) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **code** (string) - Required - The credit card type code. Use constants from `CreditCard` enum (e.g., `CreditCard.AmericanExpress`). - **width** (integer) - Optional - The desired width of the icon in pixels. Defaults to 0. - **height** (integer) - Optional - The desired height of the icon in pixels. Defaults to 0. - **quality** (integer) - Optional - The quality of the image (0-100). Defaults to -1 (Appwrite default). ### Request Example ```javascript const result = avatars.getCreditCard({ code: CreditCard.AmericanExpress, width: 128, height: 128, quality: 80 }); ``` ### Response #### Success Response (200) Returns the URL of the generated credit card icon. - **url** (string) - The URL of the credit card icon. ``` -------------------------------- ### Create Document with React Native SDK Source: https://github.com/appwrite/sdk-for-react-native/blob/main/docs/examples/databases/create-document.md Use this snippet to create a new document in your Appwrite database. Ensure you have initialized the client with your project's endpoint and ID. Permissions and transaction IDs are optional parameters. ```javascript import { Client, Databases, Permission, Role } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const databases = new Databases(client); const result = await databases.createDocument({ databaseId: '', collectionId: '', documentId: '', data: { "username": "walter.obrien", "email": "walter.obrien@example.com", "fullName": "Walter O'Brien", "age": 30, "isAdmin": false }, permissions: ["read(\"any\")"], // optional transactionId: '' // optional }); console.log(result); ```