Home/Insights/Data Engineering

How to Call External APIs from Snowflake: External Access Integration Guide

By Ani BjörkströmPublished 30 July 2025Reviewed 17 November 20266 min video + articleData Engineering

How to Call External APIs from Snowflake: External Access Integration Guide
▶ Watch the full 6-minute video · with chapters & transcript

DATA ENGINEERING

How Do You Call an External API from Snowflake with External Access Integration?

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.

Snowflake external access at a glance: 4 parts Network rule, secret, integration, UDF; 3.9 Python runtime version used in the UDF; 5 steps Listed in the tutorial's setup table

Key takeaways

  • Snowflake blocks outbound API calls by default; the fix is a four-part chain — network rule, optional secret, external access integration, and a Python UDF that makes the request.
  • The network rule uses MODE = EGRESS (outbound traffic) and TYPE = HOST:PORT, and the secret step can be skipped entirely for public APIs that need no authentication.
  • Trial accounts do not support external access integrations, so the syntax shown works only on a full Snowflake account.

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.

What is the first decision before creating an external access integration?

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.

How do you create the network rule and integration?

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.

StepObjectKey detail
1Connectivity decisionPublic internet or private network
2Network ruleMODE = EGRESS, TYPE = HOST:PORT, API host name
3SecretStores credentials; skipped for the public Chuck Norris API
4External access integrationReferences the network rule, ENABLED = TRUE
5Python UDFRuntime 3.9, handler get_joke, linked to the integration

When do you need a secret, and when can you skip it?

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.

How does the Python UDF actually call the API?

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.

FAQ

Why can't this run on a Snowflake trial account?

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.

What does EGRESS mean in the network rule?

Egress simply means outbound traffic — Snowflake reaching out to the API rather than the API calling into Snowflake.

How do I use the function after creating it?

Call it in a query with SELECT my_function_name, adding parameters in parentheses if the function requires them.

Want this working inside your finance team?

Ani Björkström

Ani Björkström — founder of QvantX Sweden AB, a Stockholm consultancy building AI solutions for banks, asset managers and finance teams. Anthropic partner. Every article starts from a real client build, minus the confidential parts. LinkedIn →