shamrock package

Submodules

shamrock.shamrock module

Shamrock - A Trefle API Integration.

class shamrock.shamrock.Shamrock(token: str, page_size: Optional[int] = None)

Bases: object

API integration for Trefle service.

ENDPOINT(endpoint: str, pk: Optional[int] = None, **kwargs) → Any

Query the endpoint of the Trefle API and return results.

This method is called on any endpoint defined for the API. It can return any result from it or None if it doesn’t succeed.

Parameters:
  • endpoint (str) – An endpoint where the library will make a request.
  • pk (int) – (optional) A primary key of the element.
  • kwargs (dict) – Any query strings to add to the search object.
Returns:

Any JSON that gets decoded from a successful response or None if it fails.

Return type:

Any

NAVIGATE(navigation: str, **kwargs) → Any

Navigate the API if any navigation exists on the results once the first call is made and stored on the instance.

This method is called on any navigation defined for the API. It can return any result from it or None if it doesn’t succeed.

Parameters:
  • navigation (str) – A navigation option where the library will make a request.
  • kwargs (dict) – Any query strings to add to the search object.
Returns:

Any JSON that gets decoded from a successful response or None if it fails.

Return type:

Any

search(q: str, **kwargs) → Any

Search the species and return results of the API call.

Searches the Trefle database of any matching species of plants and returns either successful results or None.

Parameters:
  • q (str) – A string that is used to search the species with.
  • kwargs (dict) – Any query strings to add to the search object.
Returns:

Any JSON that gets decoded from a successful response or None if it fails.

Return type:

Any

Module contents

Shamrock - A Trefle API Integration.

class shamrock.Shamrock(token: str, page_size: Optional[int] = None)

Bases: object

API integration for Trefle service.

ENDPOINT(endpoint: str, pk: Optional[int] = None, **kwargs) → Any

Query the endpoint of the Trefle API and return results.

This method is called on any endpoint defined for the API. It can return any result from it or None if it doesn’t succeed.

Parameters:
  • endpoint (str) – An endpoint where the library will make a request.
  • pk (int) – (optional) A primary key of the element.
  • kwargs (dict) – Any query strings to add to the search object.
Returns:

Any JSON that gets decoded from a successful response or None if it fails.

Return type:

Any

NAVIGATE(navigation: str, **kwargs) → Any

Navigate the API if any navigation exists on the results once the first call is made and stored on the instance.

This method is called on any navigation defined for the API. It can return any result from it or None if it doesn’t succeed.

Parameters:
  • navigation (str) – A navigation option where the library will make a request.
  • kwargs (dict) – Any query strings to add to the search object.
Returns:

Any JSON that gets decoded from a successful response or None if it fails.

Return type:

Any

search(q: str, **kwargs) → Any

Search the species and return results of the API call.

Searches the Trefle database of any matching species of plants and returns either successful results or None.

Parameters:
  • q (str) – A string that is used to search the species with.
  • kwargs (dict) – Any query strings to add to the search object.
Returns:

Any JSON that gets decoded from a successful response or None if it fails.

Return type:

Any