Learn how to deploy Rates API to Cloudflare Workers for production use.
Rates API is designed to be deployed to Cloudflare Workers, a serverless platform that offers global distribution, high performance, and excellent scalability. The API also uses Cloudflare D1 for data storage. This guide will walk you through the process of deploying your own instance of Rates API.
Before deploying, ensure you have:
First, you need to create a new Worker in your Cloudflare dashboard:
This will create a new Worker where you can deploy your code.
You’ll need to create a D1 database in your Cloudflare account:
ratesapi-data
)After creating the database, you’ll need to apply the migrations:
The project is already configured to use Wrangler, Cloudflare’s deployment tool for Workers. The configuration is in the wrangler.toml
file.
You’ll need to update some settings in this file to match your Cloudflare account:
name
field matches what you want to call your workerExample wrangler.toml
configuration with D1:
To deploy the worker, use the command:
This will build the project and deploy it to your Cloudflare Worker with the D1 database binding.
The API requires regular updates to the financial rate data. You have several options to handle this:
The repository includes a monitoring system that uses GitHub Actions to check the health of your API endpoints every 15 minutes. To set this up:
To use a custom domain for your API:
The API is configured with a 5-second cache control by default. You may want to adjust this based on your specific needs:
Consider implementing rate limiting if you expect high traffic or want to prevent abuse.
The production API redirects documentation requests to https://docs.ratesapi.nz
. Update this in the code to point to your own documentation site if needed.
Learn how to deploy Rates API to Cloudflare Workers for production use.
Rates API is designed to be deployed to Cloudflare Workers, a serverless platform that offers global distribution, high performance, and excellent scalability. The API also uses Cloudflare D1 for data storage. This guide will walk you through the process of deploying your own instance of Rates API.
Before deploying, ensure you have:
First, you need to create a new Worker in your Cloudflare dashboard:
This will create a new Worker where you can deploy your code.
You’ll need to create a D1 database in your Cloudflare account:
ratesapi-data
)After creating the database, you’ll need to apply the migrations:
The project is already configured to use Wrangler, Cloudflare’s deployment tool for Workers. The configuration is in the wrangler.toml
file.
You’ll need to update some settings in this file to match your Cloudflare account:
name
field matches what you want to call your workerExample wrangler.toml
configuration with D1:
To deploy the worker, use the command:
This will build the project and deploy it to your Cloudflare Worker with the D1 database binding.
The API requires regular updates to the financial rate data. You have several options to handle this:
The repository includes a monitoring system that uses GitHub Actions to check the health of your API endpoints every 15 minutes. To set this up:
To use a custom domain for your API:
The API is configured with a 5-second cache control by default. You may want to adjust this based on your specific needs:
Consider implementing rate limiting if you expect high traffic or want to prevent abuse.
The production API redirects documentation requests to https://docs.ratesapi.nz
. Update this in the code to point to your own documentation site if needed.