# APIリファレンス
## サーバ側完成形コードのリポジトリ
- [https://github.com/taroosg/laratter-test](https://github.com/taroosg/laratter-test)
### 基本情報
- **ベースURL**: `http://localhost/api`
## 認証
- **認証方法**: Bearer Token
- **トークン取得**: ユーザ登録またはログイン時にトークンを取得
## エンドポイント
### ユーザ登録
- **URL**: `/register`
- **メソッド**: POST
- **パラメータ**:
- `name`: ユーザ名
- `email`: メールアドレス
- `password`: パスワード
- **レスポンス**:
```json
{
"access_token": "your-access-token",
"token_type": "Bearer"
}
```
### ユーザログイン
- **URL**: `/login`
- **メソッド**: POST
- **パラメータ**:
- `email`: メールアドレス
- `password`: パスワード
- **レスポンス**:
```json
{
"access_token": "your-access-token",
"token_type": "Bearer"
}
```
### ユーザログアウト
- **URL**: `/logout`
- **メソッド**: POST
- **認証**: 必要
- **レスポンス**:
```json
{
"message": "Successfully logged out"
}
```
### Tweetの作成
- **URL**: `/tweets`
- **メソッド**: POST
- **認証**: 必要
- **パラメータ**:
- `tweet`: Tweet内容
- **レスポンス**:
```json
{
"id": 1,
"tweet": "Test tweet",
"user_id": 1,
"created_at": "2021-01-01T00:00:00.000000Z",
"updated_at": "2021-01-01T00:00:00.000000Z"
}
```
### Tweetの一覧取得
- **URL**: `/tweets`
- **メソッド**: GET
- **認証**: 必要
- **レスポンス**:
```json
[
{
"id": 1,
"tweet": "Test tweet",
"user_id": 1,
"created_at": "2021-01-01T00:00:00.000000Z",
"updated_at": "2021-01-01T00:00:00.000000Z"
},
// 他のTweet
]
```
### Tweetの詳細取得
- **URL**: `/tweets/{id}`
- **メソッド**: GET
- **認証**: 必要
- **レスポンス**:
```json
{
"id": 1,
"tweet": "Test tweet",
"user_id": 1,
"created_at": "2021-01-01T00:00:00.000000Z",
"updated_at": "2021-01-01T00:00:00.000000Z"
}
```
### Tweetの更新
- **URL**: `/tweets/{id}`
- **メソッド**: PUT
- **認証**: 必要
- **パラメータ**:
- `tweet`: 新しいTweet内容
- **レスポンス**:
```json
{
"id": 1,
"tweet": "Updated tweet content",
"user_id": 1,
"created_at": "2021-01-01T00:00:00.000000Z",
"updated_at": "2021-01-01T00:00:00.000000Z"
}
```
### Tweetの削除
- **URL**: `/tweets/{id}`
- **メソッド**: DELETE
- **認証**: 必要
- **レスポンス**:
```json
{
"message": "Tweet deleted successfully"
}
```
### Tweetのlike
- **URL**: `/tweets/{id}/like`
- **メソッド**: POST
- **認証**: 必要
- **レスポンス**:
```json
{
"message": "Tweet liked successfully"
}
```
### Tweetのdislike
- **URL**: `/tweets/{id}/like`
- **メソッド**: DELETE
- **認証**: 必要
- **レスポンス**:
```json
{
"message": "Tweet disliked successfully"
}
```