# Quick Start Guide - Public APIs for General Bots ๐Ÿš€ Get started with 70+ free API keywords in under 5 minutes! ## ๐Ÿ“ฆ Installation 1. Copy the entire `public-apis.gbai` folder to your General Bots templates directory: ``` /templates/public-apis.gbai/ ``` 2. Restart your General Bots instance or reload templates 3. Done! All keywords are now available ๐ŸŽ‰ ## ๐ŸŽฏ Your First API Call ### Example 1: Get a Random Cat Image ```vbs DESCRIPTION "Show me a random cat picture" cat_url = "https://cataas.com/cat" file = DOWNLOAD cat_url SEND FILE file RETURN cat_url ``` **Test it:** - User: "Show me a cat" - Bot: *sends random cat image* ### Example 2: Weather Check ```vbs TALK "What's your location? (format: lat,lon)" HEAR location AS string coordinates = SPLIT(location, ",") lat = coordinates[0] lon = coordinates[1] weather_url = "https://api.open-meteo.com/v1/forecast?latitude=" + lat + "&longitude=" + lon + "¤t_weather=true" weather = GET weather_url current = weather.current_weather TALK "๐ŸŒก๏ธ Temperature: " + current.temperature + "ยฐC" TALK "๐Ÿ’จ Wind Speed: " + current.windspeed + " km/h" ``` ### Example 3: Random Joke ```vbs DESCRIPTION "Tell me a joke" SET HEADER "Accept" = "application/json" joke = GET "https://icanhazdadjoke.com/" TALK "๐Ÿ˜„ " + joke.joke RETURN joke.joke ``` ## ๐Ÿ”ฅ Most Popular Keywords ### Animals ๐Ÿพ ```vbs REM Random dog image dog_data = GET "https://random.dog/woof.json" file = DOWNLOAD dog_data.url SEND FILE file REM Cat fact cat_fact = GET "https://catfact.ninja/fact" TALK cat_fact.fact REM Random fox fox = GET "https://randomfox.ca/floof/" file = DOWNLOAD fox.image SEND FILE file ``` ### Entertainment ๐Ÿ˜„ ```vbs REM Chuck Norris joke joke = GET "https://api.chucknorris.io/jokes/random" TALK joke.value REM Random advice advice = GET "https://api.adviceslip.com/advice" TALK advice.slip.advice REM Kanye quote kanye = GET "https://api.kanye.rest/" TALK kanye.quote ``` ### Food & Drink ๐Ÿฝ๏ธ ```vbs REM Random meal recipe meal = GET "https://www.themealdb.com/api/json/v1/1/random.php" recipe = meal.meals[0] TALK recipe.strMeal TALK recipe.strInstructions REM Random cocktail cocktail = GET "https://www.thecocktaildb.com/api/json/v1/1/random.php" drink = cocktail.drinks[0] TALK drink.strDrink TALK drink.strInstructions ``` ### Utilities ๐Ÿ”ง ```vbs REM Generate UUID uuid = GET "https://www.uuidgenerator.net/api/version4" TALK "๐Ÿ”‘ " + uuid REM Get my IP ip = GET "https://api.ipify.org?format=json" TALK "๐ŸŒ Your IP: " + ip.ip REM Generate QR Code qr_url = "https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=Hello" file = DOWNLOAD qr_url SEND FILE file ``` ## ๐ŸŽจ Building Your First Bot ### Interactive Recipe Bot ```vbs TALK "Welcome to Recipe Bot! ๐Ÿณ" TALK "What are you hungry for?" HEAR choice AS "Meal", "Cocktail", "Dessert" IF choice = "Meal" THEN meal = GET "https://www.themealdb.com/api/json/v1/1/random.php" recipe = meal.meals[0] TALK "๐Ÿฝ๏ธ How about: " + recipe.strMeal TALK "" TALK "Category: " + recipe.strCategory TALK "Origin: " + recipe.strArea TALK "" TALK "๐Ÿ“ Instructions:" TALK recipe.strInstructions file = DOWNLOAD recipe.strMealThumb SEND FILE file ELSE IF choice = "Cocktail" THEN cocktail = GET "https://www.thecocktaildb.com/api/json/v1/1/random.php" drink = cocktail.drinks[0] TALK "๐Ÿน Try this: " + drink.strDrink TALK "" TALK "Glass: " + drink.strGlass TALK "" TALK "๐Ÿธ Instructions:" TALK drink.strInstructions file = DOWNLOAD drink.strDrinkThumb SEND FILE file END IF TALK "" TALK "Enjoy your meal! ๐Ÿ˜‹" ``` ### Daily Motivation Bot ```vbs TALK "๐ŸŒ… Good morning! Here's your daily motivation:" TALK "" REM Get inspirational quote quote = GET "https://api.quotable.io/random" TALK "โœจ Quote:" TALK '"' + quote.content + '"' TALK "โ€” " + quote.author TALK "" REM Get affirmation affirmation = GET "https://www.affirmations.dev/" TALK "๐Ÿ’– Affirmation:" TALK affirmation.affirmation TALK "" REM Get activity suggestion activity = GET "https://www.boredapi.com/api/activity" TALK "๐Ÿ’ก Activity Suggestion:" TALK activity.activity TALK "" TALK "Have a great day! ๐ŸŒŸ" ``` ### Pet Picture Gallery Bot ```vbs TALK "๐Ÿพ Welcome to Pet Picture Gallery!" TALK "Which animal would you like to see?" HEAR animal AS "Cat", "Dog", "Fox", "Duck", "Bear" TALK "Getting a random " + animal + " for you..." IF animal = "Cat" THEN url = "https://cataas.com/cat" ELSE IF animal = "Dog" THEN data = GET "https://random.dog/woof.json" url = data.url ELSE IF animal = "Fox" THEN data = GET "https://randomfox.ca/floof/" url = data.image ELSE IF animal = "Duck" THEN data = GET "https://random-d.uk/api/random" url = data.url ELSE IF animal = "Bear" THEN url = "https://placebear.com/400/300" END IF file = DOWNLOAD url SEND FILE file TALK "Isn't it adorable? ๐Ÿ˜" TALK "" TALK "Want another one?" HEAR again AS BOOLEAN IF again THEN TALK "Coming right up! ๐ŸŽ‰" REM Repeat the process END IF ``` ## ๐Ÿงช Testing Your Keywords ### Method 1: Direct Testing ```vbs REM Create a test dialog file: test.gbdialog/test-apis.vbs TALK "Testing Weather API..." weather = GET "https://api.open-meteo.com/v1/forecast?latitude=52.52&longitude=13.41¤t_weather=true" TALK "โœ… Weather API works!" TALK "Testing Joke API..." joke = GET "https://api.chucknorris.io/jokes/random" TALK "โœ… Joke API works!" TALK "All tests passed! ๐ŸŽ‰" ``` ### Method 2: Interactive Testing Talk to your bot: - "Tell me a joke" - "Show me a cat picture" - "What's the weather?" - "Give me a recipe" ## ๐Ÿ’ก Pro Tips ### 1. Error Handling Always check if data exists: ```vbs data = GET "https://api.example.com/endpoint" IF data THEN TALK "Success!" TALK data.result ELSE TALK "โŒ Could not fetch data" END IF ``` ### 2. Rate Limiting Add delays between multiple API calls: ```vbs TALK "Fetching data..." data1 = GET "https://api1.example.com" WAIT 1 data2 = GET "https://api2.example.com" ``` ### 3. Image Downloads Always download before sending: ```vbs image_url = "https://example.com/image.jpg" file = DOWNLOAD image_url SEND FILE file ``` ### 4. Header Setting Some APIs need specific headers: ```vbs SET HEADER "Accept" = "application/json" SET HEADER "User-Agent" = "GeneralBots/1.0" data = GET "https://api.example.com" ``` ## ๐Ÿ“š Learning Path ### Beginner (Day 1) - โœ… Try 5 simple keywords (cat image, joke, quote) - โœ… Understand GET requests - โœ… Learn TALK and SEND FILE ### Intermediate (Day 2-3) - โœ… Build interactive bot with HEAR - โœ… Combine multiple APIs - โœ… Add error handling ### Advanced (Day 4-7) - โœ… Create multi-step conversations - โœ… Parse complex JSON responses - โœ… Build production-ready bots ## ๐Ÿ†˜ Troubleshooting ### Problem: API returns error **Solution:** Check if API is online: ```vbs REM Add debug output data = GET "https://api.example.com" TALK "Raw response: " + data ``` ### Problem: Image not showing **Solution:** Verify URL and download: ```vbs TALK "Image URL: " + image_url file = DOWNLOAD image_url IF file THEN SEND FILE file ELSE TALK "โŒ Could not download image" END IF ``` ### Problem: JSON parsing error **Solution:** Check if field exists: ```vbs data = GET "https://api.example.com" IF data.field THEN TALK data.field ELSE TALK "Field not found" END IF ``` ## ๐ŸŽ“ Next Steps 1. **Explore all categories**: Check `README.md` for full keyword list 2. **Combine APIs**: Mix weather + location + activities 3. **Build workflows**: Create multi-step conversations 4. **Share your bots**: Contribute back to community ## ๐Ÿ”— Useful Resources - [Full Documentation](README.md) - Complete API reference - [Keywords Checklist](KEYWORDS_CHECKLIST.md) - Implementation status - [Public APIs List](https://github.com/public-apis/public-apis) - Find more APIs - [General Bots Docs](https://github.com/GeneralBots/BotServer) - Platform documentation ## ๐Ÿค Community - Found a bug? Open an issue - Have a suggestion? Submit a PR - Need help? Ask in discussions ## โšก Quick Reference Card ```vbs REM Basic API Call data = GET "https://api.example.com/endpoint" REM With Parameters data = GET "https://api.example.com?param=" + value REM Download Image file = DOWNLOAD url SEND FILE file REM Error Handling IF data THEN TALK data.result ELSE TALK "Error" END IF REM Set Headers SET HEADER "Accept" = "application/json" REM User Input HEAR variable AS TYPE HEAR name AS NAME HEAR choice AS "Option1", "Option2" REM Loops FOR EACH item IN array TALK item END FOR ``` --- **Ready to build amazing bots?** Start with a simple keyword and grow from there! ๐Ÿš€ **Need help?** Check the examples in this guide or refer to the full README.md **Have fun coding!** ๐ŸŽ‰