Cocktail Recipe API - Ruby Gem
Cocktail is a simple tool for getting cocktail recipes. It returns the ingredients, instructions, and more of the cocktail.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_cocktail'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_cocktail
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_cocktail'
# Initialize the client
client = APIVerve::Cocktail::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({ name: "martini" })
# Print the response
puts response
Error Handling
begin
response = client.execute({ name: "martini" })
puts response["data"]
rescue APIVerve::Cocktail::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Cocktail::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Cocktail::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"count": 5,
"filteredOn": "name",
"cocktails": [
{
"name": "Espresso Martini",
"glass": "martini",
"category": "After Dinner Cocktail",
"ingredients": [
{
"unit": "cl",
"amount": 5,
"ingredient": "Vodka"
},
{
"unit": "cl",
"amount": 1,
"ingredient": "Coffee liqueur",
"label": "KahlĂșa"
},
{
"special": "Sugar syrup (according to individual preference of sweetness)"
},
{
"special": "1 short strong Espresso"
}
],
"ingredientCount": 4,
"estimatedStrength": "medium",
"preparation": "Shake and strain into a chilled cocktail glass."
},
{
"name": "Lemon Drop Martini",
"glass": "martini",
"category": "All Day Cocktail",
"ingredients": [
{
"unit": "cl",
"amount": 2.5,
"ingredient": "Vodka",
"label": "Citron Vodka"
},
{
"unit": "cl",
"amount": 2,
"ingredient": "Triple Sec"
},
{
"unit": "cl",
"amount": 1.5,
"ingredient": "Lemon juice"
}
],
"garnish": "Lemon slice",
"preparation": "Shake and strain into a chilled cocktail glass rimmed with sugar."
},
{
"name": "French Martini",
"glass": "martini",
"category": "Before Dinner Cocktail",
"ingredients": [
{
"unit": "cl",
"amount": 4.5,
"ingredient": "Vodka"
},
{
"unit": "cl",
"amount": 1.5,
"ingredient": "Raspberry liqueur"
},
{
"unit": "cl",
"amount": 1.5,
"ingredient": "Pineapple juice"
}
],
"preparation": "Stir in mixing glass with ice cubes. Strain into chilled cocktail glass. Squeeze oil from lemon peel onto the drink."
},
{
"name": "Dirty Martini",
"glass": "martini",
"category": "Before Dinner Cocktail",
"ingredients": [
{
"unit": "cl",
"amount": 6,
"ingredient": "Vodka"
},
{
"unit": "cl",
"amount": 1,
"ingredient": "Vermouth",
"label": "Dry vermouth"
},
{
"unit": "cl",
"amount": 1,
"ingredient": "Olive juice"
}
],
"garnish": "Green olive",
"preparation": "Stir in mixing glass with ice cubes. Strain into chilled martini glass."
},
{
"name": "Dry Martini",
"glass": "martini",
"category": "Before Dinner Cocktail",
"ingredients": [
{
"unit": "cl",
"amount": 6,
"ingredient": "Gin"
},
{
"unit": "cl",
"amount": 1,
"ingredient": "Vermouth",
"label": "Dry vermouth"
}
],
"preparation": "Stir in mixing glass with ice cubes. Strain into chilled martini glass. Squeeze oil from lemon peel onto the drink, or garnish with olive."
}
]
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/cocktail?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.