This is my second open source Android app published on F-Droid. I wouldn’t say that the publishing process was smooth since some F-Droid maintainers are biased against Bitcoin, but the app is now published and everything seems to be fine. It feels good to be able to avoid Google Play and still reach a pretty large audience.
My initial plan was to use Overpass API as a backend, but it looks like Overpass usually needs a few minutes to return all bitcoin-accepting places.
There are two most obvious ways to solve this issue:
- Bundle the data with the app
- Set up a fast cache and place it between Android client and Overpass API
I ended up combining both of those options and adding some GitHub magic on top of that. Here is how it works:
- I’ve set up a public GitHub repository at: https://github.com/bubelov/btcmap-data
- This repository has
data.jsonin its root directory
- The sole purpose of
query.txtis to explain what we need from Overpass API, namely:
[out:json][timeout:300]; ( node["currency:XBT"="yes"]; way["currency:XBT"="yes"]; relation["currency:XBT"="yes"]; node["currency:BTC"="yes"]; way["currency:BTC"="yes"]; relation["currency:BTC"="yes"]; node["payment:bitcoin"="yes"]; way["payment:bitcoin"="yes"]; relation["payment:bitcoin"="yes"]; ); out meta geom;
- The latest Overpass response should be saved to
- Here is how you can populate or update the data repository:
curl -X POST -d "@query.txt" -o data.json https://overpass-api.de/api/interpreter
- Regular updates can be done automatically with the help of GitHub Actions: https://github.com/bubelov/btcmap-data/blob/main/.github/workflows/refresh-data.yml
- Now we have a self-contained and self-updating repository which caches OSM responses and you can even use it as a backend
- I’d like to avoid making GitHub angry, so I’ve set up a Nginx caching proxy on
btcmap.orgwhich is supposed to take most of the traffic
This process is pretty simple, transparent and auditable. All you might need is a webserver and curl and both of those programs are available out of the box in most Linux distributions.