const client = new CozyStackClient(options)

Usage no npm install needed!

<script type="module">
  import cozyStackClient from '';



The constructor

const client = new CozyStackClient(options)


  • uri: The Cozy instance URI ;
  • token: The token given by the stack.


A collection is the set of all documents of a same doctype.

Selecting a collection is done by calling the collection() method, passing it the doctype:

const todos = client.collection('io.cozy.todos')

Listing all documents

const allTodos = await todos.all()


By default, the stack limits the number of query results to 100 documents. If the limit causes some documents not to be returned, the response will have a next: true property.

By using the skip and limit options you can build your own pagination:

const firstPage = await todos.all({ limit: 100 })
if ( {
  const secondPage = await todos.all({ skip: 100, limit: 100 })

You can also use the meta.count property to know the total count of documents.

const allTodos = await todos.all()
console.log(`There are ${allTodos.meta.count} todos.`)

Finding documents

const doneTodos = await todos.find({ done: true })