Skip to content

Commit cb8706c

Browse files
Merge pull request #18 from SinSo-API/dev
cleaning the mess
2 parents 6655ba1 + 8a839b5 commit cb8706c

9 files changed

Lines changed: 343 additions & 1966 deletions

File tree

README.md

Lines changed: 311 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,312 @@
11
# SinSo API Lite
2-
> Under Construction
2+
3+
A lightweight Sinhala song lyrics API built with [Hono.js](https://hono.dev/) and deployed on Cloudflare Workers. This API allows users to search for Sinhala songs, artists, lyrics, and submit song suggestions for community contribution.
4+
5+
## Features
6+
7+
- **Songs & Artists** - Browse and search Sinhala songs and artists
8+
- **Lyrics** - Get complete song lyrics by ID
9+
- **Search** - Powerful search functionality across songs
10+
- **User Suggestions** - Community-driven song submissions
11+
- **Admin Panel** - Manage and moderate song suggestions
12+
- **API Documentation** - Interactive Swagger UI
13+
- **Fast & Scalable** - Built on Cloudflare Workers edge network
14+
15+
---
16+
17+
## API Endpoints
18+
19+
Base URL: `https://sinso.vishalrashmika.com/api/v1`
20+
21+
### Songs
22+
23+
| Method | Endpoint | Description | Auth Required |
24+
|--------|----------|-------------|---------------|
25+
| `GET` | `/songs` | Get all songs | No |
26+
| `GET` | `/songs/:id` | Get song by ID | No |
27+
| `GET` | `/songs/health` | Health check | No |
28+
29+
**Example:**
30+
```bash
31+
GET /api/v1/songs
32+
GET /api/v1/songs/123
33+
```
34+
35+
---
36+
37+
### Artists
38+
39+
| Method | Endpoint | Description | Auth Required |
40+
|--------|----------|-------------|---------------|
41+
| `GET` | `/artists` | Get all artists | No |
42+
| `GET` | `/artists/:id` | Get artist by ID | No |
43+
| `GET` | `/artists/health` | Health check | No |
44+
45+
**Example:**
46+
```bash
47+
GET /api/v1/artists
48+
GET /api/v1/artists/456
49+
```
50+
51+
---
52+
53+
### Lyrics
54+
55+
| Method | Endpoint | Description | Auth Required |
56+
|--------|----------|-------------|---------------|
57+
| `GET` | `/lyrics/:id` | Get lyrics by ID | No |
58+
| `GET` | `/lyrics/health` | Health check | No |
59+
60+
**Example:**
61+
```bash
62+
GET /api/v1/lyrics/789
63+
```
64+
65+
---
66+
67+
### Search
68+
69+
| Method | Endpoint | Description | Auth Required |
70+
|--------|----------|-------------|---------------|
71+
| `GET` | `/search?q={query}` | Search songs by title/artist | No |
72+
| `GET` | `/search/health` | Health check | No |
73+
74+
**Example:**
75+
```bash
76+
GET /api/v1/search?q=සඳ
77+
```
78+
79+
---
80+
81+
### Suggestions (Public)
82+
83+
| Method | Endpoint | Description | Auth Required |
84+
|--------|----------|-------------|---------------|
85+
| `POST` | `/suggestions` | Submit a new song suggestion | No |
86+
| `GET` | `/suggestions/:id/status` | Check suggestion status | No |
87+
| `GET` | `/suggestions/health` | Health check | No |
88+
89+
**Required Fields:**
90+
- **Song Name** * - Song name in English
91+
- **Song Name (Sinhala)** * - Song name in Sinhala unicode only
92+
- **Artist Name** * - Artist name in English
93+
- **Artist Name (Sinhala)** * - Artist name in Sinhala unicode only
94+
- **Lyrics** * - Song lyrics in English/transliteration
95+
- **Lyrics (Sinhala)** * - Song lyrics in Sinhala unicode only
96+
97+
**Optional Fields:**
98+
- **Duration** - Duration in seconds
99+
- **Release Year** - Year the song was released
100+
- **Composer** - Name of the composer
101+
- **Lyricist** - Name of the lyricist
102+
103+
**Submit Suggestion Example:**
104+
```bash
105+
POST /api/v1/suggestions
106+
Content-Type: application/json
107+
108+
{
109+
"title": "Sanda Tharu Mal",
110+
"title_sinhala": "සඳ තරු මල්",
111+
"artist": "Nanda Malani",
112+
"artist_sinhala": "නන්දා මාලනී",
113+
"lyrics": "Mal mal mal pipenne\nTharu tharu ahase",
114+
"lyrics_sinhala": "මල් මල් මල් පිපෙන්නේ\nතරු තරු අහසේ",
115+
"duration": 240,
116+
"year": 2020,
117+
"composer": "Composer Name",
118+
"lyricist": "Lyricist Name"
119+
}
120+
```
121+
122+
**Response:**
123+
```json
124+
{
125+
"status": 201,
126+
"code": "SUGGESTION_CREATED",
127+
"message": "Song suggestion submitted successfully",
128+
"data": {
129+
"suggestion_id": 1,
130+
"title": "Sanda Tharu Mal",
131+
"artist": "Nanda Malani",
132+
"status": "pending"
133+
}
134+
}
135+
```
136+
137+
---
138+
139+
### Admin (Requires Authorization)
140+
141+
All admin endpoints require `Authorization: Bearer YOUR_ADMIN_API_KEY` header.
142+
143+
| Method | Endpoint | Description | Auth Required |
144+
|--------|----------|-------------|---------------|
145+
| `GET` | `/admin/suggestions?status={pending\|approved\|rejected}` | Get suggestions by status | Yes |
146+
| `GET` | `/admin/suggestions/:id` | Get specific suggestion | Yes |
147+
| `POST` | `/admin/suggestions/:id/approve` | Approve suggestion | Yes |
148+
| `POST` | `/admin/suggestions/:id/reject` | Reject suggestion with reason | Yes |
149+
| `DELETE` | `/admin/suggestions/:id` | Delete suggestion permanently | Yes |
150+
| `GET` | `/admin/stats` | Get admin statistics | Yes |
151+
| `GET` | `/admin/health` | Health check | Yes |
152+
153+
**Approve Suggestion:**
154+
```bash
155+
POST /api/v1/admin/suggestions/1/approve
156+
Authorization: Bearer YOUR_ADMIN_API_KEY
157+
```
158+
159+
**Reject Suggestion:**
160+
```bash
161+
POST /api/v1/admin/suggestions/1/reject
162+
Authorization: Bearer YOUR_ADMIN_API_KEY
163+
Content-Type: application/json
164+
165+
{
166+
"reason": "Lyrics are incomplete or incorrect"
167+
}
168+
```
169+
170+
**Get Statistics:**
171+
```bash
172+
GET /api/v1/admin/stats
173+
Authorization: Bearer YOUR_ADMIN_API_KEY
174+
```
175+
176+
---
177+
178+
## Documentation
179+
180+
- **Swagger UI**: `/docs`
181+
- **OpenAPI Spec**: `/docs/openapi.json`
182+
- **API Root**: `/` (Shows all available endpoints)
183+
- **Health Check**: `/health`
184+
185+
---
186+
187+
### Tech Stack
188+
189+
- **Framework**: [Hono.js](https://hono.dev/) - Ultra-fast web framework
190+
- **Runtime**: Cloudflare Workers
191+
- **Database**: Cloudflare D1 (SQLite)
192+
- **ORM**: Drizzle ORM
193+
- **Language**: TypeScript
194+
- **API Docs**: Swagger UI / OpenAPI 3.0
195+
196+
---
197+
198+
## API Response Format
199+
200+
All API responses follow a consistent format:
201+
202+
**Success Response:**
203+
```json
204+
{
205+
"status": 200,
206+
"code": "SUCCESS",
207+
"data": { ... },
208+
"timestamp": "2026-01-04T12:00:00"
209+
}
210+
```
211+
212+
**Error Response:**
213+
```json
214+
{
215+
"status": 400,
216+
"code": "VALIDATION_ERROR",
217+
"message": "Invalid request",
218+
"details": "Detailed error message",
219+
"path": "/api/v1/endpoint",
220+
"timestamp": "2026-01-04T12:00:00"
221+
}
222+
```
223+
224+
---
225+
226+
## Testing
227+
228+
### Test User Submission Flow
229+
230+
**1. Submit a suggestion:**
231+
```bash
232+
curl -X POST http://localhost:8787/api/v1/suggestions \
233+
-H "Content-Type: application/json" \
234+
-d '{
235+
"title": "Test Song",
236+
"artist": "Test Artist",
237+
"lyrics": "Test lyrics content here..."
238+
}'
239+
```
240+
241+
**2. Check status (note the ID from step 1):**
242+
```bash
243+
curl http://localhost:8787/api/v1/suggestions/1/status
244+
```
245+
246+
**3. Admin: View pending suggestions:**
247+
```bash
248+
curl http://localhost:8787/api/v1/admin/suggestions?status=pending \
249+
-H "Authorization: Bearer YOUR_ADMIN_API_KEY"
250+
```
251+
252+
**4. Admin: Approve or reject:**
253+
```bash
254+
curl -X POST http://localhost:8787/api/v1/admin/suggestions/1/approve \
255+
-H "Authorization: Bearer YOUR_ADMIN_API_KEY"
256+
```
257+
258+
---
259+
260+
## Security
261+
262+
- Admin endpoints are protected with API key authentication
263+
- CORS enabled for cross-origin requests
264+
- Input validation on all endpoints
265+
- SQL injection protection via parameterized queries
266+
267+
---
268+
269+
## License
270+
271+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
272+
273+
---
274+
275+
## Contributing
276+
277+
Contributions are welcome! Feel free to:
278+
1. Submit song suggestions via the API
279+
2. Report bugs or issues
280+
3. Submit pull requests
281+
282+
---
283+
284+
## Contact
285+
286+
For questions or support, please open an issue on GitHub.
287+
288+
---
289+
290+
## Lyrics Copyright & Legal Notice
291+
292+
**Important:** All song lyrics provided through this API are the intellectual property of their respective artists, composers, lyricists, and music publishers. SinSo-API does not claim ownership of any lyrical content.
293+
294+
### Copyright Information
295+
296+
- All copyrights belong to the original artists and creators
297+
- Lyrics are provided for educational, research, and non-commercial purposes
298+
- Commercial use of lyrics may require proper licensing from copyright holders
299+
- Users are responsible for ensuring compliance with applicable copyright laws
300+
301+
### Usage Guidelines
302+
303+
- Please respect the intellectual property rights of artists and creators
304+
- Consider this API as a tool for promoting Sinhala music and culture
305+
- For commercial applications, seek appropriate permissions from copyright owners
306+
- Give proper attribution to artists when displaying lyrics
307+
308+
**Disclaimer:** SinSo-API serves as a platform to make Sinhala lyrics more accessible while respecting the creative rights of all artists and music industry stakeholders.
309+
310+
---
311+
312+
**Made with love for the Sinhala music community**

0 commit comments

Comments
 (0)