Skip to main content

VillageSQL is a drop-in replacement for MySQL with extensions.

All examples in this guide work on VillageSQL. Install Now →
MySQL has no built-in way to make network requests. If you want to call an HTTP API, you pull the data out of the database, make the request in application code, and push results back. VillageSQL’s vsql_http extension adds http_get(), http_post(), and the full range of HTTP methods directly to SQL — so you can call external APIs from the same place the data lives.

The Problem: Leaving the Database for Every API Call

A typical pattern without VillageSQL:
This works but every row is three round-trips: SELECT, API call, UPDATE. The enrichment logic lives in application code instead of in the schema where the data lives.

With VillageSQL: HTTP from SQL

http_get(url) makes a GET request and returns a JSON string with the full response.
Every function in vsql_http returns the same JSON shape:

The charset conversion

VEF STRING functions return binary charset. Before passing the result to JSON_VALUE or JSON_EXTRACT, wrap it with CONVERT(... USING utf8mb4):
Assign to a variable with CONVERT once and reuse the variable to avoid repeating the cast.

POST Requests

http_post(url, content_type, body) sends a POST with a body:

Custom Headers and Other Methods

http_request(method, url, headers_json, body, content_type, options_json) handles any method with custom headers:
The headers_json argument is a JSON object where keys are header names and values are header values.

All available functions

All functions return NULL on connection failure or NULL input.

URL Encoding

url_encode() and url_decode() handle percent-encoding for query parameters:

Known Limitations

256KB response cap — Responses larger than 256KB are truncated. This covers typical API payloads used in SQL queries; it’s not suited for large file downloads. JSON_VALUE size limitJSON_VALUE returns NULL when the extracted value exceeds MySQL’s internal size limit. For large response bodies, use JSON_UNQUOTE(JSON_EXTRACT(...)) instead:
Synchronous — Every HTTP call blocks until it completes or times out. For bulk UPDATE operations, set max_execution_time to avoid hitting the default query timeout.

Troubleshooting

Next Steps

See also