Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leafyeexyz/myapis
My personal API repository
https://github.com/leafyeexyz/myapis
cloudflare-ai cloudflare-workers clouflare hono honojs huggingface javascript qweather typescript
Last synced: 28 days ago
JSON representation
My personal API repository
- Host: GitHub
- URL: https://github.com/leafyeexyz/myapis
- Owner: LeafYeeXYZ
- License: gpl-3.0
- Created: 2024-04-09T07:16:04.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-05-28T01:14:40.000Z (8 months ago)
- Last Synced: 2024-05-30T02:18:08.610Z (7 months ago)
- Topics: cloudflare-ai, cloudflare-workers, clouflare, hono, honojs, huggingface, javascript, qweather, typescript
- Language: TypeScript
- Homepage:
- Size: 130 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Introduction
My personal `Cloudflare Workers` `API` repository
## Usage
### Configure Environment Variables
Please `Fork` this repository, manually create the `wrangler.toml` file, and add the following content:
```toml
name = "api"
main = "dist/index.js"
compatibility_date = "2024-04-05"
assets = { directory = "public" }[vars]
KEY = "VALUE"
# See Environment Variables# Only used for counting visits, can be omitted
[[d1_databases]]
binding = "count"
database_name = "YOUR_D1_DATABASE_NAME"
database_id = "YOUR_D1_DATABASE_ID"# Only used for FileBox, can be omitted
[[r2_buckets]]
binding = "filebox"
bucket_name = "YOUR_BUCKET_NAME"[observability] # Optional
enabled = true # Optional
```### Environment Variables
- `CF_USER`: `Cloudflare` user `ID`, for `PainterLeaf` and `CounselorLeaf`
- `CF_AI_API_KEY`: `Cloudflare AI` `API` key, for `PainterLeaf` and `CounselorLeaf`
- `HF_API_KEY`: `Hugging Face` `API` key, for `PainterLeaf`
- `WEATHER_API_KEY`: [`qWeather`](https://dev.qweather.com/docs/api) `API` key, for `MyHomepage`
- `FILEBOX_UPLOAD_PW`: FileBox upload password, for `FileBox`
- `FILEBOX_DOWNLOAD_PW`: FileBox download password, for `FileBox`> If you don't need to use a certain feature, it's okay not to set the corresponding environment variable.
### Deployment
```bash
# Install dependencies
npm i -g bun # if you haven't installed bun yet
bun i
# Login to Cloudflare
bunx wrangler login
# Deploy
bun dep
```## API Reference
| Category | Function | Path | Method | Query Parameters | Request Body | Response |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| `PainterLeaf` | Get model list | `/painter/models` | `GET` | - | - | `application/json` |
| `PainterLeaf` | Generate image | `/painter/generate` | `POST` | - | `prompt`: prompt words
`model`: model name
If img2img: `image: Array.from(uint8Array)` | `image/png` |
| `PainterLeaf` | Translate prompt words | `/painter/translate` | `POST` | - | `text`: text
`source_lang`: source language
`target_lang`: target language | `application/json` |
| `MyHomepage` | qWeather | `/weather` | `GET` | `location`: `longitude,latitude` | - | `application/json` |
| `CounselorLeaf` | Chat | `/counselor/chat` | `POST` | - | `messages`: message list, excluding system messages | `application/json` |
| `PainterLeaf` | Generate text from image | `/painter/genprompt` | `POST` | - | `image: Array.from(uint8Array)` | `application/json` |
| `PainterLeaf` | Generate text from image
with `llama3.2 vision` | `/painter/genprompt/v4` | `POST` | - | `image: Array.from(uint8Array)` | `application/json` |
| `Others` | Count visits | `/count` | `GET` | - | - | `text/javascript` |
| `Others` | Count visits | `/count` | `POST` | - | `hostname`: domain name
`unique`: whether to count as unique visitors | `application/json` |
| `FileBox` | Upload file | `/filebox/upload` | `POST` | - | `key`: pickup code
`filename`: file name
`password`: upload password
`file`: base64 encoded file | `application/json` |
| `FileBox` | Download file | `/filebox/download` | `POST` | - | `key`: pickup code
`password`: download password
`shouldDelete`: whether to delete the file
`filetype`: `file` or `text` | `application/json` |
| `Others` | Return my avatar | `/avatar.jpg` | `GET` | - | - | `image/jpeg` |