This API provides endpoints for interacting with two main tables: faucet.solana_balances
and faucet.rate_limits
. Below are the available endpoints for each table.
-
Clone the repository
git clone <repository-url>
-
Install dependencies
yarn install
-
Set up your
.env
file with the followingPOSTGRES_STRING=postgresql://<user>:<password>@<host>:<port>/<database> PROJECT_ID=<GCP Project ID>
-
Start the server
yarn start
-
Access the API at
http://localhost:3000/api
.
POST /api/solana-balances
- Description: Adds a new Solana account balance.
- Request Body:
{ "account": "string", "balance": "number" }
- Curl Command:
curl -v -X POST http://localhost:3000/api/solana-balances \ -H "Content-Type: application/json" \ -d '{"account": "test_account_1", "balance": 100.50}'
- Response:
{ "id": 1, "account": "string", "balance": "number", "date": "timestamp" }
GET /api/solana-balances/account/:account
- Description: Retrieves all balances for a specific Solana account.
- Curl Command:
curl -v http://localhost:3000/api/solana-balances/account/test_account_1
- Response:
[ { "id": 1, "account": "string", "balance": "number", "date": "timestamp" }, ... ]
GET /api/solana-balances/recent
- Description: Retrieves all Solana account balances from the past month, ordered by date.
- Curl Command:
curl -v http://localhost:3000/api/solana-balances/recent
- Response:
[ { "account": "string", "balance": "number", "date": "timestamp" }, ... ]
POST /api/rate-limits
- Description: Adds a new rate limit entry.
- Request Body:
{ "key": "string", "timestamps": ["number"] }
- Curl Command:
curl -v -X POST http://localhost:3000/api/rate-limits \ -H "Content-Type: application/json" \ -d '{"key": "test_key_1", "timestamps": [1635793421]}'
- Response:
{ "key": "string", "timestamps": ["number"] }
GET /api/rate-limits/:key
- Description: Retrieves the rate limit entry for a specific key.
- Curl Command:
curl -v http://localhost:3000/api/rate-limits/test_key_1
- Response:
{ "key": "string", "timestamps": ["number"] }
PUT /api/rate-limits/:key
- Description: Updates the timestamps for a specific rate limit key.
- Request Body:
{ "timestamps": ["number"] }
- Curl Command:
curl -v -X PUT http://localhost:3000/api/rate-limits/test_key_1 \ -H "Content-Type: application/json" \ -d '{"timestamps": [1635793500]}'
- Response:
{ "key": "string", "timestamps": ["number"] }
All endpoints return appropriate HTTP status codes:
201 Created
for successful creations.200 OK
for successful data retrieval or updates.404 Not Found
if the requested resource does not exist.500 Internal Server Error
for unhandled exceptions.