ライトパス 翻訳API (PHP, Java)

ご紹介

当社のAPIをすぐ簡単に始めるには、以下のクラスを使用するか Github (PHP, Java)よりダウンロードしてください。 (PHP, Java)よりダウンロードしてください。 これによって権限付与、JSONエンコーディング&デコーディング及びいくつかの便利な機能をご利用いただけます。

APIキーを取得する場合は こちらからサインアップ。 そしてアカウントの設定セクションにてAPIキーを依頼してください。

当社はJSON使用しています。全てのレスポンスは以下のとおりになります。
                    {
                        "response": {

                        },
                        "opStatus": "ok"
                        }
                
何か異常が起きた場合、レスポンスは以下のようになります。
                {
                    "response": {
                    "errorCode": "4001",
                    "errorMessage": "Something has gone wrong"
                    },
                    "opStatus": "error"
                    }
                
ご自分のアプリで エラーコード によってエラーを特定することが可能です。

メソッド

クライアント様がライトパスの翻訳APIを使って実行可能な作業について、以下の資料を用いてご説明いたします。


普通のテキストのワード数計算(POST)

概要
テキスト文字列の語数を計算してもらいます。テキストに基本のHTMLタグが含まれる場合、それらはワード数として計上されません。
URL
https://www.writepath.co/api/wordcount
認証
必須

パラメーター

api_key 必須 あなたのパブリックAPIキー
private_key 必須 あなたのプライベートAPIキー
service 必須 ご利用のサービス: 1 = 編集; 2 = 翻訳のみ; 4 =プレミアム翻訳 (翻訳 + 編集)
langID 必須 翻訳/編集する言語のID。 こちらをクリックして取り扱う言語の一覧をご覧ください。.
text 必須 翻訳または編集してもらいたいテキスト。HTMLタグが含まれる場合、それらはワード数として計上されません。

使用例

                    include 'WritepathClient.php';

$api_key = '12345678';
$private_key = 'ABCDEFGH';

$service = '2'; // i.e. Standard Translation
$langID = '5'; // i.e. English - Chinese (Simplified)
$text = 'My very long text';

$WritepathClient = new WritepathClient($api_key, $private_key);
$reply = $WritepathClient->getWordCountPlainText($service, $langID, $text);

レスポンス

                {
                "response": {
                "wordCount": "710"
                },
                "opStatus": "ok"
                }
                

ドキュメントのワード数計算 (POST)

概要
ドキュメント(.docx, .pptx, .xlsx)にあるテキストのワード数を計算してもらいます。テキストに基本のHTMLタグが含まれる場合、それらはワード数として計上されません。
URL
https://www.writepath.co/api/wordcount
認証
必須

パラメーター

api_key 必須 あなたのパブリックAPIキー
private_key 必須 あなたのプライベートAPIキー
service 必須 ご利用のサービス: 1 = 編集; 2 = 翻訳のみ; 4 =プレミアム翻訳 (翻訳 + 編集)
langID 必須 翻訳/編集する言語のID。 こちらをクリックして取り扱う言語の一覧をご覧ください。.
filename 必須 保存場所 + ドキュメントのファイル名(.docx, .pptx, .xlsxのみ)
                    include 'WritepathClient.php';

$api_key = '12345678';
$private_key = 'ABCDEFGH';

$service = '2'; // i.e. Standard Translation
$langID = '5'; // i.e. English - Chinese (Simplified)
$filename = 'c:/mydoc.docx';

$WritepathClient = new WritepathClient($api_key, $private_key);
$reply = $WritepathClient->getWordCountDocument($service, $langID, $filename);

レスポンス

                {
                "response": {
                "wordCount": "710"
                },
                "opStatus": "ok"
                }
                

テキスト形式の案件を載せる (POST)

概要
このサービスにテキスト形式の文書を案件として送付してください。計上されたワード数がアカウントより差し引かると同時に、その案件は当該専門分野に精通した翻訳者/編集者に届きます。 (ワード数計算機能を使う) 案件を載せる前に御見積りが必要な場合、普通のテキストでてワード数計算機能をお使いください。
URL
https://www.writepath.co/api/job
認証
必須

パラメーター

