Nango provides unified API access for AI agents with OAuth handling, 700+ pre-built integrations, and MCP server support. This skill helps you connect your agent to any external API.
# Python
pip install nango
# Node.js
npm install @nangohq/node-client
Add to your environment:
NANGO_SECRET_KEY=your-secret-key-here
NANGO_HOST=https://api.nango.dev # or self-hosted
For APIs requiring OAuth (Google, Slack, GitHub, etc.):
from nango import Nango
nango = Nango()
# Get OAuth URL
auth_url = nango.get_auth_url(
provider="google",
redirect_uri="https://your-app.com/callback"
)
# User visits auth_url, authorizes, returns with code
# Exchange code for connection
connection = nango.create_connection(
provider="google",
code="auth_code_from_callback",
connection_id="user-google-123"
)
# Now make API calls
result = nango.proxy(
provider="google",
endpoint="/gmail/v1/users/me/messages",
connection_id="user-google-123"
)
For APIs using API keys (Stripe, OpenAI, etc.):
from nango import Nango
nango = Nango()
# Set API key for provider
nango.set_credentials(
provider="stripe",
connection_id="user-stripe-123",
credentials={"api_key": "sk_test_xxx"}
)
# Make calls
customers = nango.proxy(
provider="stripe",
endpoint="/v1/customers",
connection_id="user-stripe-123"
)
For Model Context Protocol integration:
# Get MCP server configuration for a provider
mcp_config = nango.get_mcp_server(
provider="github",
connection_id="user-github-123"
)
# Use with MCP-compatible agents
# The config includes tools, resources, and prompts
| Provider | Use Case | Auth Type |
|---|---|---|
| ---------- | ---------- | ----------- |
| Gmail, Calendar, Drive | OAuth | |
| Slack | Messages, Channels | OAuth |
| GitHub | Repos, Issues, PRs | OAuth |
| Salesforce | CRM Data | OAuth |
| Stripe | Payments | API Key |
| Notion | Notes, Databases | OAuth |
| Linear | Issues, Projects | OAuth |
| HubSpot | CRM, Marketing | OAuth |
// integrations/my-custom-api.ts
import { NangoIntegration } from '@nangohq/types';
export default NangoIntegration({
// Provider name
provider: 'my-custom-api',
// Authentication type
auth: {
type: 'api_key', // or 'oauth2', 'basic'
credentials: {
api_key: { type: 'string', required: true }
}
},
// Available actions
actions: {
list_items: {
endpoint: '/items',
method: 'GET',
output: { type: 'array' }
},
create_item: {
endpoint: '/items',
method: 'POST',
input: { type: 'object' },
output: { type: 'object' }
}
}
});
# Deploy to Nango
nango deploy integrations/my-custom-api.ts
from nango import Nango, NangoError
try:
result = nango.proxy(
provider="github",
endpoint="/repos/owner/repo/issues",
connection_id="user-github-123"
)
except NangoError as e:
if e.code == "auth_expired":
# Re-authorize
auth_url = nango.get_auth_url("github")
print(f"Please re-authorize: {auth_url}")
elif e.code == "rate_limited":
# Wait and retry
time.sleep(e.retry_after)
else:
raise
To use Nango with OpenClaw agents:
# In your OpenClaw skill or tool
from nango import Nango
class NangoTool:
def __init__(self):
self.nango = Nango()
def call_api(self, provider: str, endpoint: str, connection_id: str, **params):
"""Generic API calling tool for any provider."""
return self.nango.proxy(
provider=provider,
endpoint=endpoint,
connection_id=connection_id,
params=params
)
def list_providers(self):
"""List all available providers."""
return self.nango.list_providers()
def get_provider_actions(self, provider: str):
"""Get available actions for a provider."""
return self.nango.get_actions(provider)
Free tier is sufficient for development and small projects.
共 1 个版本