cd /news/artificial-intelligence/integrating-external-apis-with-agent… · home topics artificial-intelligence article
[ARTICLE · art-69725] src=dev.to ↗ pub= topic=artificial-intelligence verified=true sentiment=↑ positive

Integrating External APIs with Agentic AI: A Practical Approach

A developer demonstrates a practical approach to integrating external APIs with agentic AI, including code examples for weather data and Slack messaging, and emphasizes best practices such as secure API keys, timeout handling, and rate limiting. The post predicts that agents integrating 10+ APIs will become standard by 2026.

read1 min views2 publishedJul 23, 2026

An agent without APIs is limited. Connected to APIs, it's unstoppable.

import requests

def get_weather(city: str) -> str:
    """Get current weather for a city"""
    response = requests.get(
        f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={API_KEY}"
    )
    data = response.json()
    return f"{data['main']['temp']}°C in {city}"

from langchain.tools import tool

@tooldef weather_tool(city: str) -> str:
    """Get weather for a city"""
    return get_weather(city)
python
def safe_api_call(func, *args, **kwargs):
    try:
        return func(*args, **kwargs)
    except TimeoutError:
        return "API timeout - try again"
    except requests.exceptions.ConnectionError:
        return "Connection failed - check internet"
    except Exception as e:
        return f"Error: {str(e)}"
python
from functools import wraps
import time

def rate_limit(calls_per_second: float):
    min_interval = 1.0 / calls_per_second
    last_called = [0.0]

    def decorator(func):
        @wraps(func)        def wrapper(*args, **kwargs):
            elapsed = time.time() - last_called[0]
            if elapsed < min_interval:
                time.sleep(min_interval - elapsed)
            result = func(*args, **kwargs)
            last_called[0] = time.time()
            return result
        return wrapper
    return decorator

Connecting to Slack:

from slack_sdk import WebClient

client = WebClient(token=SLACK_TOKEN)

@tooldef send_slack_message(channel: str, text: str) -> str:
    """Send message to Slack channel"""
    response = client.chat_postMessage(
        channel=channel,
        text=text
    )
    return f"Message sent to {channel}"

✅ Secure API keys in environment variables

✅ Implement timeout handling

✅ Log all API calls

✅ Cache responses when possible

✅ Test with mock APIs first

✅ Monitor API usage & costs

✅ Handle rate limiting gracefully

Agents that integrate 10+ APIs will be standard in 2026.

What APIs are you connecting to your agents?

── more in #artificial-intelligence 4 stories · sorted by recency
── more on @openweathermap 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/integrating-external…] indexed:0 read:1min 2026-07-23 ·