Tip Sheet #42: Football, Data, and APIs!


Hi Tip-Sheeters,

This week brings one of the most exciting times of the year for me: the National Football League kicks off its regular season. I'm a fan of the Kansas City Chiefs, and they'll be playing their opener in São Paolo, Brazil (in Arena Corinthians if there are any serious soccer fans out there).

This also means Fantasy Football Season begins!! I'm a huge fantasy football fanatic, and I'll be managing five teams this year. What is fantasy football, you ask? Here is a succinct definition from the FantasyPros Fantasy Football 101:

In fantasy football, you select and manage a team of real NFL players. The players on your team earn points for your team based on their real-life performance in games each week. These points are then totaled and compared to your opponent’s team each week to determine the winner.
-- FantasyPros.com

Fantasy Football, APIs, and AI: A perfect team

Since I enjoy this hobby so much, it was only natural to use it for the examples in my book that came out in April: Hands-on APIs for AI and Data Science. The book's been a success, hitting Amazon #1 New Release when it launched. I've had fun this year speaking and sharing tips from the book.

So how exactly does the book use fantasy football to teach about APIs and AI? Glad you asked.

Every Imaginary Business needs a Website

Part 1 of my book walks readers through the API Product Management Lifecycle: understanding user needs and designing and building a FastAPI REST API to serve them. The business scenario is built on an imaginary website named SportsWorldCentral:

Based on this business scenario, readers design and build the SportsWorldCentral API. This contains API endpoints providing data about players, teams, and scoring:

You'll also learn to deploy the API using Docker, Render, and Amazon Web Services.

Building Data Analytics for Football

With a running API, you're ready to start using it for data science. One of the first projects is building a data app using Streamlit. You'll build a multi-page app with charts and data filters, sourced from the API you built. (Or based on one you can launch with the code repo if you're in a hurry.) Here's the team stats page you'll create:

Developing Your Own Custom Metrics

Possibly the most fun I had in writing the book was developing a metric that had been bouncing around my head for many years: The Shark League Score. This Metric used a variety of data features to answer the question: Is my fantasy league as tough as I think? The chapter uses sub-metrics like the League Balance Score and League Juice Score to make the final product:

The Big Finish: Using Your API with Generative AI

Part Three of the book gives readers the skills to develop custom AI agents that consume APIs. You'll use products like ChatGPT, LangChain, and Anthropic APIs to chat with your data. Here is a look at the Custom GPT you will develop:

If you really want to get technical, you'll learn to build an AI Agent using LangChain. Here's the architecture you'll implement:

Are You Ready for Football, AI, and APIs?

If you haven't checked checked out the book yet, I'd be flattered if you took a look at it!

Here are two easy options:

Hope your fantasy football season is a good one!

Keep coding,

Ryan Day

👉 https://tips.handsonapibook.com/ -- no spam, just a short email every week.

Ryan Day

Every week or two I share tips for hands-on skills related to data science, APIs, and AI. From the author of Hands-on APIs for AI and Data Science:Python Development with FastAPI from O'Reilly Publishing

Read more from Ryan Day

Hi Tip-Sheeters, The World Cup starts today!!! I live in Kansas City, USA and we're one of the host cities for the World Cup games this year. We're also hosting the training camps for the Netherlands, England, and Argentina so it's going to be an exciting month. If you visit the airport, you'll see we are ready for the festivities to begin! So this week I'm sharing a variety of World Cup and soccer / voetbal / fútbol / football links related to data and analytics. I'll be rooting for the red,...

Hi Tip-Sheeters, This week has an everything-old-is-new-again flavor: we're looking at building command line interfaces (CLIs) for APIs. You remember those old things: the somewhat cryptic tools you run in a linux prompt or from your Mac's terminal. Well they're having a moment in the AI and API space because they're a useful way for agents to call your APIs. And we're going to build one for the Air Travel API. Read to the end to see an LLM use the CLI in an agent harness. Back from Summer...

Ricardo Heredia Joya

Hi Tip-Sheeters, This week I'm sharing highlights of virtual chat I had with Ricardo Heredia Joya, a Madrid data scientist with a background as a medical doctor. He is active in the Football analytics community, and shares his thoughts and tips in the Underdoc substack. (If you're enjoying the Tip Sheet I'm sure you'll get a lot from Ricardo's newsletter.) You are your best asset, so never stop learning. - Ricardo Heredia Joya Q1: Thanks for having a virtual chat with the Tip Sheet...