api_key 必須 あなたのパブリックAPIキー
private_key 必須 あなたのプライベートAPIキー
service 必須 ご利用のサービス: 1 = 編集; 2 = 翻訳のみ; 4 =プレミアム翻訳 (翻訳 + 編集)
langID 必須 翻訳/編集する言語のID。 こちらをクリックして取り扱う言語の一覧をご覧ください。.
category 必須 本テキストのカテゴリ/トピック。 こちらをクリックして取り扱うカテゴリの一覧をご覧ください。.
text 必須 翻訳または編集してもらいたいテキスト。HTMLタグが含まれる場合、それらはワード数として計上されません。
instructions オプション 翻訳者/編集者へのご指示。
notify_url オプション 案件が完成されたら、当該URLにRESTの掲載をお知らせします。

使用例

                    include 'WritepathClient.php';

$api_key = '12345678';
$private_key = 'ABCDEFGH';

$service = '2'; // i.e. Standard Translation
$langID = '5'; // i.e. English - Chinese (Simplified)
$category = '3'; // i.e. Technology
$text = 'My very long text';
$instructions = 'here are my instructions';
$notify_url = 'http://www.mydomain.com/notify_me.php';

$WritepathClient = new WritepathClient($api_key, $private_key);
$reply = $WritepathClient->sendPlainText($service, $langID, $category, $text, $instructions, $notify_url);

レスポンス

                {
                "response": {
                "wordsUsed": "710",
                "orderId": "411"
                },
                "opStatus": "ok"
                }
                

ドキュメントの案件を載せる (POST)

概要 
このサービスに添付ファイルを案件として送付してください。対応可能なファイル種類、docx, .xlsx, .pptx。計上されたワード数がアカウントより差し引かると同時に、その案件は当該専門分野に精通した翻訳者/編集者のに届きます。案件を載せる前に御見積りが必要な場合、ドキュメントに対してワード数計算という機能をお使いください。 対応可能なファイル種類:.docx, .xlsx, .pptx。Supported file types: .docx, .xlsx, .pptx. 計上されたワード数がアカウントより差し引かると同時に、その案件は当該専門分野に精通した翻訳者/編集者のところに届きます。 (ワード数計算機能を使う) 案件を載せる前に御見積りが必要な場合、ドキュメントに対してワード数計算機能をお使いください。
URL
https://www.writepath.co/api/job
認証
必須

パラメーター

api_key 必須 あなたのパブリックAPIキー
private_key 必須 あなたのプライベートAPIキー
service 必須 ご利用のサービス: 1 = 編集; 2 = 翻訳のみ; 4 =プレミアム翻訳 (翻訳 + 編集)
langID 必須 翻訳/編集する言語のID。 こちらをクリックして取り扱う言語の一覧をご覧ください。.
category 必須 本テキストのカテゴリ/トピック。 こちらをクリックして取り扱うカテゴリの一覧をご覧ください。.
filename 必須 保存場所 + ドキュメントのファイル名(.docx, .pptx, .xlsxのみ)
instructions オプション 翻訳者/編集者へのご指示。
notify_url オプション 案件が完成されたら、当該URLにRESTの掲載をお知らせします。

使用例

                    include 'WritepathClient.php';

$api_key = '12345678';
$private_key = 'ABCDEFGH';

$service = '2'; // i.e. Standard Translation
$langID = '5'; // i.e. English - Chinese (Simplified)
$category = '3'; // i.e. Technology
$filename = 'c:/mydoc.docx';
$instructions = 'here are my instructions';
$notify_url = 'http://www.mydomain.com/notify_me.php';

$WritepathClient = new WritepathClient($api_key, $private_key);
$reply = $WritepathClient->sendDocument($service, $langID, $category, $filename, $instructions, $notify_url);

レスポンス

                    {
                    "response": {
                    "wordsUsed": "710",
                    "orderId": "411"
                    },
                    "opStatus": "ok"
                    }
                

案件の進捗を把握する (GET)

概要
特定の案件を訂正します。
URL
https://www.writepath.co/api/job/{id}
認証
必須

パラメーター

api_key 必須 あなたのパブリックAPIキー
private_key 必須 あなたのプライベートAPIキー
id 必須 把握したい案件のID。案件を載せた後、あなた宛に発行されたオーダーIDのこと。
format 必須 納品する内容のフォーマット。 1 = ファイル; 2 = テキスト形式

使用例

                    include 'WritepathClient.php';

$api_key = '12345678';
$private_key = 'ABCDEFGH';

