← Blog/Salesforce

🔥 Deserializing F1 API Data in Apex – No Limits, No Surprises!

Ricardo Simões
Ricardo SimõesSoftware Engineer
|
🔥 Deserializing F1 API Data in Apex – No Limits, No Surprises!

And here we are, for the second part of our adventure storing Formula 1 data inside Salesforce! 😀

I’ll try not to make this post too technical, so I don’t bore you too much—promise I’ll keep it light! 😅(But if you are a nerd — like me — you can follow this other post where I go some deep inside implementation —Nerd)

First, let’s start with the goals we achieved in this phase:

  • ✅ Named Credentials
  • ✅ Apex exception handling when the API doesn’t respond
  • ✅ Connecting to the API and fetching data for a chosen year
  • ✅ Storing the received data into specific Salesforce objects
  • ✅ Visualizing the inserted data within our app
  • ✅ Creating an app dedicated solely to Formula 1
  • ✅ Studying the API’s data model to implement a proper Salesforce data model with the correct relationships between objects

Step 1 – Studying the Endpoint 🔍

  • We began by analyzing what the API returns, which endpoints exist, and which ones we wanted to use in this first phase.
  • After evaluation, we decided to use the Season endpoint, as it provides most of the data we need — race results, drivers, teams, and everything essential.

Step 2 – Creating the necessary objects 🗂️

  • After studying the API, we designed the Salesforce objects needed to store all relevant data from the API
  • Once the object structure was solid, we moved on to API implementation

Step 3 – API Configuration ⚙️

  • Following Salesforce best practices, we created a Named Credential to securely store the API connection
  • Then we built an Apex class: F1APIService, which holds all the logic for integrating Salesforce with the API. It contains all possible API calls.
  • We can now perform direct queries for specific drivers, teams, etc.
  • The code workflow looks like this:

Step 4 – Creating a ScreenFlow 🔄

  • We created a Screen Flow as the user interface for interacting with the API. In this flow, the user can search for any season they want.
  • Once the user triggers the search, the following records get created:

After all that, we reached the first version of our Formula 1 app! 🏁

It’s not perfect yet, but it’s getting there.

Right now, you can view all key info related to each season — everything is available inside the Lightning Record Pages for each object! ⚡


Next Steps 🛠️:

  • Implement a better way to identify whether a Race record is a race or a sprint — right now you have to open the record and check the “Type” field
  • Automate updates for the current season with weekend race results
  • Build a dynamic calendar showing upcoming races 📅
  • Create report types and dashboards to compare data between races, drivers, teams, seasons, and more 📊

Tags

0

Comments

Loading animation