A Crystal API wrapper for AdviceSlip.
"My life was changed after this got released"
- Get a random advice
- Get advice by ID
- Returns JSON parsed as key-value hashes
Clone the repository and require the SDK in your project:
require "path/to/advice"
client = Advice.new
advice = client.advice.by_id(13)
puts advice #{"slip" => {"id" => 13, "advice" => "If you're feeling tired or anxious, a pint of water will almost always make you feel better."}}
# again parsed to key value hashes!!
require "path/to/advice"
client = Advice.new
advice = client.advice.by_id(13)
puts advice #{"slip" => {"id" => 13, "advice" => "If you're feeling tired or anxious, a pint of water will almost always make you feel better."}}
# again parsed to key value hashes!!
require "path/to/advice"
client = Advice.new
query = client.advice.search("coffee")
puts advice #{"total_results": "1", "query": "coffee", "slips": [{"id":219,"advice":"Try buying a coffee for the creator of a free public API, now and then.","date":"2021-08-16"}]}
So simple!
- Maybe better error handling
- transform to a shard