(Maybe) Tracking Singapore's Blood Stock Fluctuations

- 7 mins


  1. I wrote a Telegram bot to track Singapore’s blood stock levels (@sgbloodstocksbot). Users can subscribe to the bot to be notified about changes in their blood type’s stock levels (or any changes at all).
  2. The stock data from 14th June 2021 onwards (constantly updated with new data) is available in this repository in the “Flat Data” format.

Graph of Singapore Blood Stocks since June 2021

If you’re on mobile, you can press and hold on this image and open it in a new tab.

Table of Contents


Why did I do this?

I was looking to donate my blood sometime in April 2021. Each time I checked the Singapore Red Cross website (scroll down there to see blood stocks), my blood type was fully stocked. It didn’t seem like the most useful time to donate, so I decided to wait.

The (happy) problem was, every time I checked for a while, my stock level was full. When was the best time to donate?.

I decided to make a Telegram bot (try @sgbloodstocksbot here!) that scrapes data from the Red Cross website and pings me when my blood type’s stocks change.

I then heard about Datascape Singapore, a project to save Singapore-related data into “Flat Data” files on GitHub. I used the same code from the Telegram bot to scrape and save the blood stock data daily, from 14th June 2021 onward, into this repository (see blood-stocks.json for the latest scraped data).

Where do I get exact blood stock levels?

This is where the (maybe) comes from. There is no official API or data source that I am aware of, so scraping is the only option. The Red Cross reports blood stock levels like this on their website:

Red Cross blood stock reporting

It seems like there are only four preset levels for each blood type: Healthy/Moderate/Low/Critical. That seemed fine at first. I could just report the broad category of blood stock level. However, if you look closer, you’ll notice something curious.

A- Blood Type O- Blood Type
Bloodstock picture for A- type Bloodstock picture for O- type

Two blood types, both reported as “Low”, have different “fill levels” in the image. Specifically, the HTML representing each image was (note the height parameter):

<!-- A- blood type -->
<div class="fill_humam" style="height: 45%; background: #ffc000;"></div>

<!-- 0- blood type -->
<div class="fill_humam" style="height: 35%; background: #ffc000;"></div>

So maybe there are more presets than expected (increments of 5% each time?). But if we look at the height parameters of some of the other blood level images:

<!-- A+ blood type -->
<div class="fill_humam" style="height: 59%; background: #ffff00;"></div>

<!-- AB- blood type -->
<div class="fill_humam" style="height: 18%; background: #ff0000;"></div>

These blood stock levels seem to be updated to a precision of 1%. One last piece of evidence:

Bloodstock update on Telegram

@sgbloodstocksbot pings all subscribers when blood stock levels change (you can watch for a specific blood type or any of them). Notice that the O+ blood type changes only by 1%. Visually, no website user will see a 1% change in the image fill level, so this must be some semi-automated and precise process.

TLDR: I hypothesize that the image fill levels are accurate and precise blood stock levels.

Is this okay?

I get asked sometimes if the blood stock levels are sensitive information and whether I should be publicly broadcasting them. In my view, if the stock levels are accurate, and are already publicly updated by the Red Cross to within 1% (even if it’s encoded within an image), then I’m just using public data. My only intention is to create a useful service to know when to donate blood.

Overview of the data

Downloading and plotting

The blood stock data is stored in this repository, but each update is a separate git commit. We first have to download all versions of blood-stocks.json across all commits. The code to download and analyze the most up-to-date data is here, feel free to give it a go!

Graph of Singapore Blood Stocks If you’re on mobile, you can press and hold on this image and open it in a new tab.

Graph format and data frequency

Some questions

Disclaimer again that I’m not an expert. The Red Cross has facts and figures here and an infographic of 2021 blood usage here.

These are just some layman questions:

Please feel free to download and analyze this data as well.

Wrapping up

This data is all a side effect of @sgbloodstocksbot, so hopefully both the data and bot turn out to be useful. Please feel free to drop me a message if you’re interested in anything related to this :)


rss facebook twitter github gitlab youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora