0.5.1 • Published 3 years ago

strainsapi.js v0.5.1

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

An API Wrapper for StrainsAPI written in TypeScript

Features

  • Strain lookup and filtering
  • Recipe lookup and filtering
  • Configurable cacheing
  • Fluent and beautiful error messages

Installation

Install with npm

npm install strainsapi.js

Usage/Examples

import StrainsClient from "strainsapi.js";
// or
const StrainsClient = require("strainsapi.js");

// Config for the cache
const cacheConfig: Partial<ICachingOptions> = { ttl: 1000 * 60 * 60 * 3 }; // 3 hour cache

// initialize the client
const client = new StrainsClient("Your api token", cacheConfig);

// Search for strains
async function strainSearches() {
	// You can combine as many fields as you want
	const bestIndicas: Strain[] = await client.strains.filter({
		race: "indica",
		rating: 5.0,
	});
	const worstSativas: Strain[] = await client.strains.filter({
		race: "sativa",
		rating: 0.0,
	});
	const midHybrids: Strain[] = await client.strains.filter({
		race: "hybrid",
		rating: 2.5,
	});
	const keywordStrain: Strain[] = await client.strains.filter({
		description: "gorilla glue",
	});
	const namedStrain: Strain[] = await client.strains.filter({ name: "Wedding Cake" });
}

// Search for recipes
async function recipeSearches() {
	const recipes: Recipe[] = await client.recipes.byName("recipe name");
}

async function main() {
	await strainSearches();

	await recipeSearches();
}

main();

Support

For support, join the Offical Discord Server for Cannabot and StrainsAPI