A pure JavaScript client for the Anytype API, generated from the OpenAPI specification.
npm install anytype-clientA pure JavaScript client for the Anytype API, generated from the OpenAPI specification.
Install via npm:
``bash`
npm install anytype-client
Or using yarn:
`bash`
yarn add anytype-client
`javascript
import { AnytypeClient } from 'anytype-client';
// Initialize the client
const client = new AnytypeClient({
BASE: 'https://api.anytype.io',
HEADERS: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
`
#### List Spaces
`javascript`
const spaces = await client.spaces.listSpaces();
console.log(spaces);
#### Create an Object
`javascript`
const newObject = await client.objects.createObject('space_id', {
type_key: 'page',
name: 'My New Page',
body: 'This is the content of my page'
});
console.log(newObject);
#### List Objects in a Space
`javascript`
const objects = await client.objects.listObjects('space_id', '2025-11-08', 0, 100);
console.log(objects);
#### Search Objects
`javascript`
const searchResults = await client.search.searchObjectsWithinASpace('space_id', {
query: 'search term',
limit: 10
});
console.log(searchResults);
#### Update an Object
`javascript`
const updated = await client.objects.updateObject('space_id', 'object_id', {
name: 'Updated Name',
body: 'Updated content'
});
console.log(updated);
The client includes the following services:
- client.auth - Authentication (start challenge, retrieve token)client.objects
- - Object management (create, read, update, delete, export)client.spaces
- - Space managementclient.lists
- - List/Set operationsclient.types
- - Type managementclient.templates
- - Template operationsclient.tags
- - Tag managementclient.properties
- - Property managementclient.members
- - Member managementclient.search` - Search operations
-
- All API calls return Promises
- The client uses the Fetch API for HTTP requests
- Error handling follows standard Promise rejection patterns