Developer Interface

This part of the documentation covers all the interfaces of ccapi.

Main Interface

All of ccapi’s functionality can be accessed by the Client object.

class ccapi.Client(base_url=None, proxies=[], test=True, cache_timeout=None)

The Client class provides a convenient access to the Cell Collective API. Instances of this class are a gateway to interacting with Cell Collective’s API through the ccapi.

Parameters:
  • base_url – A base URL to use.
  • proxies – A dictionary/list of proxies to use. If a list is passed, each element in the list should be a dictionary of the format { protocol: ip }.
  • test – Attempt to test the connection to the base url.

Usage:

>>> import ccapi
>>> client = ccapi.Client()
>>> client
<Client url='https://cellcollective.org'>
auth(*args, **kwargs)

Authenticate client.

Usage:

>>> import ccapi
>>> client = ccapi.Client()
>>> client.auth(
        email    = "test@cellcollective.org",
        password = "test"
    )
>>> client.authenticated
True

>>> client.auth(token = "<YOUR_AUTH_TOKEN>")
>>> client.authenticated
True
get(resource, *args, **kwargs)

Get resources.

Parameters:resource – Resource name.
logout()

Logout client.

me(*args, **kwargs)

Get the user profile of the authenticated client.

Usage:

>>> import ccapi
>>> client = ccapi.Client()
>>> client.auth(email = "test@cellcollective.org", password = "test")
>>> client.me()
<User id=10887 name='Test Test'>
ping(*args, **kwargs)

Check if the URL is alive.

Parameters:
  • args – Arguments provided to client.request
  • kwargs – Keyword Arguments provided to client.request

Usage:

>>> import ccapi
>>> client = ccapi.Client()
>>> client.ping()
'pong'
post(url, *args, **kwargs)

Dispatch a POST request to the server.

param url:URL part (does not include the base URL).
param args:Arguments provided to client.request
param kwargs:Keyword Arguments provided to client.request

Usage:

>>> import ccapi
>>> client   = ccapi.Client()
>>> response = client.post("api/module/12345/report")
>>> response.content
b'"First Name","Last Name","Email","Institution","Last Updated Date"

put(url, *args, **kwargs)

Dispatch a PUT request to the server.

raise_for_authentication()

Raise AuthenticationError in case the client hasn’t been authenticated.

read(filename, type=None, save=False)

Read a model file.

Parameters:
  • filename – Name of the file locally present to read a model file.
  • save – Save model after importing.
search(resource, query, *args, **kwargs)

Search a resource.

Parameters:
  • resource – Name of the resource.
  • query – Search a query string.
version

Version of the Build Service.

Usage:

>>> import ccapi
>>> client = ccapi.Client()
>>> client.version
'2.6.2'