Discussion API

The Discussion API is composed of 4 endpoints:

List Discussions

This endpoint is accessible by both private and public Project API keys and returns the discussions on a project.

/api/projects/:project_token/discussions [GET]

Pagination

This resource is paginated and serves 250 Discussions per page. You can specify further page using the ?page parameter. Note that page numbering is 1-based and that omitting the ?page parameter will return the first page.

Link Header

The pagination information is included in the Link header. You can use the Link Header in order to know which page is next and which page is the last one, instead of constructing your own URLs.

For instance, let’s make a curl request to the TermBase API:

The -I parameter indicates that we only care about the headers, not the actual content. In examining the result, you’ll notice some information in the Link header that looks like this:

Link: <https://webtranslateit.com/api/projects/api_key/discussions.json?page=2>; rel="next",
  <https://webtranslateit.com/api/projects/api_key/discussions.json?page=20>; rel="last"

The possible rel values are:

  • next: Shows the URL of the immediate next page of results.
  • last: Shows the URL of the last page of results.
  • first: Shows the URL of the first page of results.
  • prev: Shows the URL of the immediate previous page of results.

Here’s another example of the Link Header when browsing the 3rd page:

Link: <https://webtranslateit.com/api/projects/api_key/discussions.json?page=4>; rel="next",
  <https://webtranslateit.com/api/projects/api_key/discussions.json?page=9>; rel="last",
  <https://webtranslateit.com/api/projects/api_key/discussions.json?page=1>; rel="first",
  <https://webtranslateit.com/api/projects/api_key/discussions.json?page=2>; rel="prev"

This resource is paginated and serves 250 Discussions per page. In the server response headers, you will find Link, with a link for an API call to the next and last pages.

Optional Parameters:

  • string_id: ID of a segment
  • locale: the locale of the discussion: en-US, en_GB or fr for instance.
  • kind: can be segments to list discussions about segments only or project to list discussions about projects only.
  • status: can be locked or left blank.
  • page: the page number

Example query:

https://webtranslateit.com/api/projects/api_key/discussions.json

Example response with JSON:

The author’s e-mail address is anonymized when authenticating using the public API token. E-mail address is visible when authenticating using the private API token.

Implementation Example in Ruby:

Implementation Example in PHP:

Delete Discussion

This endpoint is accessible by the private Project API key and deletes a discussion on a project.

/api/projects/:project_token/discussion/:discussion_id [DELETE]

If everything goes well, the server should respond with 202 Accepted in the response headers.

Implementation Example in Ruby:

Implementation Example in PHP:

Lock Discussion

This endpoint is accessible by the private Project API key and deletes a discussion on a project.

/api/projects/:project_token/discussion/:discussion_id/lock [PUT]

If everything goes well, the server should respond with 202 Accepted in the response headers.

Unlock Discussion

This endpoint is accessible by the private Project API key and deletes a discussion on a project.

/api/projects/:project_token/discussion/:discussion_id/unlock [PUT]

If everything goes well, the server should respond with 202 Accepted in the response headers.