-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* version 1.2.1 * version 1.3.0 * version 1.4.1
- Loading branch information
Showing
43 changed files
with
1,777 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: クイックスタート | ||
--- | ||
|
||
## APIを試してみる | ||
APIキーを発行せずに試してみましょう。 | ||
|
||
1. [管理ページ](https://peeace.net)にアクセスし、`平和ネットAPIを使う`をクリックしてください。<br/><br/> | ||
![](/img/top.png) | ||
|
||
2. `ログインしないで使ってみる`から簡単にAPIを試すことができます! <br/><br/> | ||
![](/img/anon-login.png) | ||
|
||
3. Playgroundページで試しましょう!<br/><br/> | ||
![](/img/playground.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions
66
apps/docs/versioned_docs/version-1.2.0/code-reference/golang.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Go | ||
|
||
```go | ||
// main.go | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
var ( | ||
apiKey = "YOUR_API_KEY" | ||
apiUrl = "https://api.peeace.net/v1/guardians/text" | ||
) | ||
|
||
func main() { | ||
// リクエストを作成 | ||
body, err := json.Marshal(map[string]string{ | ||
"text": "最低な文章", | ||
}) | ||
if err != nil { | ||
fmt.Println("Error marshalling request body:", err) | ||
return | ||
} | ||
|
||
req, err := http.NewRequest("POST", apiUrl, bytes.NewBuffer(body)) | ||
if err != nil { | ||
fmt.Println("Error creating request:", err) | ||
return | ||
} | ||
req.Header.Set("Content-Type", "application/json") | ||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey)) | ||
|
||
// リクエスト | ||
client := &http.Client{} | ||
resp, err := client.Do(req) | ||
if err != nil { | ||
fmt.Println("Error sending request:", err) | ||
return | ||
} | ||
defer resp.Body.Close() | ||
|
||
// レスポンスをチェック | ||
if resp.StatusCode != http.StatusOK { | ||
fmt.Println("Request failed with status:", resp.Status) | ||
return | ||
} | ||
|
||
var responseBody map[string]interface{} | ||
if err := json.NewDecoder(resp.Body).Decode(&responseBody); err != nil { | ||
fmt.Println("Error decoding response body:", err) | ||
return | ||
} | ||
|
||
fmt.Println("Response:", responseBody) | ||
} | ||
``` | ||
|
||
### 実行 | ||
|
||
```sh | ||
go run main.go | ||
``` |
5 changes: 5 additions & 0 deletions
5
apps/docs/versioned_docs/version-1.2.0/code-reference/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# コードリファレンス | ||
|
||
<!-- <言語名>がタイトルだと望ましい --> | ||
- [Node.js](./node-js.md) | ||
- [Go](./golang.md) |
29 changes: 29 additions & 0 deletions
29
apps/docs/versioned_docs/version-1.2.0/code-reference/node-js.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Node.js | ||
|
||
```js | ||
// 変数をセット | ||
//// YOUR_API_KEYを取得したものに変更してください | ||
const apiKey= 'YOUR_API_KEY'; | ||
|
||
const apiUrl = "https://api.peeace.net/v1/guardians/text"; | ||
const requestBody = { | ||
text: "最低な文章" | ||
}; | ||
|
||
fetch(apiUrl, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Authorization': `Bearer ${apiKey}` | ||
}, | ||
body: JSON.stringify(requestBody) | ||
}) | ||
.then(response => response.json()) | ||
.then(data => { | ||
console.log(data); | ||
}) | ||
.catch(error => { | ||
console.error('Error:', error); | ||
}); | ||
|
||
``` |
41 changes: 41 additions & 0 deletions
41
apps/docs/versioned_docs/version-1.2.0/code-reference/sdk/golang.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# SDK for Go | ||
|
||
### [GitHub Issues](https://github.com/naruse666/peace-net-sdk-go/issues) | ||
バグや機能リクエストは[Issues](https://github.com/naruse666/peace-net-sdk-go/issues)からお願いします✨ <br/> | ||
|
||
### サンプルコード | ||
```go | ||
// main.go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/naruse666/peace-net-sdk-go/guardian" | ||
"os" | ||
) | ||
|
||
func main() { | ||
apiKey, ok := os.LookupEnv("API_KEY") | ||
if !ok { | ||
fmt.Println("API_KEY is not set") | ||
return | ||
} | ||
|
||
guardianInput := guardian.GuardianInput{ | ||
Text: "最低な文章!", | ||
APIKey: apiKey, | ||
} | ||
|
||
resp, err := guardian.RequestGuardian(guardianInput) | ||
if err != nil { | ||
fmt.Println(err.Error()) | ||
return | ||
} | ||
fmt.Println(resp) | ||
} | ||
``` | ||
|
||
### 実行 | ||
```go | ||
go run main.go | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
title: よくあるエラー | ||
--- | ||
|
||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext' | ||
|
||
export const ApiName = () => { | ||
const { siteConfig } = useDocusaurusContext() | ||
return siteConfig.customFields.peace_net | ||
} | ||
|
||
# エラー | ||
|
||
<ApiName />へのリクエストを完了できない場合、エラーが返される 表示されます。エラー メッセージを解析し、適切に処理することで、 予測できます。 | ||
|
||
エラー レスポンスの形式は次のとおりです。 | ||
|
||
```json | ||
{ | ||
"error": string, | ||
"details": string, | ||
"status": 400 | 401 | 404 | 429 | 500 | 501 | ||
} | ||
``` | ||
|
||
## よくあるエラー | ||
|
||
以下に、一般的な API エラーと、次の場合に行う推奨の対応を示します。 | ||
|
||
:::info | ||
推奨される対応を行ってもエラーが解決しない場合は、 [サポートに連絡](https://github.com/TECH-C-LT/Peace-Net/issues/new)して問題を報告してください。 | ||
::: | ||
|
||
|
||
| エラーコード | 説明 | 推奨される対応 | | ||
|------------|------|--------------| | ||
| 400 Invalid Input | リクエストの形式が正しくないか、必要なパラメータが不足しています。 | リクエストのパラメータと形式を確認し、必要な情報がすべて含まれていることを確認してください。 | | ||
| 401 Unauthorized | APIキーが無効であるか、認証に失敗しました。 | APIキーが正しいことを確認し、必要に応じて新しいキーを生成してください。 | | ||
| 404 Invalid Request | リクエストされたリソースが見つかりません。 | URLとリソースIDが正しいことを確認してください。 | | ||
| 429 Usage Limit Exceeded | レート制限を超えています。 | リクエストの頻度を下げるか、より高いレート制限のプランにアップグレードすることを検討してください。 | | ||
| 500 Internal Server Error | サーバー側で予期しないエラーが発生しました。 | しばらく待ってから再試行してください。問題が続く場合はサポートに連絡してください。 | | ||
| 501 Not Implemented | リクエストされた機能が実装されていません。 | 他のエンドポイントを使用するか、サポートに問い合わせてください。 | |
89 changes: 89 additions & 0 deletions
89
apps/docs/versioned_docs/version-1.2.0/features/guardian.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
title: Guardian API | ||
--- | ||
|
||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext' | ||
|
||
export const GuardianApiName = () => { | ||
const { siteConfig } = useDocusaurusContext() | ||
return siteConfig.customFields.guardian | ||
} | ||
|
||
# <GuardianApiName /> | ||
|
||
**POST `v1/guardians/text`** | ||
|
||
## リクエスト | ||
#### ヘッダー | ||
**`accept`** string | ||
|
||
#### リクエストボディ | ||
**`text`** string **required** <br/> | ||
最大500文字までを受け付けています。 | ||
|
||
**`score_threshold`** integer optional <br/> | ||
`0-1`までの値を受け付けています。 <br /> | ||
default値は`0.5`です。 | ||
|
||
|
||
### リクエスト例 | ||
<details> | ||
<summary>cURL</summary> | ||
<pre> | ||
<code> | ||
``` | ||
curl -X POST \ | ||
--location 'https://api.peeace.net/v1/guardians/text' \ | ||
-H 'Content-Type: application/json' \ | ||
-H "Authorization: Bearer <API_KEY>" \ | ||
-d '{ | ||
"text": "<TEXT>" | ||
}' | ||
``` | ||
</code> | ||
</pre> | ||
</details> | ||
|
||
## レスポンス | ||
<details> | ||
<summary>レスポンス例</summary> | ||
|
||
status: `200` | ||
<pre> | ||
<code> | ||
``` | ||
{ | ||
"flagged": true, | ||
"categories": { | ||
"sexual": false, | ||
"hate": false, | ||
"self_harm": true, | ||
"violence": false, | ||
"defamation": true | ||
}, | ||
"category_scores": { | ||
"sexual": 0, | ||
"hate": 0, | ||
"self_harm": 0.9, | ||
"violence": 0, | ||
"defamation": 0.8 | ||
} | ||
} | ||
``` | ||
</code> | ||
</pre> | ||
</details> | ||
|
||
### レスポンスステータスコード | ||
|
||
| Status Code | Description | | ||
| ---- | ---- | | ||
| `200` | Success | | ||
| `400` | Validation | | ||
| `401` | Unauthorized | | ||
| `404` | Not Found | | ||
| `429` | Usage Limit Exceeded | | ||
| `500` | Internal Server Error | | ||
| `501` | Not Implemented Error | | ||
|
||
エラーの詳細は[よくあるエラー](/docs/errors)を参照してください。 |
Oops, something went wrong.