VillageSQL is a drop-in replacement for MySQL with extensions.
All examples in this guide work on VillageSQL. Install Now →
vsql_http extension lets you pull that data directly from a query or store it in a column with a single UPDATE.
Setup
Pattern 1: Store Enrichment in a Column
The most common use: backfill a column with data fetched from an external API. Run an UPDATE that calls the API per row, store the result, then query the stored column. This example fetches a shipping status for each order:shipping_status IS NULL remain. Process in batches to stay within API rate limits.
After backfilling, queries hit the stored column — no API call per query:
Pattern 2: Live Lookup in a Query
For data that changes too fast to cache — exchange rates, real-time pricing — you can call the API inline in the SELECT. Every row in the result triggers a request, so keep the result set small.http_get() inside the SELECT expression unless each row genuinely needs a different API call.
Pattern 3: Conditional Enrichment
Only fetch for rows that actually need it using WHERE to filter before calling the API:url_encode() wrapping the address — always encode user data before embedding it in a URL.
Handling API Errors
Allvsql_http functions return NULL on connection failure. Check the status code before using the content:
Performance Considerations
Each HTTP call is synchronous and blocks the query. A batch of 50 rows each hitting a 200ms API takes 10 seconds minimum. Setmax_execution_time accordingly:
Troubleshooting
Next Steps
- Making HTTP requests from SQL — full function reference and response parsing
- Sending webhooks from triggers — push changes out instead of pulling data in
See also
- Making HTTP Requests from SQL — the HTTP functions used for API calls
- JSON in MySQL — parsing the JSON responses returned by APIs

