Skip to main content

A Trefle API Integration.

Project description

Shamrock - A Trefle API Library

Coverage Status Documentation Status

Shamrock is a Python shallow API library for Trefle integration. It enables interacting with the Trefle plants API in Python to get the information needed for various things you might want to use the API with such as research, gardening software, automation, etc. It is made for use with Python 3.6 and above.

For the full documentation refer to Shamrock documentation.

For more information what the Trefle service provides, refer to the Trefle API documentation. It is also useful for checking out how to use the API with Shamrock library.

Installation

pipenv install shamrock

or

pip install shamrock

Simple Usage Example

from shamrock import Shamrock
api = Shamrock('mytoken')
species = api.species()

Advanced Usage

You can configure the API initially like this:

api = Shamrock(TOKEN)

Methods that can be run with the API are:

api.kingdoms()
api.subkingdoms()
api.divisions()
api.division_classes()
api.division_orders()
api.families()
api.genus()
api.plants()
api.species()

They correspond to the Trefle API endpoints.

You can also query a specific item from the database:

api.plants(103505)

Searching is covered with a separate method:

api.search("tomato")

Navigating the API is covered with these methods:

api.next()
api.prev()
api.first()
api.last()

It will work only if you previously made a request. For example:

api.species()
api.next()

You can also use the varoius query string options described on Trefle API documentation as keyword arguments in methods, however, be careful when unpacking filters, for example:

filters = {"filter[common_name]" : "blackwood"}
api.species(**filters)

History

0.0.1 (27.04.2019.)

  • First release on PyPI.

0.0.2 (21.07.2020.)

  • Trefle.io changed so this release retains links to an old version that is to be removed.

0.1.0 (22.07.2020.)

  • Trefle.io updated so these things were changed:
    • Authorization is now handled through query parameter, copy module needed, new query_parameters property added and removed headers property.

    • Pagination handled through links in the body and made relative instead of absolute. No more page size.

    • Gzip response needed to unwrap the JSON response now. Will remove this in the future versions.

    • New bascic endpoints added for division classes, division orders and distributions.

    • Added new methods for client-side auth, selecting plants by distributions or genus, submitting errors and corrections.

    • Genuses endpoint renamed to genus.

    • Versioning of the API started so the url parameter in the constructor is split to base and relative urls.

    • Response changed to handle the added meta and links additions for the navigation.

  • Added ShamrockException wrapper for the low level library exceptions.

0.2.0 (15.07.2021.)

  • Trefle.io got deprecated so base_url parameter is now available when initiating Shamrock for drop-in replacements.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shamrock-0.2.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

shamrock-0.2.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file shamrock-0.2.0.tar.gz.

File metadata

  • Download URL: shamrock-0.2.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.6.13

File hashes

Hashes for shamrock-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f1a57ffb4a0552a8a5be7e743b1021b1ace4abbd27b86774cca067a1ff7c2530
MD5 39d8f5a32c883f997ddb3fe9d786ac89
BLAKE2b-256 369f3097acc1bea631c399c2b5cc46677c843805719ba36368cc43dae426fc5e

See more details on using hashes here.

File details

Details for the file shamrock-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: shamrock-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.6.13

File hashes

Hashes for shamrock-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a62f206b1f9d3a6c6db8eb1bf5f9495aae184c1cfce5d1c2ffdaf038f75ced40
MD5 9796bb856bb2f9522304feb5a42e67f5
BLAKE2b-256 fb2d769a93f9ed1303edef290eb1c93503867c9d2476fc49b934a63efaf8c5c4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page