$id = '379';
$format = '1';

$WritepathClient = new WritepathClient($api_key, $private_key);
$reply = $WritepathClient->getStatus($id, $format);

レスポンス (document)

                    {
                    "response": {
                    "wordsUsed": "710",
                    "status": "finished",
                    "dueDate": "1384570722",
                    "wordsBalance": "532",
                    "commentFinished": "",
                    "document": "A4BDLP0..." (base64)
                    },
                    "opStatus": "ok"
                    }
                

レスポンス (plain text)

                    {
                    "response": {
                    "wordsUsed": "710",
                    "status": "finished",
                    "dueDate": "1384570722",
                    "wordsBalance": "532",
                    "commentFinished": "",
                    "document": "this is the translated text"
                    },
                    "opStatus": "ok"
                    }
                

ステータスに対して設定可能な値は「working」と「finished」です。「commentFinished」と「document」は作業が終わると設定される値です。また、「document」はBASE64エンコードのマイクロソフトのワードドキュメントとして編集済みのドキュメントを含みます。


ワードクレジットのご利用残高を確認する (POST)

概要
現在のワード数のご利用残高を確認します。
URL
https://www.writepath.co/api/balance
認証
必須

パラメーター

api_key 必須 あなたのパブリックAPIキー
private_key 必須 あなたのプライベートAPIキー

使用例

                    include 'WritepathClient.php';

$api_key = '12345678';
$private_key = 'ABCDEFGH';

$WritepathClient = new WritepathClient($api_key, $private_key);
$reply = $WritepathClient->getWordBalance();

レスポンス

                    {
                    "response": {
                    "wordsBalance": "522"
                    },
                    "opStatus": "ok"
                    }
                

コメントを掲載する (POST)

概要
案件に対してコメントを掲載します。
URL
https://www.writepath.co/api/jobs/{id}/comment
認証
必須

パラメーター

api_key 必須 あなたのパブリックAPI キー
private_key 必須 あなたのプライベートAPI キー
id 必須 コメントを掲載したい案件のID (= オーダーId)

使用例

                    include 'WritepathClient.php';

$api_key = '12345678';
$private_key = 'ABCDEFGH';

$WritepathClient = new WritepathClient($api_key, $private_key);
$reply = $WritepathClient->postComment(379,'this is a comment for job #379');

レスポンス

                    {
                    "response": {
                    },
                    "opStatus": "ok"
                    }
                

プレーンテキストの仕事を複数載せる(POST)

概要
プレーンテキストの仕事を複数サービスにサービスに送る。計算されたワード数がお客様のアカウントから差し引かれ、案件をお客様の仕事のカテゴリーにマッチする翻訳者/編集者が利用できるようにします。仕事を掲載する前にお見積もりをお要望の場合、プレーンテキストのワード数をまず出す、をお使い下さい。
URL
https://www.writepath.co/api/bjobs
認証
必須

パラメーター

api_key 必須 あなたのパブリックAPIキー
private_key 必須 あなたのプライベートAPIキー
service 必須 ご利用のサービス: 1 = 編集; 2 = 翻訳のみ; 4 =プレミアム翻訳 (翻訳 + 編集)
langID 必須 翻訳/編集する言語のID。 こちらをクリックして取り扱う言語の一覧をご覧ください。.
category 必須 本テキストのカテゴリ/トピック。 こちらをクリックして取り扱うカテゴリの一覧をご覧ください。.
text 必須 翻訳または編集したいテキストの配列 (List) HTMLタグを含められます。これらはワードとしてカウントされません
instructions オプション 翻訳者/編集者へのご指示。
notify_url オプション 案件が完成されたら、当該URLにRESTの掲載をお知らせします。
                    include 'WritepathClient.php';

$api_key = '12345678';
$private_key = 'ABCDEFGH';

$service = '2'; // i.e. Standard Translation
$langID = '6'; // i.e. English - Chinese (Traditional)
$category = '3'; // i.e. Technology
$text = {'My very long text','My very long another text'};
$instructions = 'here are my instructions';
$notify_url = 'http://www.mydomain.com/notify_me.php';

$WritepathClient = new WritepathClient($api_key, $private_key);
$reply = $WritepathClient->sendPlainText($service, $langID, $category, $text, $instructions, $notify_url);

