Learn R Programming

sofa

An easy interface to CouchDB from R

sofa docs: https://docs.ropensci.org/sofa/

CouchDB versions

sofa works with CouchDB v2 and v3. See the builds for checks on various CouchDB versions.

CouchDB Info

Connect to CouchDB

This may be starting it on your terminal/shell

couchdb

Or opening the CouchDB app on your machine, or running it in Docker. Whatever it is, start it up.

Install sofa

From CRAN

install.packages("sofa")

Development version from GitHub

remotes::install_github("ropensci/sofa")

library('sofa')

Cushions

Cushions? What? Since it’s couch we gotta use cushions somehow. cushions are a connection class containing all connection info to a CouchDB instance. See ?Cushion for help.

As an example, connecting to a remote CouchDB-compatible service:

z <- Cushion$new(
  host = "example.com",
  transport = 'https',
  port = NULL,
  user = 'foobar',
  pwd = 'things'
)

Break down of parameters:

  • host: the base url, without the transport (http/https)
  • path: context path that is appended to the end of the url
  • transport: http or https
  • port: The port to connect to. Default: 5984. For Cloudant, have to set to NULL
  • user: User name for the service.
  • pwd: Password for the service, if any.
  • headers: headers to pass in all requests

If you call Cushion$new() with no arguments you get a cushion set up for local use on your machine, with all defaults used.

x <- Cushion$new()

Ping the server

x$ping()

Nice, it’s working.

More

See the docs https://docs.ropensci.org/sofa/ for more.

Meta

Copy Link

Version

Install

install.packages('sofa')

Monthly Downloads

349

Version

0.4.2

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Yaoxiang Li

Last Published

July 21st, 2026

Functions in sofa (0.4.2)

db_revisions

Get document revisions.
db_compact

Request compaction of the specified database
db_replicate

Upload (replicate) a local database to a remote CouchDB-compatible server
db_delete

Delete a database.
design_search

Search design documents
doc_update

Update a document.
design

Work with design documents
doc_upsert

Create a new document or update an existing one
doc_create

Create documents to a database.
doc_delete

Delete a document in a database.
doc_get

Get a document from a database.
documents

Work with documents in CouchDB.
membership

membership
doc_head

Get header info for a document
ping

Ping a CouchDB server
session

session
uuids

Get uuids.
sofa-package

R client for CouchDB.
parse_df

Parse data.frame to json or list by row or column
restart

Restart your CouchDB instance
databases

Work with databases in CouchDB.
Cushion

sofa connection client
db_bulk_create

Create documents via the bulk API
db_bulk_get

Query many documents at once
active_tasks

active tasks
db_bulk_update

Create documents via the bulk API
db_alldocs

List all docs in a given database.
attachments

Work with attachments
db_changes

List changes to a database.
attach_get

Get an attachment
db_info

List database info.
db_create

Create a database.
db_index

Create and get database indexes
db_list

List all databases.
db_explain

Explain API
db_query

Query a database.