strainsapi.js
TypeScript icon, indicating that this package has built-in type declarations

0.5.1 • Public • Published

StrainsAPI.js

Discord

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

Readme

Keywords

none

Package Sidebar

Install

npm i strainsapi.js

Weekly Downloads

1

Version

0.5.1

License

none

Unpacked Size

49.8 kB

Total Files

30

Last publish

Collaborators

  • makeshiftartist