Skip to main content

License: MIT | PyPi Package | PyPi Versions

Build Status | Test Coverage | Code Climate

Python Cannabis Reports

This library allows you to interact with the Cannabis Reports API using Python.

Installation

Installation is easiest using Pip and PyPi:

pip install cannabis-reports

If you would like to contribute, or prefer Git:

git clone https://github.com/LasLabs/python-cannabis-reports.git
cd python-cannabis-reports
pip install .

Usage

The CannabisReports object is the primary point of interaction with the CannabisReports API.

Connection

Connecting to the CannabisReports API will require an API Key, which is generated from within your CannabisReports account. In the below example, our key is API_KEY.

from cannabis-reports import CannabisReports
cr = CannabisReports('API_KEY')

API Endpoints

The CannabisReports API endpoints are exposed as variables on the instantiated CannabisReports object. The available endpoints are:

They can also be viewed from the __apis__ property of CannabisReports:

>>> cr.__apis__
{'Strains': <CannabisReports.auth_proxy.AuthProxy object at 0x10783ddd0>,
 }

API usage is as simple as calling the method with the required parameters and iterating the results:

for strain in cr.Strains.list():
    print(strain)
    print(strain.serialize())
    break

The output from the above would look something like the below:

# This is the Strain object itself (first print)
<cannabis-reports.models.strain.Strain object at 0x10783df10>
# This is the serialized form of the Strain (second print)
{'name': '#1K',
 'updated_at': {
     'datetime': '2015-06-16 22:10:20',
     'timezone': 'UTC'
 },
 'lineage': [],
 'qr': 'https://www.cannabisreports.com/strain-reports/unknown-breeder/1k/qr-code.svg',
 'seed_company': {
     '__class__': 'SeedCompany',
     'ucpc': '9XVU700000000000000000000',
     'link': 'https://www.cannabisreports.com/api/v1.0/seed-companies/9XVU700000000000000000000'
 },
 'genetics': {'__class__': 'StrainGenetics'},
 'created_at': {'datetime': '2015-06-16 22:10:20', 'timezone': 'UTC'},
 'reviews': {
     '__class__': 'GeneralOverview',
     'link': 'https://www.cannabisreports.com/api/v1.0/strains/9XVU7PZUEC000000000000000/reviews'
 },
 'image': 'https://www.cannabisreports.com/images/strains/no_image.png',
 'ucpc': '9XVU7PZUEC000000000000000',
 '__class__': 'Strain',
 'url': 'https://www.cannabisreports.com/strain-reports/unknown-breeder/1k',
 'children': {
     '__class__': 'GeneralOverview',
     'count': 2,
     'link': 'https://www.cannabisreports.com/api/v1.0/strains/9XVU7PZUEC000000000000000/children'
 },
 'link': 'https://www.cannabisreports.com/api/v1.0/strains/9XVU7PZUEC000000000000000'
}

In some instances, such as in the case of browsing for a record by its UCPC, a singleton is expected. In these instances, the singleton is directly used instead of iterated

>>> strain = cr.Strains.get('9XVU7PZUEC000000000000000')
>>> strain
<cannabis-reports.models.strain.Strain object at 0x101723e50>
>>> strain.serialize()
{'name': '#1K',
 'updated_at': {
     'datetime': '2015-06-16 22:10:20',
     'timezone': 'UTC'
 },
 'lineage': [],
 'qr': 'https://www.cannabisreports.com/strain-reports/unknown-breeder/1k/qr-code.svg',
 'seed_company': {
     '__class__': 'SeedCompany',
     'ucpc': '9XVU700000000000000000000',
     'link': 'https://www.cannabisreports.com/api/v1.0/seed-companies/9XVU700000000000000000000'
 },
 'genetics': {'__class__': 'StrainGenetics'},
 'created_at': {'datetime': '2015-06-16 22:10:20', 'timezone': 'UTC'},
 'reviews': {
     '__class__': 'GeneralOverview',
     'link': 'https://www.cannabisreports.com/api/v1.0/strains/9XVU7PZUEC000000000000000/reviews'
 },
 'image': 'https://www.cannabisreports.com/images/strains/no_image.png',
 'ucpc': '9XVU7PZUEC000000000000000',
 '__class__': 'Strain',
 'url': 'https://www.cannabisreports.com/strain-reports/unknown-breeder/1k',
 'children': {
     '__class__': 'GeneralOverview',
     'count': 2,
     'link': 'https://www.cannabisreports.com/api/v1.0/strains/9XVU7PZUEC000000000000000/children'
 },
 'link': 'https://www.cannabisreports.com/api/v1.0/strains/9XVU7PZUEC000000000000000'
}

Note that all of the API responses will be parsed, with proper objects being created from the results. The objects are all defined in the cannabis-reports.models package.

Known Issues / Road Map

  • This ReadMe could use work

  • More testing on the endpoints. Kept getting rate limited and have not yet received and API key.

Credits

Most of the doc strings were taken directly from the Cannabis Reports API Documentation

Contributors

Maintainer

LasLabs Inc.

This module is maintained by LasLabs Inc.

Release files for cannabis-reports 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cannabis-reports 0.1.1
File Size Uploaded
cannabis-reports-0.1.1.tar.gz 138.7 kB Details

Release files / cannabis-reports-0.1.1.tar.gz

Download URL cannabis-reports-0.1.1.tar.gz
Size 138.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d15d1506f93b129ad5dcc591d8297ffd5a642226019aaca804385f1072ddf595
BLAKE2b-256 checksum
How to use checksums
ea225366d6851532d2911437b3174469242944747150623d5e260484671950a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page