We need access to SMART Connect Server data via API.
For this the following documentation was found: SMART Connect API Documentation | SMART Conservation Software Project | Assembla.
The more specific documentation for version 7.5.7 (in development) was found in there:
- Open API / Swagger files are available here: Connect 7.5.7 API Files
- Further details on the Connect data API (for uploading data to SMART via Connect) can be found here: SMART Connect Data API
I checked briefly the API in two ways: via command line curl
and via Python
code – both work fine.
import subprocess
import requests
# Define URL
server_url = 'https://<my_smart_connect_server_domain>:8443/server'
api_test = '/api/query/custom/waypoint?waypoint_date=2024-01-01:2024-05-10'
query_url = server_url + api_test
# My credentials
username = '...'
password = '...'
print('==== Python code ====')
# Perform GET request with basic authentication
response = requests.get(query_url, auth=(username, password))
if response.status_code == 200: # Check response status
print("Request successful!")
print(response.json()) # Print out response content
else:
print("Error:", response.status_code)
print('==== Command line ====')
result = subprocess.run(
['curl', '-u', f'{username}:{password}', query_url],
capture_output = True, # Python >= 3.7 only
text = True # Python >= 3.7 only
)
print(result.stdout)
Everything is fine.
Issues
However, we found a lack of functionality in API queries. Though probably we just did not find proper query types.
For example:
- It is possible to get records of the SMART Collect Package type. However, in the resulted JSON in the field
properties: waypoint: source
there isSMARTCOLLECT
instead of the email of a user submitted the record. For us it would be better to have the latter. - It is not clear how to get photo or audio attachments from the SMART Connect Server database. Or it would be even sufficient to have a link to the needed media file.
- It is said in the documentation that the Custom Query API returns 1000 records maximum. The issue followed immediately – how to get all requested records in case if their number is more than 1000. Of course, it might be done by chunks. For this it should be another type of request telling how many there are requested records. The latter could not be found, at least so far.
We would be grateful for your help, hints, ideas.