Transforming external APIs into tables with foreign data wrappers
Imagine this – instead of querying an API to store data inside your database or to retrieve certain information, the only thing you have to do is select data from your database instead. This sounds like some kind of magic, and indeed it is.
Supabase supports so-called foreign data wrappers (FDWs). These FDWs act as if they’re just another table in your database, which means you can query them like tables with the Supabase client, but they are essentially a proxy between the database and the API. That means you can connect an external source that will act as if it’s just another table and you can hence query it as such.
Figure 13.8: FDW visualization
This is best learned by using it, so let’s do that. Within Supabase Studio, you can activate the FDW functionality by either activating the postgres_fdw
extension in the Database | Extensions section or by clicking...