FaunaClient

class faunadb.client.FaunaClient(secret, domain='db.fauna.com', scheme='https', port=None, timeout=60, observer=None, pool_connections=10, pool_maxsize=10, **kwargs)

Directly communicates with FaunaDB via JSON.

For data sent to the server, the to_fauna_json method will be called on any values. It is encouraged to pass e.g. Ref objects instead of raw JSON data.

All methods return a converted JSON response. This is a dict containing lists, ints, floats, strings, and other dicts. Any Ref, SetRef, FaunaTime, or datetime.date values in it will also be parsed. (So instead of { "@ref": "classes/frogs/123" }, you will get Ref("classes/frogs", "123").)

__init__(secret, domain='db.fauna.com', scheme='https', port=None, timeout=60, observer=None, pool_connections=10, pool_maxsize=10, **kwargs)
Parameters:
  • secret – Auth token for the FaunaDB server.
  • domain – Base URL for the FaunaDB server.
  • scheme"http" or "https".
  • port – Port of the FaunaDB server.
  • timeout – Read timeout in seconds.
  • observer – Callback that will be passed a RequestResult after every completed request.
  • pool_connections – The number of connection pools to cache.
  • pool_maxsize – The maximum number of connections to save in the pool.
new_session_client(secret, observer=None)

Create a new client from the existing config with a given secret. The returned client share its parent underlying resources.

Parameters:
  • secret – Credentials to use when sending requests.
  • observer – Callback that will be passed a RequestResult after every completed request.
Returns:

ping(scope=None, timeout=None)

Ping FaunaDB. See the docs.

query(expression)

Use the FaunaDB query API.

Parameters:expression – A query. See Query for information on queries.
Returns:Converted JSON response.