Skip to content

Cannlytics API

The Cannlytics API allows users to interface with cannabis data and statistics. Each API endpoints handle authentication, error handling, and identifying the precise logic to perform.

Getting Started with the Cannlytics API

Getting started making requests to the Cannlytics API can be done in 3 quick steps.

  1. First, create a Cannlytics account.
  2. Second, create a Cannlytics API key.
  3. Third, begin making requests to the Cannlytics API with your API Key in an Authorization: Bearer <cannlytics_api_key> header.

You can make requests through the API passing your API key as a bearer token in the authorization header. Below is an example reading an API key from a local .env file.

from dotenv import load_dotenv
import os
import requests

# Load your API key.
load_dotenv('.env')
API_KEY = os.getenv('CANNLYTICS_API_KEY')

# Pass your API key through the authorization header as a bearer token.
HEADERS = {
    'Authorization': 'Bearer %s' % API_KEY,
    'Content-type': 'application/json',
}

# Parse a COA through the API.
url = 'https://cannlytics.page.link/test-coa'
data = {'urls': [url]}
response = requests.post(url, headers=headers, json=data)
extracted = response.json()
print(extracted["data"])
const axios = require('axios');
require('dotenv').config();

// Pass API key through the authorization header as a bearer token.
const apiKey = process.env.CANNLYTICS_API_KEY;
const options = {
  headers: {
    'Content-Type': 'application/json',
    'Authorization' : `Bearer ${apiKey}`
  }
};

// Parse a COA through the API.
const url = 'https://cannlytics.page.link/test-coa';
const data = { urls: [url] };

axios.post(url, data, options)
  .then((response) => {
    const extracted = response.data;
    console.log(extracted["data"]);
  })
  .catch((error) => {
    console.error("Error:", error);
  });