Getting Started with the CaseLocker Python API

Estimated reading: 4 minutes

To use the CaseLocker Python API, you’ll need to meet the following requirements:

After creating your virtual environment, install the caselockerapi package by running

pip install caselockerapi

Client/ClientHelper

For the CaseLocker API, there are two Clients you can use – Client, a general API login, and ClientHelper, which adds login prompts and command line arguments.

Import Client or ClientHelper from caselockerapi.client to begin.

Quick Start

from caselockerapi.client import ClientHelper
client = ClientHelper()
client.authenticate()

Client.authenticate(DOMAIN, USERNAME, PASSWORD)

client.authenticate(DOMAIN="mysite.litigationlocker.com", USERNAME="username", PASSWORD="password")

When using the Client, the authenticate function can be called without any parameters. If called without parameters, authenticate will check for the environment variables CASELOCKER_DOMAIN, CASELOCKER_USERNAME, and CASELOCKER_PASSWORD.

ClientHelper – Command Line Argument Authentication

If using the ClientHelper, you can also authenticate via command line arguments, the following will prompt for the password when ran:

python myScript.py --s mysite.litigationlocker.com --u username --p

To pass the password in an argument, use –password (not recommended for security reasons)
python myScript.py –s mysite.litigationlocker.com –u username –pa


Getting Started with the CaseLocker Python API

3 years ago

To use the CaseLocker Python API, you’ll need to meet the following requirements:

After creating your virtual environment, install the caselockerapi package by running

pip install caselockerapi

Client/ClientHelper

For the CaseLocker API, there are two Clients you can use – Client, a general API login, and ClientHelper, which adds login prompts and command line arguments.

Import Client or ClientHelper from caselockerapi.client to begin.

Quick Start

from caselockerapi.client import ClientHelper
client = ClientHelper()
client.authenticate()

Client.authenticate(DOMAIN, USERNAME, PASSWORD)

client.authenticate(DOMAIN="mysite.litigationlocker.com", USERNAME="username", PASSWORD="password")

When using the Client, the authenticate function can be called without any parameters. If called without parameters, authenticate will check for the environment variables CASELOCKER_DOMAIN, CASELOCKER_USERNAME, and CASELOCKER_PASSWORD.

ClientHelper – Command Line Argument Authentication

If using the ClientHelper, you can also authenticate via command line arguments, the following will prompt for the password when ran:

python myScript.py --s mysite.litigationlocker.com --u username --p

To pass the password in an argument, use –password (not recommended for security reasons)

python myScript.py --s mysite.litigationlocker.com --u username --password "myPassword"

Basic API Functions

All API Objects have the following common functions, most which match REST API calls:

list(search, ordering, page, per_page, params)

userforms = UserForm(client)
results = userforms.list(search="String", page=1, per_page=25, params={
"template": "Form Template"
})

This will create a list result of all userforms that match the search query. To iterate through all results, use the all_results() function.

Note: If modifying the objects in a list result, it is recommended you store the results before making modifications, as all_results may change as results are fetched.

for form in results.all_results():
# do something

get(pk)

userforms = UserForm(client)
formObject = userforms.get(123) # returns UserForm object with the ID 123

post(obj)

userforms = UserForm(client)
userforms.post({}) # Creates a new UserForm object

patch(pk, obj)

userforms = UserForm(client)
userforms.patch(123, {}) # Updates UserForm object 123 with the dict passed

delete(pk)

userforms = UserForm(client)
userforms.delete(123) # Deletes the UserForm 123 (Note: some objects prevent deletion if data exists)

put(pk, obj)

userforms = UserForm(client)
userforms.put(123, {}) # Updates the entire object, requires all necessary attributes.

move(pk, location)

In objects that are ordered (Question, Section, Paragraph, Signature), move will move this object to the index specified in the template.

question = Question(client)
question.move(123, 3) # Moves the question to a specific index in its parent section
Share this Doc

Getting Started with the CaseLocker Python API

Or copy link

CONTENTS