NAV Navbar
Bash JavaScript PHP JSON
  • Introduction
  • Authentication
  • Strains
  • Products
  • Shops
  • Filters
  • Errors
  • Introduction

    Welcome to the Kushy API! You can use our API to access Kushy API endpoints, which can get information on various cannabis strains, products, shops, and brands in our database.

    We have language bindings in Javascript and PHP! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right. Find example apps and more on our Github.

    Authentication

    To authorize, use this code:

      curl "http://kushy.net/api/v3/strains/"
    
    <?php
    $api = 'http://kushy.net/api/v3/strains/';
    $curl = curl_init();
    
    curl_setopt_array($curl, array(
      CURLOPT_URL => $api,
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "cache-control: no-cache"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    $response = json_decode($response, true);
    print_r($response);
    ?>
    
    var api = 'http://kushy.net/api/v3/strains/';
    var xmlhttp;
    xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
          strains = JSON.parse(this.responseText);
          console.log(strains);
        }
    }
    xmlhttp.open("GET", api, true);
    xmlhttp.send();
    

    Kushy allows for GET requests from any public request, just request your data and go!

    As a verified developer you'll gain access to API keys to allow POST, PUT, and DELETE requests. We are currently not accepting new applications for API keys, please check back soon!

    Strains

    Get All Strains

      curl "http://kushy.net/api/v3/strains/"
    
    var api = 'http://kushy.net/api/v3/strains/';
    var xmlhttp;
    xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
          strains = JSON.parse(this.responseText);
          console.log(strains);
        }
    }
    xmlhttp.open("GET", api, true);
    xmlhttp.send();
    
    <?php
    $api = 'http://api.kushy.net/api/v3/strains/';
    $curl = curl_init();
    
    curl_setopt_array($curl, array(
      CURLOPT_URL => $api,
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "cache-control: no-cache"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    $response = json_decode($response, true);
    echo 'Strain Name'. $response['data'][0]['name'];
    ?>
    

    The above command returns JSON structured like this:

    [
      meta: {
        table: "strains",
        type: "collection",
        total: 20,
        total_entries: 0
      },
      data: [
        {
          id: 1,
          status: 1,
          sort: 0,
          name: "100 OG",
          slug: null,
          image: "http://fadedfools.com/medical_marijuana/100dollar_og_kush.jpg",
          description: "<p>This strain is named after it's high price in it's Hollywood home. As a 50/50 hybrid of indica and sativa, $100 OG does a great job offering pain relief with an alert, cerebral high.</p>",
          type: "Hybrid",
          crosses: "",
          breeder: "Old School Breeder's Association",
          effects: "Focused",
          ailment: "Depression",
          flavor: "Citrus",
          location: null,
          terpenes: "Limonene",
          thc: 127,
          thca: 0,
          thcv: 0,
          cbd: 16,
          cbda: 0,
          cbdv: 0,
          cbn: 10,
          cbg: 0,
          cbgm: 0,
          cbgv: 0,
          cbc: 0,
          cbcv: 0,
          cbv: 0,
          cbe: 0,
          cbt: 0,
          cbl: 0
        }]
      }
    ]
    

    This endpoint retrieves all strains.

    HTTP Request

    GET http://kushy.net/api/v3/strains/?<FILTER><LIMIT>

    Query Parameters

    Parameter Default Description
    filters null Set filter parameters (see filter section for more info)
    limit 20 Sets the number of items retrieved. Max is 20.

    Get a Specific Strain

      curl "http://kushy.net/api/v3/strains/:id"
    

    This endpoint retrieves a specific strain.

    HTTP Request

    GET http://kushy.net/api/v3/strains/<ID>

    URL Parameters

    Parameter Description
    ID The ID of the strain to retrieve

    Delete a Specific Strain

    curl "http://kushy.net/api/v3/strains/420"
      -X DELETE
      -H "Authorization: API_KEY"
    

    This endpoint deletes a specific strain.

    HTTP Request

    DELETE http://kushy.net/api/v3/strains/<ID>

    URL Parameters

    Parameter Description
    ID The ID of the strain to delete

    Products

    Get All Products

      curl "http://kushy.net/api/v3/products/"
    
    var api = 'http://kushy.net/api/v3/products/';
    var xmlhttp;
    xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
          products = JSON.parse(this.responseText);
          console.log(products);
        }
    }
    xmlhttp.open("GET", api, true);
    xmlhttp.send();
    
    <?php
    $api = 'http://api.kushy.net/api/1.1/tables/products/';
    $curl = curl_init();
    
    curl_setopt_array($curl, array(
      CURLOPT_URL => $api,
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "cache-control: no-cache"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    $response = json_decode($response, true);
    echo 'Product Name'. $response['data'][0]['name'];
    ?>
    

    The above command returns JSON structured like this:

    {
        meta: {
        table: "products",
        type: "collection",
        total: 20,
        total_entries: 0
    },
    data: [
        {
        id: 1,
        name: "Pre-Roll Package - Pre-roll",
        slug: "the-humboldt-cure-pre-roll-package-pre-roll",
        brand: "The Humboldt Cure",
        category: "Flowers,Pre-Roll",
        strain: 10,
        thc: 1889,
        cbd: 10,
        lab_test: 53
        },
    

    This endpoint retrieves all products.

    HTTP Request

    GET http://kushy.net/api/v3/products/

    Query Parameters

    Parameter Default Description
    filters null Set filter parameters (see filter section for more info)
    limit 20 Sets the number of items retrieved. Max is 20.

    Get a Specific Product

      curl "http://kushy.net/api/v3/products/:id"
    

    This endpoint retrieves a specific product.

    HTTP Request

    GET http://kushy.net/api/v3/products/<ID>

    URL Parameters

    Parameter Description
    ID The ID of the product to retrieve

    Delete a Specific Product

    curl "http://kushy.net/api/v3/products/420"
      -X DELETE
      -H "Authorization: API_KEY"
    

    This endpoint deletes a specific product.

    HTTP Request

    DELETE http://kushy.net/api/v3/products/<ID>

    URL Parameters

    Parameter Description
    ID The ID of the product to delete

    Shops

    Get All Shops

      curl "http://kushy.net/api/v3/shops/"
    
    var api = 'http://kushy.net/api/v3/shops/';
    var xmlhttp;
    xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
          shops = JSON.parse(this.responseText);
          console.log(shops);
        }
    }
    xmlhttp.open("GET", api, true);
    xmlhttp.send();
    
    <?php
    $api = 'http://api.kushy.net/api/1.1/tables/shops/';
    $curl = curl_init();
    
    curl_setopt_array($curl, array(
      CURLOPT_URL => $api,
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "cache-control: no-cache"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    $response = json_decode($response, true);
    echo 'Shop Name'. $response['data'][0]['name'];
    ?>
    

    The above command returns JSON structured like this:

    [
      meta: {
        table: "shops",
        type: "collection",
        total: 20
      },
      data: [
        {
            id: 911,
            status: 2,
            sort: 0,
            name: "ShowGrow Ramona",
            slug: "showgrow-ramona/",
            featured_image: "http://kushy.net/wp-content/uploads/2016/12/square_logo.jpg",
            avatar: "http://kushy.net/wp-content/uploads/2016/12/square_logo.jpg",
            images: null,
            gallery: null,
            description: "",
            lat: 33.043339,
            lng: -116.905479,
            address: "",
            city: "Ramona",
            state: "CA",
            postcode: "92065",
            country: "US",
            hours: "",
            coupons: null,
            deals: null,
            rating: null,
            tags: null,
            twitter: "",
            facebook: "",
            instagram: "",
            tumblr: "",
            googleplus: "",
            type: "Medical Marijuana Dispensary",
        }]
      }
    ]
    

    This endpoint retrieves all shops.

    HTTP Request

    GET http://kushy.net/api/v3/shops/?<FILTER><LIMIT>

    Query Parameters

    Parameter Default Description
    filters null Set filter parameters (see filter section for more info)
    region null Set region parameters (see region section below)
    limit 20 Sets the number of items retrieved. Max is 20.

    Get a Specific Shop

      curl "http://kushy.net/api/v3/shops/:id"
    

    This endpoint retrieves a specific shop.

    HTTP Request

    GET http://kushy.net/api/v3/shops/<ID>

    URL Parameters

    Parameter Description
    ID The ID of the shop to retrieve

    Delete a Specific Shop

    curl "http://kushy.net/api/v3/shops/420"
      -X DELETE
      -H "Authorization: API_KEY"
    

    This endpoint deletes a specific shop.

    HTTP Request

    DELETE http://kushy.net/api/v3/shops/<ID>

    URL Parameters

    Parameter Description
    ID The ID of the shop to delete

    Get Shops by Region

      curl "http://kushy.net/api/v3/shops/<Region>"
    

    This endpoint retrieves shops within a circular region of the coordinates provided (using the Haversine formula).

    HTTP Request

    GET http://kushy.net/api/v3/shops/?region[geo][lat]=33.719657&region[geo][lng]=-117.852899&region[geo][radius]=20

    URL Parameters

    Parameter Description
    Region Query string object with geo info (lat, lng, and radius)

    In object form:

    region: { geo: { lat: 33, lng: -117, radius: 20 } }

    Filters

    Filters are a way to refine listing results based on one or more conditions.

    How to use

    To add a filter you have to use the query param key filters with the following format: filters[column-name][operator]=value

    Example: Fetching shops from California

    kushy.net/api/v3/shops/?filters[location_state][like]=ca

    filters[location_state][eq]=us filters the customers to only those with location_state equal to ca.

    Also filters[location_state][eq]=ca can be simplified to filters[location_state]=ca

    To add another filter you have to separate each filters with the ampersand symbol (&).

    Example: Fetching shops from Los Angeles, California

    kushy.net/api/v3/shops/?filters[location_city][like]=los%20angeles

    Supported Operators

    Operator Description
    =, eq Equal to
    <>, !=, neq Not Equal to
    <, lt Less than
    <=, lte Less than or equal to
    >, gt Greater than
    >=, gte Greater than or equal to
    contains Contains a string
    ncontains Not Contains a string
    between Is Between
    nbetween Is Not Between
    empty Is Empty
    nempty Is Not Empty

    Errors

    The Kushy API uses the following error codes:

    Error Code Meaning
    400 Bad Request -- Your request sucks.
    401 Unauthorized -- Your API key is wrong.
    403 Forbidden -- The cannabis requested is hidden for administrators only.
    404 Not Found -- The specified cannabis could not be found.
    405 Method Not Allowed -- You tried to access a cannabis with an invalid method.
    406 Not Acceptable -- You requested a format that isn't json.
    410 Gone -- The cannabis requested has been removed from our servers.
    420 Smoke weed everyday.
    429 Too Many Requests -- You're requesting too many weeds! Slow down!
    500 Internal Server Error -- We had a problem with our server. Try again later.
    503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.