<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Lakebase Data API in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/lakebase-data-api/m-p/176376#M57135</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/271176"&gt;@Jack17&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;One small addition to the service principal advice above, because it makes testing a lot easier. Since 12 November, OAuth on-behalf-of for service principals is generally available, so you can test the Data API locally as the same service principal your job will run as, without creating an OAuth secret for it:&lt;/P&gt;&lt;PRE&gt;databricks auth login --host https://your-workspace-url
# in the browser, pick the service principal from the dropdown and authorize
databricks auth token --host https://your-workspace-url&lt;/PRE&gt;&lt;P&gt;You need the Service Principal Manager role on that service principal (you get it automatically if you created it). Use the token as the Bearer token for your test POSTs. If the inserts work locally with it, you know the Postgres role and grants for the service principal are right before you schedule anything, and the scheduled job then runs as that same service principal.&lt;/P&gt;&lt;P&gt;Cheers,&lt;BR /&gt;Suranga&lt;/P&gt;</description>
    <pubDate>Fri, 13 Nov 2026 21:33:24 GMT</pubDate>
    <dc:creator>suranga</dc:creator>
    <dc:date>2026-11-13T21:33:24Z</dc:date>
    <item>
      <title>Lakebase Data API</title>
      <link>https://community.databricks.com/t5/data-engineering/lakebase-data-api/m-p/176212#M57112</link>
      <description>&lt;P&gt;We need to bring the json data from external API and need to load it into lakebase API tables.&lt;BR /&gt;Please suggest in connecting this.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2026 02:23:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/lakebase-data-api/m-p/176212#M57112</guid>
      <dc:creator>Jack17</dc:creator>
      <dc:date>2026-11-12T02:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: Lakebase Data API</title>
      <link>https://community.databricks.com/t5/data-engineering/lakebase-data-api/m-p/176220#M57113</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;You can ingest JSON data from an external REST API into Databricks Lakebase (PostgreSQL) using a Databricks notebook.&lt;BR /&gt;I would suggest the following approach:&lt;BR /&gt;&lt;STRONG&gt;Extract data:&lt;/STRONG&gt; Use Python's request&amp;nbsp;library to connect to the external API and retrieve the JSON response. Configure the required authentication (API key, OAuth, etc.).&lt;BR /&gt;&lt;STRONG&gt;Transform data:&lt;/STRONG&gt; Parse the JSON response and map the fields to your target Lakebase table schema.&lt;BR /&gt;&lt;STRONG&gt;Load into Lakebase:&lt;/STRONG&gt; You can use the Lakebase Data API, which supports inserting records through HTTP POST requests, or connect directly using a PostgreSQL driver such as psycopg.&lt;BR /&gt;&lt;STRONG&gt;Automate ingestion:&lt;/STRONG&gt; Schedule the notebook using Databricks Workflows. For larger datasets, consider pagination, batching, incremental loads, and error handling.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Suggested flow:&lt;/STRONG&gt;&lt;BR /&gt;External REST API → Databricks Notebook (Python) → JSON Processing → Lakebase PostgreSQL Table&lt;/P&gt;&lt;P&gt;If you are using Lakebase Autoscaling, the Data API is a convenient option. Make sure it is enabled and the authenticated identity has the required table permissions.&lt;/P&gt;&lt;P&gt;Reference:&lt;BR /&gt;&lt;A href="https://docs.databricks.com/aws/en/oltp/projects/data-api" target="_self"&gt;https://docs.databricks.com/aws/en/oltp/projects/data-api&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2026 05:54:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/lakebase-data-api/m-p/176220#M57113</guid>
      <dc:creator>Divya_Pathak</dc:creator>
      <dc:date>2026-11-12T05:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Lakebase Data API</title>
      <link>https://community.databricks.com/t5/data-engineering/lakebase-data-api/m-p/176253#M57118</link>
      <description>&lt;P&gt;Adding to the notebook approach above, two things to plan for. The Data API wants an OAuth bearer token on every request, and those tokens are short lived (about an hour per the docs), so a scheduled job should fetch a fresh one at the start of each run instead of storing one. I also couldn't find any documented payload or rate limit for POST inserts, so for a large JSON load I'd send it in batches and test with your real volume first. If that turns out slow, a normal Postgres driver with batched inserts is the fallback. Either way, the identity the job runs as needs INSERT on the target table, and a service principal is easier to manage for that than your own user.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2026 13:12:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/lakebase-data-api/m-p/176253#M57118</guid>
      <dc:creator>DoTA</dc:creator>
      <dc:date>2026-11-12T13:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: Lakebase Data API</title>
      <link>https://community.databricks.com/t5/data-engineering/lakebase-data-api/m-p/176367#M57131</link>
      <description>&lt;P&gt;Hello Jack17, I took a look at both internal and external documentation and here is what I found.&lt;/P&gt;
