Conyac Requester API v1 Getting Started Guide

Introduction

Conyac API has been implemented as a RESTful Web service using OAuth 2.0 for authentication. Access to each of the translation request functions is made using URL parameters.

In addition, the information coming back from the Conyac API server is in JSON format. This makes it possible to read and use the data easily regardless of programming language, platform, mobile application or web service.

In this guide, Conyac Requester API v1 basics will be described. Please see the Conyac Requester API v1 for more information.

Account registration

To create an application using the Conyac API, registration of a requester account is required.

New application registration

First, login to Conyac with your requester account. From the drop-down menu (located under the Conyac logo and to the right of your available points) select Manage Apps.

You should now be in the “Manage Apps” page. Click on the green Add Application button. The “New application” registration screen will appear. The following data can be entered for the application that will use Conyac API:

  • Name (required)
    Enter the name for your application (eg. YourConyacApp)
  • Service Site URL
    For web services, enter the server’s URL. For native (mobile) apps, enter your site’s official URL (eg. https://yourconyacapp.com).
  • Description (required)
    Enter details regarding your application such as main functions, usage, and description of your application.
  • OAuth callback URL (required)
    Enter the callback URL to be used for OAuth 2.0 authentication (eg. https://yourconyacapp.com/oauth/conyac/callback).
  • Callback notification URL
    Enter the callback notification URL of your application (eg. https://yourconyacapp.com/conyac/notifications). For more information regarding callback notification, please refer to the Conyac API Reference Manual.

Click the Create button. Registration of your application is now complete. A Secret and unique application ID (Uid) will be issued to your application. Both parameters are random 64-character long strings, respectively. The above two parameters will be required during the OAuth 2.0 authentication, to the OAuth callback URL. Please keep them both in a safe place and especially take extra precaution to not release your Secret to the public.

Test the authentication

Get the authentication code

In order to authenticate your application, the required parameters must be included with your Conyac authentication URL (https://biz.conyac.cc/oauth/authorize).

The required parameters are the following:

  • response_type
    code
  • client_id
    Application ID
  • redirect_uri
    UTF-8 encoded OAuth callback URL

You can verify that the authentication URL is correct by comparing your parameters with this example URL:

https://biz.conyac.cc/oauth/authorize?response_type=code&client_id=df256790540e639c9ef7a1debc31ae09405170c5b51b76d4a123b910cc032e56&redirect_uri=https%3A%2F%2Fyourconyacapp.com%2Foauth%2Fconyac%2Fcallback

(Note: redirect_uri and client_id will be different for each application. Please use the parameters that were generated for your application.)

In the case when you are not currently logged in, the login screen will appear. Authentication is successful when a message to Authorize or Deny your application appears on the screen.

After clicking on the Authorize button, your browser’s URL should be similar to the following:

https://yourconyacapp.com/oauth/conyac/callback?code=daaefad48a50797ff9b424e4ac948dda87bb8238d67090b4fa6909726f235ad3

(you can ignore any messages regarding not being able to access the web page)

Please save the code string (64 characters) somewhere.

Get the access token

To get the access token, open the URL (https://biz.conyac.cc/oauth/token) with the following parameters:

  • client_id
    Application ID
  • client_secret
    Secret
  • redirect_uri
    UTF-8 encoded OAuth callback URL
  • grant_type
    authorization_code
  • code
    the same code that was obtained from above

In this case, rather than a Web browser, you can use the Curl command.

$ curl https://biz.conyac.cc/oauth/token \
   -d client_id=df256790540e639c9ef7a1debc31ae09405170c5b51b76d4a123b910cc032e56 \
   -d client_secret=f11d67fe92e97c371dec524e989ed3289828e604f5c4c4b545e7392dfb47d7a3 \
 -d redirect_uri=https%3A%2F%2Fyourconyacapp.com%2Foauth%2Fconyac%2Fcallback \
 -d grant_type=authorization_code \
 -d code=b35ec927409e96ce3676ccc77e27240a205d4fe5e74d446c34e42e2f5f72c5ca \
 -X POST

You should be able to successfully obtain an access_token in JSON format like the given example:

{
  "access_token": "a5adb9bc60a9ed4438f7db1443971181b1dab875f0d6994d3245aa4cee7e34b8",
  "token_type": "bearer",
  "expires_in": null,
  "refresh_token": null,
  "scope": ""
}

Testing the API

Getting your information (the logged in requester)

curl -X GET https://biz.conyac.cc/api/v1/my?access_token=a5adb9bc60a9ed4438f7db1443971181b1dab875f0d6994d3245aa4cee7e34b8
{
  "success": true,
  "message": "the user information is successfully obtained.",
  "id": 107,
  "login": "test10",
  "created_at": "2014-06-10T10:32:38.000+09:00",
  "updated_at": "2014-06-10T10:32:38.000+09:00",
  "locale": "en",
  "picture_url": "https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.png?d=identicon&r=PG&s=48",
  "translator": false,
  "email": "test@example.com",
  "default_organization_id": 4,
  "default_organization": {
    "id": 4,
    "name": "test10",
    "plan_id": 1,
    "user_id": 107,
    "default": 1,
    "description": null,
    "created_at": "2014-06-10T10:32:38.000+09:00",
    "updated_at": "2014-06-10T10:32:39.000+09:00",
    "url": "https://biz.conyac.cc/api/v1/organizations/4",
    "html_url": "https://conyac.cc/b/organizations/4",
    "point": 100250,
    "available_point": 100250
  }
}

You are now ready to use Conyac API. For the overall functionality of the API, refer to the end points.

(To make a request, you will need to purchase points through Conyac in advance)