PropertySync API Python Package
For developers and integrators working with Python, we have created a package that provides some basic functionality and workflow for developing powerful integrations with PropertySync quickly.
Internally, we use these tools regularly to facilitate data editing, validation, correction, automated posting, reporting and much more on behalf of a variety of our clients and partners. You can use this package to create automated workflows within your organization or to build custom integrations with PropertySync.
Getting Started
Installation
You can install the package from PyPI:
pip install propertysync
Changelog
You can view the changelog here.
Upgrading
We are constantly adding new features and functionality to the PropertySync API and our companion Python package. To ensure you are using the latest version of the package, you can upgrade it using pip.
To check the current version of the package you have installed and the versions available, run the following command:
pip index versions propertysync
To upgrade to the latest version, run the following command:
pip install --upgrade propertysync
Note: We do our best to maintain compatibility with previous versions of the package. However, we do not guarantee that older versions will continue to work with future versions of the API. If you are using an older version of the package, we recommend upgrading to the latest version to ensure your integrations continue to work. We also recommend that you thouroughly test your integrations after upgrading to ensure that they continue to work as expected.
ApiClient
The main class for interacting with the PropertySync API is the ApiClient. This is a helper class that provides facilities for logging into the API and working with the various API endpoints available.
import propertysync
api = propertysync.ApiClient(
email='email',
password='password',
document_group_id='123456789',
company_id='123456789'
)
All parameters of the initialization method are optional. If no values are passed, the module will attempt to load values available in the following environment variables:
- PROPERTYSYNC_API_EMAIL
- PROPERTYSYNC_API_PASSWORD
- PROPERTYSYNC_DOCUMENT_GROUP_ID
- PROPERTYSYNC_COMPANY_ID
login
This method is used to login to the API and retrieve a session token. This method is called automatically when the ApiClient is instantiated, but can be called again to refresh the session token. Note that the session token is automatically refreshed when it expires so this is not required.
- Usage:
login()
set_document_group_id
This method is used to set (or change) the document_group_id assigned with method calls. If you instantiate a new ApiClient object without passing a document_group_id, you can use this method to set it after instantiation.
- Usage:
set_document_group_id(document_group_id)
Example:
api.set_document_group_id('123456789')
get_info
This method returns details about the currently assigned document group. See Get Document Group Details for more information.
- Usage:
get_info()
get_batches
This method returns a list of active, visible batches within the currently assigned document group.
- Usage:
get_batches()
Example:
import propertysync
api = propertysync.ApiClient(
email='user@domain.com',
password='mypassword123',
document_group_id='9264a050-2538-45e9-a7cb-1234567890'
)
batch_list = api.get_batches()
print(batch_list)
"""
Output
[
{
"id": "a7ede104-e89d-4ace-a78b-1234567890",
"documentGroupId": "9264a050-2538-45e9-a7cb-1234567890",
"createdAt": "2023-04-04T00:07:47.000000Z",
"updatedAt": "2023-04-04T00:07:47.000000Z",
"name": "My Batch Name",
"createdBy": "Rob Martinson",
"lastModifiedBy": "Rob Martinson",
"lastModifiedAt": "2023-04-04 23:00:54",
"numOfDocs": 6,
"numOfCompletedDocs": 6
},
{
"id": "a7ede104-e89d-4ace-a78b-0987654321",
"documentGroupId": "9264a050-2538-45e9-a7cb-1234567890",
"createdAt": "2023-04-04T00:07:47.000000Z",
"updatedAt": "2023-04-04T00:07:47.000000Z",
"name": "My Other Batch Name",
"createdBy": "Rob Martinson",
"lastModifiedBy": "Rob Martinson",
"lastModifiedAt": "2023-04-04 23:00:54",
"numOfDocs": 6,
"numOfCompletedDocs": 6
}
]
"""
create_batch
- Usage:
create_batch(batch_name, search_id=None)
create_batch_from_json
Create a batch in PropertySync from a JSON batch file (see Batches for more information). If the save_to_search parameter is set to True, this call will count all documents in the provided batch file and will wait until all documents have been processed by PropertySync before returning. It will wait for the number of seconds specified in the wait_time parameter before checking the status of the batch again. Once all documents have been successfully processed, the batch will be saved to search, making it live in the plant.
- Usage:
create_batch_from_json(json, save_to_search=False, wait_time=2):
update_batch_from_json
Update a batch from a JSON batch file. If no batch_id is passed, the batch_id will be extracted from the JSON document if it exists. If it does not exist, an exception will be thrown. If a batch_id is passed, it's value will override any batch_id found in the JSON document.
- Usage:
update_batch_from_json(json, batch_id=None)
create_batch_from_url
- Usage:
create_batch_from_url(url)
delete_batch
- Usage:
delete_batch(batch_id)
get_batch_info
- Usage:
get_batch_info(batch_id)
get_batch
- Usage:
get_batch(batch_id, filter=None):
save_batch_to_search
- Usage:
save_batch_to_search(batch_id)
get_autocompletes
- Usage:
get_autocompletes(type=None, search=None):
delete_autocomplete
- Usage:
delete_autocomplete(autocomplete_id)
add_autocomplete
- Usage:
add_autocomplete(type, value)
get_landvalidations
- Usage:
get_landvalidations(type=None, pageSize=10000, page=None):
get_document_ids_from_search
- Usage:
get_document_ids_from_search(search_id)
get_json_from_document_id
- Usage:
get_json_from_document_id(document_id)
get_document_assets
- Usage:
get_document_assets(document_id)
get_document_asset
- Usage:
get_document_asset(document_id, asset_id)
get_document_pdf
Retrieve the PDF for a given document. By default, this retrieves the pdf file and saves it as in the /tmp folder with the name of the document id.
- Usage:
get_document_pdf(document_id)
Example:
# download the file to a temporary local file
image_file = api.get_document_pdf("6FB6A5EB-35B1-4372-872A-16B358A65893")
# image_file should now contain the path to the downloaded file which should be similar to
# /tmp/6FB6A5EB-35B1-4372-872A-16B358A65893.pdf
# move the file to a new location
os.rename(image_file, "/path/to/my.pdf")
get_document_versions
- Usage:
get_document_versions(document_id)
get_orders
- Usage:
get_orders()
close_order
- Usage:
close_order(order_id)
reopen_order
- Usage:
reopen_order(order_id)
get_document_group_metadata
- Usage:
get_document_group_metadata()
run_document_action
- Usage:
run_document_action(batch_id, action_id, document_ids=None):
This will run a document action on a batch. If document_ids is not passed, it will run the action on all documents in the batch. If document_ids is passed, it will run the action on the documents specified in the document_ids list.
validate_document
- Usage:
validate_document(document_json)
This will send a document to the PropertySync validation engine and return the results. If document_json contains an "id" key and no "json" key, it will validate the stored copy of the document. If document_json contains a "json" key and no "id" key, it will validate the json. If document_json contains a "json" key and no "id" key and the "json" contains a "indexingRecordId" key, it will validate the stored copy of the document if it finds a match bae don the indexingRecordId.
run_report
- Usage:
run_report(report_id, params=None)
run_search
- Usage: `run_search(search_query)
Run a search and return the results. See Search for more information. search_query
is the JSON payload of an API search query which can be generated by the Search class.
run_search_and_create_batch
- Usage:
run_search_and_create_batch(search_query, minimum_results=1, wait_time=2, batch_name='python-api-client temp batch', delete_batch=True)
Run a search. If the number of results of the search is at least minimum_results
then create a batch and wait for the batch to fully hydrate checking every wait_time
seconds. If the search does not at least minimum_results
, then throw an exception. If delete_batch
is set to True, then delete the batch after it has been successfully retrieved.
This method is useful in all areas of document editing workflow.
validate_document
- Usage:
validate_document(document_json)
This method can be used to validate a document using PropertySync's server-side validation tables setup for the given document group. If document_json contains an "id" key and no "json" key, it will validate the stored copy of the document if found. If document_json contains a "json" key and no "id" key, it will validate the json that is supplied in document_json, whether or not there is a copy stored in PropertySync. If document_json contains a "json" key and no "id" key and the "json" contains a "indexingRecordId" key, it will validate the stored copy of the document if it can find a matching document with the same indexingRecordId in the document group. Otherwise it will validate the document json as passed.
api_call
- Usage:
api_call(method, url, params=None, body=None, tries=1)
This method is used to call API endpoints directly. Generally this method will be used internally by the ApiClient class itself, but can be used to call endpoints that are not yet implemented in the ApiClient class if required.
Search
The search class is a helper to create new search queries against a given document group.
import propertysync
api = propertysync.ApiClient(
email='user@domain.com',
password='mypassword123',
document_group_id='9264a050-2538-45e9-a7cb-1234567890'
)
# run a search where the address is 123 Main St
search = propertysync.Search()
search.add_address("123 Main St")
search_results = api.run_search(search.get_query())
add_tag
Search for documents containing a specific tag or tags.
- Usage:
add_tag(tag)
add_recording_info
- Usage:
add_recording_info(instrument_type=None, instrument_page=None,instrument_number=None, book_type=None, book_number=None, book_page=None, case_number=None, file_number=None, start_date=None, end_date=None):
add_party
- Usage:
add_party(party_name=None,grantor_name=None, grantee_name=None, soundex=False, proximity=False)
add_subdivision
- Usage:
add_subdivision(addition=None, lot=None, block=None, unit=None, claim=None, mining_survey=None, arb=None, comment=None)
add_parcel
- Usage:
add_parcel(number=None)
add_legal
- Usage:
add_legal(full_text_legal=None, parcel=None)
add_acreage
- Usage:
add_acreage(section=None, township=None, range=None, quarter=None, arb=None, govlot=None, comment=None)
add_address
- Usage:
add_address(address=None, city=None, state=None, zip=None)
add_limit
- Usage:
add_limit(limit)
get_query
Retreive the search query structure. This value can be passed directly to the run_search
method of the ApiClient class.
- Usage:
get_query()
Document
This class represents an individual document within the PropertySync system and provides various helper methods and properties for accessing elements within a document contained in a batch.
Once json is loaded into a document, the root level elements of the document json are exposed as properties. For example, you can access the document id by calling doc.id
or the instrumentNumber by calling doc.instrumentNumber
.
import propertysync
doc = new propertysync.Document(json_string=json_string)
to_json
Dump the document to a JSON string.
- Usage:
to_json()
find
Find uses JSONPath to find elements within the document json. This is a very powerful tool for finding elements within a document. We use the jsonpath-ng library for JSONPath queries which aims to be fully compliant with the JSONPath spec.
For more information on JSONPath, see:
- Usage:
find(json_path)
replace
Replace uses JSONPath to find elements within the document json and replaces them with the given value. This allows you to easily replace either full elements or just document values within a document.
- Usage:
replace(json_path, value)
Batch
This is a helper class for working with PropertySync batch structures in both local files as well as communicating with the API using batch structures.
to_json
Dump the batch to a JSON string.
- Usage:
to_json()
load_from_titlesearch_batch
This method converts a titlesearch batch file into a PropertySync batch file.
- Usage:
load_from_titlesearch_batch(titlesearch_batchfile)
find_documents
find_documents uses JSONPath queries to identify individual documents within a batch. This allows you to search for documents within a batch that match certain criteria and then perform operations on those documents.
- Usage:
find_documents(json_path, where_value)
Example:
# find all documents in the batch where the instrumentType is "WARRANTY DEED"
docs = batch.find_documents("$.instrumentType", "WARRANTY DEED")
replace_in_documents
Replace uses JSONPath queries to identify individual documents within a batch and then replaces the value of the given element with the given value across all documents that match the query in the batch. It can also optionally only match documents where where_json_path contains the where_value.
- Usage:
replace_in_documents(self, json_path, value, where_json_path=None, where_value=None)
Example:
# find all documents in the batch where the grantor last name is SWATZELL
# and replace the grantor last name with SMITH
batch.replace_in_documents("$.grantor.lastName", "SMITH", "$.grantor.lastName", "SWATZELL")
# replace the instrument type with "WARRANTY DEED" for all documents in the batch
batch.replace_in_documents("$.instrumentType", "WARRANTY DEED")
# replace the instrument type of all "WARRANTY DEED" documents with "QUIT CLAIM DEED"
batch.replace_in_documents("$.instrumentType", "QUIT CLAIM DEED", "$.instrumentType", "WARRANTY DEED")
TitleSearchBatch
This is a helper class for working with batches in the TitleSearch batch format.
# Convert a TitleSearchBatch to a PropertySync batch
batch = propertysync.Batch()
# load the TitleSearch batch
batch.load_from_titlesearch_batch('titlesearch_batch.txt')
# print the batch as a json string
print(batch.get_json())