&lt;P&gt;Divya_Pathak's flow (pull with &lt;CODE&gt;requests&lt;/CODE&gt;, flatten, write to Lakebase, schedule it as a job) is the right skeleton, and DoTA's cautions are the ones that bite: the OAuth token expires after an hour, there's no documented payload or rate limit on Data API POSTs, and a service principal is the identity to run under. One question decides the rest of the design, and the post doesn't say: where will the code that pulls from the external API run?&lt;/P&gt;
&lt;P&gt;If it runs outside Databricks (a small service, a serverless function, or the source system pushing to you), the Data API fits. It's PostgREST-compatible, so POST a JSON array to &lt;CODE&gt;/public/&amp;lt;table&amp;gt;&lt;/CODE&gt; and you get one row per element in a single request. Add the header &lt;CODE&gt;Prefer: resolution=merge-duplicates&lt;/CODE&gt; (optionally with &lt;CODE&gt;on_conflict=&amp;lt;key_column&amp;gt;&lt;/CODE&gt;) and re-pulling overlapping data becomes insert-or-update instead of a duplicate-key error. The API URL is on the API tab in the Lakebase App; the token comes from the OAuth flow on the authentication page, not from that tab. Setup gotchas from the docs: it needs an Autoscaling project; don't use the project owner identity, because &lt;CODE&gt;authenticator&lt;/CODE&gt; can't assume it; create the role with &lt;CODE&gt;SELECT databricks_create_role(...)&lt;/CODE&gt; in the SQL editor rather than the Roles &amp;amp; Databases UI, or &lt;CODE&gt;GRANT "&amp;lt;identity&amp;gt;" TO authenticator&lt;/CODE&gt; fails with SQLSTATE 42501; and click Refresh schema cache after you create or alter the table.&lt;/P&gt;
&lt;P&gt;If it runs as a Databricks notebook or job, skip the HTTP hop and use a Postgres driver. Mint the same token with the SDK, connect with &lt;CODE&gt;psycopg&lt;/CODE&gt; over SSL, and use &lt;CODE&gt;executemany&lt;/CODE&gt; or &lt;CODE&gt;COPY&lt;/CODE&gt;. If the JSON is nested, store the raw payload in a &lt;CODE&gt;jsonb&lt;/CODE&gt; column and flatten it with SQL later:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class="language-python"&gt;import psycopg, requests
from databricks.sdk import WorkspaceClient
from psycopg.types.json import Jsonb

records = requests.get("https://api.example.com/items", timeout=60).json()
cred = WorkspaceClient().postgres.generate_database_credential(
    endpoint="projects/&amp;lt;project&amp;gt;/branches/&amp;lt;branch&amp;gt;/endpoints/&amp;lt;endpoint&amp;gt;")

with psycopg.connect(host="&amp;lt;host&amp;gt;", dbname="databricks_postgres",
                     user="&amp;lt;identity&amp;gt;", password=cred.token, sslmode="require") as conn:
    conn.cursor().executemany(
        """INSERT INTO public.api_data (id, payload) VALUES (%s, %s)
           ON CONFLICT (id) DO UPDATE SET payload = EXCLUDED.payload""",
        [(r["id"], Jsonb(r)) for r in records])
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Generate a fresh credential each time you open a connection, keep the service principal secret in a Databricks secret scope, and give that principal INSERT on the target table.&lt;/P&gt;
&lt;P&gt;If the JSON also belongs in the lakehouse, there's a third route: write it to a Delta table first, then create a synced table from Unity Catalog into your Lakebase project. The Postgres copy is read-only, which is fine if the app only reads it, and you keep the Delta history.&lt;/P&gt;
&lt;P&gt;Short version: Data API when the writer lives outside Databricks, a Postgres driver when it lives inside, synced tables when the data needs to exist in both places anyway.&lt;/P&gt;
&lt;P&gt;References:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Lakebase Data API: &lt;A href="https://docs.databricks.com/aws/en/oltp/projects/data-api" target="_blank"&gt;https://docs.databricks.com/aws/en/oltp/projects/data-api&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Lakebase authentication and token rotation: &lt;A href="https://docs.databricks.com/aws/en/oltp/projects/authentication" target="_blank"&gt;https://docs.databricks.com/aws/en/oltp/projects/authentication&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Connect an external app with the SDK (service principal plus psycopg): &lt;A href="https://docs.databricks.com/aws/en/oltp/projects/external-apps-connect" target="_blank"&gt;https://docs.databricks.com/aws/en/oltp/projects/external-apps-connect&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Synced tables for Autoscaling projects: &lt;A href="https://docs.databricks.com/aws/en/oltp/projects/sync-tables" target="_blank"&gt;https://docs.databricks.com/aws/en/oltp/projects/sync-tables&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;PostgREST API reference (bulk insert, upsert, Prefer headers): &lt;A href="https://postgrest.org/en/stable/references/api.html" target="_blank"&gt;https://postgrest.org/en/stable/references/api.html&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Louis.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2026 19:16:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/lakebase-data-api/m-p/176367#M57131</guid>
      <dc:creator>Louis_Frolio</dc:creator>
      <dc:date>2026-11-13T19:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: Lakebase Data API</title>
      <link>https://community.databricks.com/t5/data-engineering/lakebase-data-api/m-p/176376#M57135</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/271176"&gt;@Jack17&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;One small addition to the service principal advice above, because it makes testing a lot easier. Since 12 November, OAuth on-behalf-of for service principals is generally available, so you can test the Data API locally as the same service principal your job will run as, without creating an OAuth secret for it:&lt;/P&gt;&lt;PRE&gt;databricks auth login --host https://your-workspace-url
# in the browser, pick the service principal from the dropdown and authorize
databricks auth token --host https://your-workspace-url&lt;/PRE&gt;&lt;P&gt;You need the Service Principal Manager role on that service principal (you get it automatically if you created it). Use the token as the Bearer token for your test POSTs. If the inserts work locally with it, you know the Postgres role and grants for the service principal are right before you schedule anything, and the scheduled job then runs as that same service principal.&lt;/P&gt;&lt;P&gt;Cheers,&lt;BR /&gt;Suranga&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2026 21:33:24 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/lakebase-data-api/m-p/176376#M57135</guid>
      <dc:creator>suranga</dc:creator>
      <dc:date>2026-11-13T21:33:24Z</dc:date>
    </item>
  </channel>
</rss>

