> ## Documentation Index
> Fetch the complete documentation index at: https://docs.noxus.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 4. Use Integration in Node

> Wire the integration into your node to call a real API with credentials

<Note>
  This is **part 4** of the [Your First Plugin](/developers/plugins/your-first-plugin) tutorial. Make sure you've completed [3. First Integration](/developers/plugins/tutorial/first-integration) first.
</Note>

Now let's connect the node to the integration so it uses real credentials to call an external API.

## Declare the integration dependency

Update the node class to reference the integration:

```python theme={null}
class GetWeatherNode(BaseNode[GetWeatherConfig]):
    node_name = "get_weather"
    title = "Get Weather"
    description = "Returns weather data for a given city"
    category = NodeCategory.DATA
    color = "#4A90E2"
    integrations = {"weather_api": ["api_key"]}  # integration_type: [required_fields]

    # ... same inputs/outputs ...

    async def call(self, ctx: RemoteExecutionContext, city: str) -> dict:
        import httpx

        # Get credentials from the execution context
        creds = ctx.get_integration_credentials("weather_api")
        api_key = creds.get("api_key", "")

        if not api_key:
            raise ValueError("Weather API key not configured")

        # Call the real API
        async with httpx.AsyncClient() as client:
            response = await client.get(
                "https://api.openweathermap.org/data/2.5/weather",
                params={"q": city, "appid": api_key, "units": "metric"},
            )
            response.raise_for_status()
            data = response.json()

        return {
            "temperature": f"{data['main']['temp']}°C",
            "description": data["weather"][0]["description"].capitalize(),
        }
```

### What changed

1. **`integrations = {"weather_api": ["api_key"]}`** — declares this node depends on the `weather_api` integration. The platform will show a connection prompt in the editor if credentials aren't configured.

2. **`ctx.get_integration_credentials("weather_api")`** — retrieves the decrypted credentials at runtime. Returns a dict with the fields from your `BaseCredentials` model.

## How credentials flow

```mermaid theme={null}
sequenceDiagram
    participant U as User
    participant WS as Workspace Settings
    participant W as Worker
    participant PS as Plugin Server
    participant P as Plugin Process

    U->>WS: Enter API key for Weather API
    WS->>WS: Encrypt & store credentials
    Note over W: Workflow runs...
    W->>PS: Execute get_weather node
    Note over W: Includes decrypted credentials in ctx
    PS->>P: Forward with ctx.integration_credentials
    P->>P: ctx.get_integration_credentials("weather_api")
    P->>P: Call external API with api_key
```

Credentials are **never stored in the plugin**. They're decrypted by the platform at execution time and passed through the `RemoteExecutionContext` for that specific run.

## Using multiple integrations

A node can depend on more than one integration:

```python theme={null}
class CrossPostNode(BaseNode[NodeConfiguration]):
    node_name = "cross_post"
    integrations = {
        "twitter": ["api_key", "api_secret"],
        "linkedin": ["access_token"],
    }

    async def call(self, ctx: RemoteExecutionContext, message: str) -> dict:
        twitter_creds = ctx.get_integration_credentials("twitter")
        linkedin_creds = ctx.get_integration_credentials("linkedin")

        # Use both sets of credentials...
        return {"status": "posted"}
```

## Error handling for credentials

Always validate that credentials exist before using them:

```python theme={null}
async def call(self, ctx: RemoteExecutionContext, city: str) -> dict:
    creds = ctx.get_integration_credentials("weather_api")

    if not creds or not creds.get("api_key"):
        raise ValueError(
            "Weather API credentials not configured. "
            "Go to Workspace Settings → Integrations to add your API key."
        )

    # Safe to use credentials...
```

<Card title="Next: Working with Files →" icon="arrow-right" href="/developers/plugins/tutorial/working-with-files">
  Read and create files from plugin nodes.
</Card>
