Home/Insights/Data Engineering
Watch the video with chapters & transcript →
DATA ENGINEERING
In short: You call an external API from Snowflake by creating a network rule, an optional secret, an external access integration and a Python UDF that makes the request. The network rule uses MODE = EGRESS and TYPE = HOST:PORT, and the secret can be skipped for public APIs. Snowflake blocks outbound calls by default, and trial accounts do not support the integration.

If you have ever tried calling an API from Snowflake and got blocked, external access integration is the solution. In this tutorial, Ani Björkström goes beyond Snowflake's documentation and walks through every step, using the public Chuck Norris API as a real-world example you can try immediately.
Step one is deciding how Snowflake should connect to the external resource: through the public internet or a private network. In simple terms, you choose whether your Snowflake environment reaches the API via the open web or through a private, secure connection — the tutorial uses the public internet option to keep things straightforward.
The network rule tells Snowflake which outbound connection is allowed. In the example it is called chuck_norris_api_network_rule, with mode set to EGRESS — networking jargon for data going out, since Snowflake is reaching out to the API and not the other way around — type set to HOST:PORT, and the API's host name specified. The integration itself is then created with CREATE OR REPLACE EXTERNAL ACCESS INTEGRATION, a name of your choice, the network rule attached via ALLOWED NETWORK RULE, and ENABLED = TRUE to activate it.
| Step | Object | Key detail |
|---|---|---|
| 1 | Connectivity decision | Public internet or private network |
| 2 | Network rule | MODE = EGRESS, TYPE = HOST:PORT, API host name |
| 3 | Secret | Stores credentials; skipped for the public Chuck Norris API |
| 4 | External access integration | References the network rule, ENABLED = TRUE |
| 5 | Python UDF | Runtime 3.9, handler get_joke, linked to the integration |
A secret stores the credentials Snowflake needs to authenticate against a private API — commonly a username and password, or more often these days industry-standard methods like OAuth tokens. Because the Chuck Norris API is public and requires no authentication, the tutorial simply skips this step; you only create a secret when the API you are calling demands credentials.
The user-defined function is where the request happens: CREATE OR REPLACE FUNCTION with a STRING return type, LANGUAGE PYTHON, runtime version 3.9, and a handler naming the Python function inside the code — here, get_joke. The function is linked to the integration by name, required packages are listed, and the Python code sits between dollar signs, wrapped in a try/except block: on success it returns the API response, otherwise an error message. Once created, the function lives in the database you specify and is called with a plain SELECT — parameters can be passed directly, as in SELECT my_function('random'). The tutorial recommends writing the Python in a proper editor with syntax highlighting (the demo used Snowflake notebooks) rather than in Snowflake's single-color text field.
Trial accounts do not support external access integrations, so the CREATE statement fails there. The syntax is correct and runs on any full Snowflake account.
Egress simply means outbound traffic — Snowflake reaching out to the API rather than the API calling into Snowflake.
Call it in a query with SELECT my_function_name, adding parameters in parentheses if the function requires them.
Read the full video transcript, with chapters, on the video page →
Want this working inside your finance team?