API Documentation
cocoPy
cocoLog
- class cocoAPI.cocoLog.cocoLog[source]
Bases:
object- login(email, password)[source]
Log in to the COCONUT API and store the access token. On success, stores the access token and sets the Authorization header.
- Parameters:
email – Email address for COCONUT account
password – Password for COCONUT account
- Returns:
Raises errors if found
- Return type:
error
cocoBase
- class cocoAPI.cocoBase.cocoBase(cocoLog)[source]
Bases:
objectBase class for COCONUT API GET and POST requests.
cocoGet
- class cocoAPI.cocoGet.cocoGet(cocoLog)[source]
Bases:
cocoBaseClass for COCONUT API GET requests.
cocoSearch
- class cocoAPI.cocoSearch.cocoSearch(cocoLog)[source]
Bases:
cocoBaseClass for COCONUT API search endpoints.
- _build_search_req(resource_endpoint, search_query)[source]
Builds search request from a search_query list of entries, where each entry has format [key, field, value].
- Parameters:
resource_endpoint – COCONUT API endpoint to search
search_query – List of entries, where each entry has format [key, field, value]
- Returns:
Search request from search_query
- Return type:
dict
- _check_search_query(resource_endpoint, search_query)[source]
Performs several checks on search_query to ensure correct format.
- Parameters:
resource_endpoint – COCONUT API endpoint to search
search_query – List of entries, where each entry has format [key, field, value]
- Returns:
Raises errors if found
- Return type:
error
- _paginate_search_data(endpoint, json_body, sleep_time)[source]
Performs pagination on the data returned from the COCONUT API search request.
- Parameters:
endpoint – COCONUT API endpoint
json_body – JSON body for the search request
sleep_time – Time to sleep between requests to avoid rate limiting
- Returns:
dict – Complete results from the COCONUT API search request
error – Raises errors if found
- get_all_records(resource_endpoint, pg_limit=25, sleep_time=0)[source]
Get all records from COCONUT API endpoint to search.
- Parameters:
resource_endpoint – COCONUT API endpoint to search
pg_limit – Number of results per page
sleep_time – Time to sleep to avoid rate limiting
- Returns:
dict – Complete results from search request
error – Raises errors if found
- query(resource_endpoint, search_query, sleep_time=0)[source]
Performs COCONUT search request and returns the json response.
- Parameters:
resource_endpoint – COCONUT resource to search
search_query – List of entries, where each entry has format [key, field, value]
sleep_time – Time to sleep between requests to avoid rate limiting
- Returns:
dict – Complete results from search request
error – Raises errors if found
cocoAdvSearch
- class cocoAPI.cocoAdvSearch.cocoAdvSearch(cocoLog)[source]
Bases:
cocoBaseClass for COCONUT API advanced search endpoint.
- _build_adv_search_req(adv_search_query)[source]
Builds advanced search request from a adv_search_query list of entries, where each entry has format [type, tag|filter, value].
- Parameters:
adv_search_query – List of entries, where each entry has format [type, tag|filter, value]
- Returns:
dict – Advanced search request from adv_search_query
error – Raises errors if found
- _check_adv_search_query(adv_search_query)[source]
Performs several checks on adv_search_query to ensure correct format.
- Parameters:
adv_search_query – List of entries, where each entry has format [type, tag|filter, value]
- Returns:
Raises errors if found
- Return type:
error
- _paginate_adv_search_data(json_body: dict, sleep_time: int = 0, pg_limit: int = 25)[source]
Performs pagination on the data returned from the COCONUT API advanced search request.
- Parameters:
json_body – JSON body for the advanced search request
sleep_time – Time to sleep to avoid rate limiting. Default is 0
pg_limit – Number of results per page. Default is 25
- Returns:
dict – Complete results from the COCONUT API advanced search request
error – Raises errors if found
- advanced_query(adv_search_query, sleep_time: int = 0, pg_limit: int = 25)[source]
Runs advanced search request from adv_search_query and returns the json response.
- Parameters:
adv_search_query – List of entries, where each entry has format [type, tag|filter, value]
sleep_time – Time to sleep between requests to avoid rate limiting. Default is 0
pg_limit – Number of results per page. Default is 25
- Returns:
dict – Complete results from the COCONUT API advanced search request
error – Raises errors if found
- get_all_adv_records(pg_limit: int = 25, sleep_time: int = 0)[source]
Get all records from COCONUT API advanced search endpoint.
- Parameters:
pg_limit – Number of results per page. Default is 25
sleep_time – Time to sleep to avoid rate limiting. Default is 0
- Returns:
dict – Complete results from the COCONUT API advanced search request
error – Raises errors if found