## Introduction
ParaClient is a powerful client library that allows developers to integrate the Para API into their applications. With ParaClient, you can easily perform CRUD operations, manage permissions, and handle other advanced features of the Para platform.
## Installation
To install ParaClient, follow the steps below:
- Open your terminal or command prompt.
- Navigate to the root directory of your project.
- Run the following command:
“`bash
npm install paraclient
“`
## Usage
To begin using ParaClient in your application, follow the steps below:
- Import ParaClient into your project:
“`javascript
const { ParaClient } = require(‘paraclient’);
“`
Next, create a new ParaClient object and configure it:
“`javascript
const paraClient = new ParaClient({
endpoint: ‘https://your-paraserver-endpoint.com’,
secretKey: ‘your-secret-key’
});
“`
You can now use `paraClient` to interact with the Para API. Below are some examples of common actions:
### Create an object
“`javascript
const newObject = {
type: ‘user’,
name: ‘John Doe’,
age: 30
};
paraClient.create(newObject)
.then((response) => {
console.log(‘Object created:’, response);
})
.catch((error) => {
console.error(‘Error creating object:’, error);
});
“`
### Retrieve an object
“`javascript
const objectId = ‘your-object-id’;
paraClient.retrieve(objectId)
.then((response) => {
console.log(‘Retrieved object:’, response);
})
.catch((error) => {
console.error(‘Error retrieving object:’, error);
});
“`
### Update an object
“`javascript
const updatedObject = {
objectId: ‘your-object-id’,
name: ‘Jane Smith’,
age: 35
};
paraClient.update(updatedObject)
.then((response) => {
console.log(‘Object updated:’, response);
})
.catch((error) => {
console.error(‘Error updating object:’, error);
});
“`
### Delete an object
“`javascript
const objectId = ‘your-object-id’;
paraClient.delete(objectId)
.then((response) => {
console.log(‘Object deleted:’, response);
})
.catch((error) => {
console.error(‘Error deleting object:’, error);
});
“`
## Additional Features
Apart from the basic CRUD operations, ParaClient provides some additional features that you might find useful:
### Permissions
To manage permissions for an object or user, you can use the following methods:
grantPermission(objectId, permission)
: Grants the specified permission to the object with the given ID.revokePermission(objectId, permission)
: Revokes the specified permission from the object with the given ID.getUserPermissions(userId)
: Retrieves the permissions of a user with the given ID.
### Searching
ParaClient also enables you to perform searches using the powerful Para search syntax. The following method is available for searching:
search(query)
: Searches for objects matching the given query.
## Roadmap
Here are some upcoming features that will be added to ParaClient in future releases:
- Support for bulk operations
- Improved error handling and logging
- Integration with third-party authentication providers
## Conclusion
ParaClient is an essential toolkit for developers who want to integrate Para API into their applications seamlessly. By following the installation instructions and exploring the available features, you can leverage ParaClient to build powerful and scalable applications.