Spaces:
Configuration error
Configuration error
Download scripts/free_apis_tool.py from D3AMON/hermes-agent: direct link, hf CLI and curl.
- Browser
- Download file 2.83 kB
-
https://huggingface.co/spaces/D3AMON/hermes-agent/resolve/main/scripts/free_apis_tool.py
- Command line
-
hf download hf://spaces/D3AMON/hermes-agent/scripts/free_apis_tool.py
-
curl -L -o free_apis_tool.py https://huggingface.co/spaces/D3AMON/hermes-agent/resolve/main/scripts/free_apis_tool.py
2.83 kB
| import requests | |
| # A collection of 30+ free, no-key-required APIs | |
| FREE_APIS = { | |
| "weather": "https://api.open-meteo.com/v1/forecast?latitude=52.52&longitude=13.41¤t_weather=true", | |
| "cat_fact": "https://catfact.ninja/fact", | |
| "dog_fact": "https://dog-api.kinduff.com/api/facts", | |
| "joke": "https://official-joke-api.appspot.com/random_joke", | |
| "ip_info": "https://ipapi.co/json/", | |
| "bitcoin_price": "https://api.coindesk.com/v1/bpi/currentprice.json", | |
| "agify": "https://api.agify.io/?name=michael", | |
| "genderize": "https://api.genderize.io/?name=luc", | |
| "nationalize": "https://api.nationalize.io/?name=nathaniel", | |
| "bored": "https://www.boredapi.com/api/activity", | |
| "random_user": "https://randomuser.me/api/", | |
| "country_info": "https://restcountries.com/v3.1/name/germany", | |
| "dictionary": "https://api.dictionaryapi.dev/api/v2/entries/en/hello", | |
| "university_list": "http://universities.hipolabs.com/search?country=United+States", | |
| "zip_code": "https://api.zippopotam.us/us/90210", | |
| "quote": "https://api.quotable.io/random", | |
| "anime_quote": "https://animechan.xyz/api/random", | |
| "pokemon": "https://pokeapi.co/api/v2/pokemon/ditto", | |
| "space_news": "https://api.spaceflightnewsapi.net/v4/articles/", | |
| "art_institute_chicago": "https://api.artic.edu/api/v1/artworks/search?q=cats", | |
| "cocktail": "https://www.thecocktaildb.com/api/json/v1/1/random.php", | |
| "meal": "https://www.themealdb.com/api/json/v1/1/random.php", | |
| "advice": "https://api.adviceslip.com/advice", | |
| "binary": "https://api.noopschallenge.com/binary", | |
| "data_usa": "https://datausa.io/api/data?drilldowns=Nation&measures=Population", | |
| "ghibli": "https://ghibliapi.herokuapp.com/films", | |
| "holiday": "https://date.nager.at/api/v3/PublicHolidays/2023/US", | |
| "open_library": "https://openlibrary.org/search.json?q=the+lord+of+the+rings", | |
| "skyscanner": "https://partners.api.skyscanner.net/apiservices/v3/geo/hierarchy/flights/en-GB", | |
| "world_bank": "http://api.worldbank.org/v2/country/all/indicator/SP.POP.TOTL?format=json", | |
| "nasa": "https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY", | |
| "wallhaven": "https://wallhaven.cc/api/v1/search", | |
| "coingecko": "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd", | |
| "binance": "https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT", | |
| "exchange_rate": "https://api.exchangerate-api.com/v4/latest/USD" | |
| } | |
| def call_free_api(api_name, params=None): | |
| if api_name not in FREE_APIS: | |
| return {"error": "API not found"} | |
| url = FREE_APIS[api_name] | |
| try: | |
| response = requests.get(url, params=params) | |
| return response.json() | |
| except Exception as e: | |
| return {"error": str(e)} | |
| if __name__ == "__main__": | |
| # Test one | |
| print(call_free_api("joke")) | |