Skip to main content

A simple wrapper for the trefle botanical RESTAPI

Project description

Trefle-Api

Trefle-API is a simple python API wrapper for the trefle botanic data API

>>> from trefle_api import TrefleAPI
>>> Client = TrefleAPI(token="trefle_api_token")
>>> Query = Client.search("rose").in_("plants").filter(family="Rosaceae").sort_by(slug="asc")
>>> Query.get_json()
"{'data': [{'id': 265580, 'common_name': 'Field rose', 'slug': 'rosa-arvensis', 'scientific_name': 'Rosa arvensis'..."
>>> New_Query = Query.range(year=[2000, 2010]).exclude(common_name="null")
>>> New_Query.get_models()
"[[Plant(id=345576, name='', slug='physaria-purpurea', common_name='Rose bladderpod', scientific_name='Physaria purpurea', year=2002,..."

This package allows you to build simple to more complex queries to fetch data from the the trefle RESTAPI
Query tags :

  • search()
    description : search a query
    args : q # the string to use as query returns : a copy of the Query class to allow chaining

  • retrieve()
    description : retrieve an item based on it's slug or id
    args : slug or id # a string representing the slug of a vegetable or it's id in the trefle api records
    returns : a copy of the Query class to allow chaining

  • in_()
    description : select a category in which to search or retrieve
    args category # available categories are :

    • kingdoms
    • subkingdoms
    • divisions
    • divisionclasses
    • division_orders
    • families
    • genus
    • plants
    • species

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

trefleapi-0.1.0.tar.gz (15.4 kB view hashes)

Uploaded Source

Built Distribution

trefleapi-0.1.0-py3-none-any.whl (13.2 kB view hashes)

Uploaded Python 3

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