This is a write-up of a small data collector: a Cloudflare Worker on an hourly cron that reads settled funding rates from the public APIs of OKX, Bybit and MEXC and stores them in D1. The code is about 100 lines. Most of the time went into two things that are not in any quick-start: the three APIs disagree on almost every field name, and two of them answered 403 from the Worker while answering 200 from a laptop.
What is being collected
Perpetual futures have a funding rate: a periodic payment between longs and shorts, usually settled every 8 hours. Each exchange publishes a predicted rate that changes until settlement, and a settled rate that is final.…