Spaces:
Sleeping
Sleeping
File size: 1,389 Bytes
12e8a63 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | ---
title: Sentiment Analysis API
emoji: 🎭
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
---
# Sentiment Analysis API
This Space provides a REST API for sentiment analysis using a fine-tuned transformer model.
## API Endpoints
- `GET /` - API information
- `GET /health` - Health check
- `POST /predict` - Analyze sentiment
- `GET /docs` - Interactive API documentation (Swagger UI)
## Usage Example
```bash
curl -X POST "https://YOUR-USERNAME-sentiment-api.hf.space/predict" \
-H "Content-Type: application/json" \
-d '{"text": "I love this product!"}'
```
Response:
```json
{
"sentiment": "positive",
"confidence": 0.9234
}
```
## Model
This API uses a sentiment classification model trained on [describe your dataset].
Model repository: [link to your model repo]
## Integration
You can call this API from any application:
```javascript
// JavaScript/TypeScript
fetch('https://YOUR-USERNAME-sentiment-api.hf.space/predict', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({text: 'Hello world'})
})
.then(r => r.json())
.then(data => console.log(data));
```
```python
# Python
import requests
response = requests.post(
'https://YOUR-USERNAME-sentiment-api.hf.space/predict',
json={'text': 'Hello world'}
)
print(response.json())
```
|