Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
151 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Configuration | ||
============= | ||
|
||
So far, only page size returned is configurable on the initial set-up. :: | ||
|
||
from shamrock import Shamrock | ||
api = Shamrock('my_secret_token', page_size=5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.. include:: ../../CONTRIBUTING.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.. include:: ../../HISTORY.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Introduction | ||
============ | ||
|
||
☘ **Shamrock** is a Python shallow API library for `Trefle <https://trefle.io/>`_ 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 more information what the Trefle service provides, refer to their documentation. It is also | ||
useful for checking out how to use the API with Shamrock library. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
shamrock | ||
======== | ||
Modules | ||
======= | ||
|
||
.. toctree:: | ||
:maxdepth: 4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Resources | ||
========= | ||
|
||
* `Trefle API <https://trefle.io/>`_ | ||
* `Shamrock repository <https://github.com/zmasek/shamrock/>`_ | ||
* `Shamrock PyPI <https://example.com/>`_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Setting up | ||
========== | ||
|
||
Prerequisites | ||
------------- | ||
|
||
Shamrock relies on Python 3.6 and above and `Requests III <https://3.python-requests.org/>`_ | ||
library. Requests will get installed automatically, but you need to make sure to meet the other | ||
requirement. | ||
|
||
To start interacting with the API, you'll need a token from them. Obtaining it is not a big deal. | ||
Make sure to sign up on the Trefle page and obtain token there. You'll need it when using the | ||
library. | ||
|
||
Installation | ||
------------ | ||
|
||
It is highly recommended to start using `pipenv <https://pipenv.readthedocs.io/en/latest/>`_ for | ||
managing your dependencies:: | ||
|
||
$ pipenv install shamrock | ||
|
||
but you can use pip also:: | ||
|
||
$ pip install shamrock | ||
|
||
Basic Usage | ||
----------- | ||
:: | ||
|
||
from shamrock import Shamrock | ||
api = Shamrock('my_secret_token') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
Usage | ||
===== | ||
|
||
Basic | ||
----- | ||
:: | ||
|
||
from shamrock import Shamrock | ||
api = Shamrock('my_secret_token') | ||
plants = api.plants() | ||
print(plants) | ||
|
||
Advanced | ||
-------- | ||
|
||
Setting Up | ||
~~~~~~~~~~ | ||
:: | ||
|
||
from shamrock import Shamrock | ||
api = Shamrock('my_secret_token') | ||
|
||
or with a configuration:: | ||
|
||
from shamrock import Shamrock | ||
api = Shamrock('my_secret_token', page_size=5) | ||
|
||
Methods | ||
~~~~~~~ | ||
|
||
Methods that can be run with the API are:: | ||
|
||
api.kingdoms() | ||
api.subkingdoms() | ||
api.divisions() | ||
api.families() | ||
api.genuses() | ||
api.plants() | ||
api.species() | ||
|
||
They correspond to the Trefle API endpoints. | ||
|
||
Single item | ||
~~~~~~~~~~~ | ||
|
||
You can also query a specific item from the database:: | ||
|
||
api.plants(103505) | ||
|
||
Search | ||
~~~~~~ | ||
|
||
Searching is covered with a separate method:: | ||
|
||
api.search("tomato") | ||
|
||
Navigation | ||
~~~~~~~~~~ | ||
|
||
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() | ||
|
||
Specific Options | ||
~~~~~~~~~~~~~~~~ | ||
|
||
By default, the API responds with the list of whatever number is set in the Trefle. You can | ||
manipulate it with previously mentioned page_size:: | ||
|
||
api.species(page_size=5) | ||
|
||
You can also use the varoius query string options described on Trefle API documentation as keyword | ||
arguments in methods:: | ||
|
||
api.species(common_name="blackwood") |