Ingesting Data From REST API endpoints in Fabric Lakehouse

Ingesting Data From REST API endpoints in Fabric Lakehouse

Technical Details

Representational?State?Transfer (REST) is a software architectural design that has been employed throughout the software industry to create?stateless web applications. An application that adheres to the?REST may be informally described as?RESTful.? This term is more commonly associated with the design of?HTTP-based?APIs?to interact with data that is stored on a vendors web site.? Today, we are going to explore how Python can be used in a Fabric notebook to interact with a popular website called Spotify.

Business Problem

Our manager has asked us to create a prototype notebook that can be used to interact with a web site using the REST API endpoints.? This code will demonstrate the following concepts:? how to grab an access token; how to perform a single read from an endpoint; how to save simple JSON data to a file; how to perform paged reads from an endpoint; and how to convert multiple JSON files into a single delta table.? To make this code somewhat reusable, we will want to write python functions.

Spotify Data

To access most REST API services, we need to login to the service to retrieve a bearer (access) token.? This token usually has a lifespan of 60 minutes.? During that time, multiple calls to various endpoints can be made.? Once the token expires, an HTTP error will occur.? To resolve this error, just ask for another token.

I like using a modular design when coding in Python.? You can even take it one step further by using object-oriented programming.? Each task is broken into functions.? I created functions for the following tasks.

  • Grab key vault secrets
  • Decode a redacted secret
  • Grab an access token
  • Make a GET http request
  • Write a JSON file given a dictionary
  • Read all JSON files and recreate a Delta Table.

Each one of these tasks were coded into a function and tested separately.? These components were called one or more times to load both the genres and artists entities.? Today’s article was not meant to be a complete coverage of the Spotify REST API.? Instead, its purpose was to show design patterns that you might encounter when writing Python code in Microsoft Fabric to talk to Web Services.

要查看或添加评论,请登录

John Miner的更多文章

  • Why use Tally Tables in the Fabric Warehouse?

    Why use Tally Tables in the Fabric Warehouse?

    Technical Problem Did you know that Edgar F. Codd is considered the father of the relational model that is used by most…

  • Streaming Data with Azure Databricks

    Streaming Data with Azure Databricks

    Technical Problem The core functionality of Apache Spark has support for structured streaming using either a batch or a…

    1 条评论
  • Upcoming Fabric Webinars from Insight

    Upcoming Fabric Webinars from Insight

    Don't miss the opportunity to boost your data skills with Insight and Microsoft. This webinar series will help you…

  • How to develop solutions with Fabric Data Warehouse?

    How to develop solutions with Fabric Data Warehouse?

    Technology Details The SQL endpoint of the Fabric Data Warehouse allows programs to read from and write to tables. The…

  • Understanding file formats within the Fabric Lakehouse

    Understanding file formats within the Fabric Lakehouse

    I am looking forward to talking to the Cloud Data Driven user group on March 13th. You can find all the presentation…

    3 条评论
  • Engineering a Lakehouse with Azure Databricks with Spark Dataframes

    Engineering a Lakehouse with Azure Databricks with Spark Dataframes

    Problem Time does surely fly. I remember when Databricks was released to general availability in Azure in March 2018.

  • Create an Azure Databricks SQL Warehouse

    Create an Azure Databricks SQL Warehouse

    Problem Many companies are leveraging data lakes to manage both structured and unstructured data. However, not all…

    2 条评论
  • How to Load a Fabric Warehouse?

    How to Load a Fabric Warehouse?

    Technology The data warehouse in Microsoft Fabric was re-written to use One Lake storage. This means each and every…

  • My Year End Wrap Up for 2024

    My Year End Wrap Up for 2024

    Hi Folks, It has been a very busy year. At the start of this year I wanted to learn Fabric in depth.

    1 条评论
  • Virtualizing GCP data with Fabric Shortcuts

    Virtualizing GCP data with Fabric Shortcuts

    New Technology Before the invention of shortcuts in Microsoft Fabric, big data engineers had to create pipelines to…

社区洞察

其他会员也浏览了