https://github.com/ghostdevv/coin-flip
https://github.com/ghostdevv/coin-flip
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/ghostdevv/coin-flip
- Owner: ghostdevv
- License: mit
- Created: 2023-09-22T17:58:33.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-22T01:04:00.000Z (over 1 year ago)
- Last Synced: 2025-02-14T02:53:54.916Z (about 1 year ago)
- Language: TypeScript
- Size: 56.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Coin Flip API
Uses random.org to generate 9 numbers between `0` and `1`, and converts that to `heads` or `tails`. It's best of nine so you need five of a side to win.
## Requesting
GET https://cf.willow.sh/
```json
{
"result": "heads",
"heads": 5,
"tails": 4,
"sequence": [
"heads",
"heads",
"heads",
"tails",
"tails",
"tails",
"heads",
"tails",
"heads"
]
}
```
```ts
type Coin = 'heads' | 'tails'
interface Response {
result: Coin;
heads: number;
tails: number;
sequence: Coin[]
}
```
## Self Hosting
You can deploy this to Cloudflare workers, all you will need is a [random.org api key](https://api.random.org/dashboard). You should set this key as the `RANDOM_API_KEY` environment variable.