Lesson 4: Information Retrieval
Guides building a Flask app that fetches Bitcoin exchange rates from multiple APIs, stores them in SQLite, and displays best rates and historical trends.
What this file does
Guides building a Flask app that fetches Bitcoin exchange rates from multiple APIs, stores them in SQLite, and displays best rates and historical trends.
When to use it
- Learning to pull data from external APIs in a Flask app
- Building a dashboard that compares live data from multiple sources
- Practicing scheduled data collection with a scheduler in Python
- Teaching a workshop on web development for data scientists
Assumes this stack
Lesson 4: Information Retrieval
In this session, you will learn how to obtain data from web APIs as well as parse and normalize the data to use in a chart.
Objectives
By the end of this lesson, you should be able to:
- Make an AJAX request from the server to grab data from an external API
- Use a scheduler to continuously pull data from external sources
Welcome
Slides: npm run day4
Challenge
The focus over the next two sessions will be to build the following app...
Flask Bitcoin
Build an app that will find the best exchange rates for Bitcoin (USD -> Bitcoin) from the following cryptocurrency exchanges:
It should have the following pages:
- The first page should display the rates and highlight the best one
- The second page should display the rates over time
Instructions
We'll work through the pseudocode together. You'll code the app either alone (or with the awesome, good-looking people at your table). We'll come together after each step to review.
Part 1 - Server
Code Along!
- Project Setup
- Add SQLite
- Get Data
- Add scheduler
Example code: https://github.com/realpython/flask-bitcoin-example
Homework
- Compare your code from class with the flask-bitcoin-example code. Make any necessary changes to your code.
- Refactor to use SQLAlchemy
- Deploy to Heroku
- Add the remaining bitcoin exchanges
What's inside
Objectives, challenge description, 4-part build instructions, homework tasks, and links to example code and bonus materials.
Change this for your project
- Replace
realpython/flask-bitcoin-examplewith your own repository URL - Replace exchange URLs
https://www.bitstamp.net/,https://www.kraken.com/,https://bittrex.com/with your data sources - Replace
npm run day4with your own slide presentation command
Where it goes
Keep it in your repository where the agent or team that needs it will read it.
Related Documents
Data Retrieval
Downloads UK electricity generation and pricing data from Electric Insights and Energy Charts APIs using the moepy library, then visualises fuel-mix time-series.
RETRIEVAL.md — Memory Scan Protocol
Defines a five-step internal memory retrieval protocol that surfaces results only in LiveHud gauges, never as visible logs.
Retrieval
Fits linear and nonlinear ephemerides to exoplanet transit times using nested sampling, then compares Bayesian evidence to detect hidden planets.