The Cannabis API is a RESTful API that provides comprehensive information about various cannabis strains. It allows you to query and retrieve details such as strain name, type (indica, sativa, or hybrid), rating, effects, flavours, and descriptions. The API is built using Node.js, Express, and MongoDB, and it is hosted on Heroku. The dataset used to populate the API is sourced from Kaggle, specifically the "cannabis.csv" file.
The API is hosted on Vercel at: https://the-cannabis-ayix5e7fr-piyush-bhors-projects.vercel.app.
To run the Cannabis API locally, follow these steps:
git clone https://github.com/Piyush-Bhor/The_Cannabis_API.git
cd The_Cannabis_API
-
Sign Up: Go to MongoDB Atlas and create a free account.
-
Create a Cluster: Click "Build a Cluster" (free tier), choose a cloud provider and region.
-
Create a Database User: Go to Database Access, click Add New Database User, and set username, password, and "Read and Write" privileges.
-
Get Connection String: Copy the connection string and replace and .
-
Add Environemnt Variables: Add the connection string to
.env
.CONNECTIONSTRING=<connection_string>
-
Create Database: In Atlas, create a test cluster and a strain database.
-
Insert Data: Go to Collections in your cluster, click Insert Document, and paste the contents of cannabis.json.
npm start
The Cannabis API is now running locally on http://localhost:3000
.
The following API endpoints are available:
GET /
: Shows a README with all the API endpoints.GET /api/strains/getStrainsById/:strainID
: Retrieves a specific strain by its ID.GET /api/strains/getStrainsByName/:strainName
: Retrieves strains by name.GET /api/strains/getStrainsByType/:strainType
: Retrieves strains by type.GET /api/strains/getStrainsByEffect/:strainEffect
: Retrieves strains by effect.GET /api/strains/getStrainsByFlavour/:strainFlavour
: Retrieves strains by flavor.GET /api/strains/getEffectsByStrainId/:strainID
: Retrieves effects by strain ID.GET /api/strains/getFlavoursByStrainId/:strainID
: Retrieves flavours by strain ID.GET /api/strains/getAllFlavours
: Retrieves all flavours.GET /api/strains/getAllEffects
: Retrieves all effects.
The Cannabis API is deployed on Vercel and can be accessed at: https://the-cannabis-ayix5e7fr-piyush-bhors-projects.vercel.app.
To Deploy your own instance of The Cannabis API, do these additional steps:
-
Create a free account on Vercel.
-
Install Vercel -
npm install -g vercel
-
Add the connection string to Vercel.
In the terminal run
vercel env pull
. This will create a.env.local
file that will have your connection string. Vercel will automatically add it to your.gitignore
. -
Run
npm run deploy
Contributions to the Cannabis API project are welcome! If you find any bugs, have suggestions for improvements, or would like to add new features, please submit an issue or open a pull request.
The Cannabis API is released under the MIT License. Please see the LICENSE file for more details.
The dataset used in this project is sourced from Kaggle: cannabis.csv. The "cannabis.csv" file contains the strain data used to populate the API.
For any questions or inquiries, please reach out to project maintainer Piyush Bhor:
- Email: [email protected]
- GitHub: Piyush-Bhor