レスポンス

                {"batchId":"31","response":[{"wordsUsed":"250","orderId":"40184"},{"wordsUsed":"3","orderId":"40186"}],"opStatus":"ok"}
                

載せた複数の仕事の状況を一括で引き出す (GET)

概要
特定の案件を訂正します。
URL
https://www.writepath.co/api/bjob/{id}
認証
必須

パラメーター

api_key 必須 あなたのパブリックAPIキー
private_key 必須 あなたのプライベートAPIキー
id 必須 把握したい案件のID。案件を載せた後、あなた宛に発行されたオーダーIDのこと。
format 必須 戻った戻ったコンテンツのフォーマット。. 1 = ファイルとして、 2 =プレーンテキストとして。1はまだサポートしていない為、本バージョンでは 2のみ御利用下さい。

使用例

                    include 'WritepathClient.php';

$api_key = '12345678';
$private_key = 'ABCDEFGH';

$id = '31';
$format = '2';

$WritepathClient = new WritepathClient($api_key, $private_key);
$reply = $WritepathClient->getBatchedStatus($id, $format);

レスポンス (document)

                    {"batchId":31,"response":[{"wordsUsed":"250","status":"working","dueDate":"1487402914","wordsBalance":"1000","commentFinished":null,"document":null},{"wordsUsed":"3","status":"finished","dueDate":"1487402914","wordsBalance":"1000","commentFinished":"test","document":"this is the translated text"}],"opStatus":"ok"}
                

レスポンス (plain text)

                    {
                    "response": {
                    "wordsUsed": "710",
                    "status": "finished",
                    "dueDate": "1384570722",
                    "wordsBalance": "532",
                    "commentFinished": "",
                    "document": "this is the translated text"
                    },
                    "opStatus": "ok"
                    }
                

ステータスに対して設定可能な値は「working」と「finished」です。「commentFinished」と「document」は作業が終わると設定される値です。また、「document」はBASE64エンコードのマイクロソフトのワードドキュメントとして編集済みのドキュメントを含みます。


コールバック

コールバックとはあなたの通知用URL(案件を載せるとき、または普通のテキストを載せるメソッドを使うことで指定した場所)に送られてくる自動通知です。コールバックは以下のことが発生する度に送付されることになります。


案件が完成されたときにコールバックします (POST)

コールバックの結果 (document / plain text)

                    {
                    "response": {
                    "orderId": "2345",
                    "wordsUsed": "764",
                    "status": "finished",
                    "dueDate": "1405747052",
                    "commentFinished": null,
                    "A4BDLP0..." (base64)
                    },
                    "opStatus": "ok"
                    }
                

翻訳者または編集者がコメントを掲載したときにコールバックします (POST)

コールバックの結果

                    {
                    "response": {
                    "orderId": "2345",
                    "comment": "this is my comment",
                    "date": 1405561885
                    },
                    "opStatus": "ok"
                    }
                

エラーコード

現在使用されているエラーコードが以下の通りです。エラーメッセージを解明したい場合、コード番号を使ってメッセージを特定してください。

エラーコード エラーメッセージ
1000Authentication failed
1100api_key is a required field
1150private_key is a required field
1200ts - timestamp is a required field
1201ts - timestamp must be numeric
1250data is a required field
1251JSON data cannot be decoded
1252type is a required field and can only be 1 or 2
1800job is a required field
1801comment is a required field
1802file upload failed (did you check that the file is correct and the extension supported?)
1803Wrong file type
1804Wrong job id
1805No words in document
1806No words in plain text
1807Can't write to file
1808File too big. Max. 15MB allowed
2700Not enough word credits - please top up
3000body or document - only one field can be set
3001Neither body nor document are set - set one
3002Service type, language ID and category must be provided
3003Wrong category
3004Wrong service
3005Wrong language ID
3006Service and language ID do not match
3007Copy writing service not supported in API
3008all parameters are requested
3009need filename with document
3010need array of text
4000Can not add comment: job has not been claimed yet
4001Job unknown: check id
4002No result
4003API format doesn't match with your upload format (1=file, 2=plain text)

ライブラリをダウンロード

PHP translation API class (.zip) をダウンロード Ver. 1.2 Deprecated
Java translation API class (.zip) をダウンロード Ver. 1.2 Deprecated
PHP translation API class (.zip) をダウンロード Ver. 1.3
Java translation API class (.zip) をダウンロード Ver. 1.3