Project API

The Project API is composed of 2 endpoints:

Show Project

This endpoint is accessible by both read-write and read-only Project API keys and returns information about your project:

  • Project name,
  • Locales setup on that project,
  • The source language,
  • For each file:
    • The file ids and file names.
    • The time of the file’s last modification.
    • The SHA-1 checksum of the file.
    • fresh: displays if the file hosted on WebTranslateIt is up to date or needs to be regenerated.

The call should be made using a GET request.

/api/projects/:project_token.format [GET]

Where format is one of xml, json or yaml.

Examples:

Data structure in YAML:

project:
  name: WebTranslateIt
  source_locale:
    name: English
    code: en
  target_locales:
  - name: French
    code: fr
    type: Locale
  id: 406
  project_files:
  - name: config/locales/app/en.yml
    updated_at: 2011-04-12 12:49:49 Z
    hash_file: 6ec3e8f72c5acfbbf2dbfe4e5d3014bd4144c541
    master_project_file_id:
    id: 56386
    locale_code: en
    fresh: true
  - name: config/locales/app/fr.yml
    updated_at: 2011-04-12 12:49:49 Z
    hash_file: 4e4ceeb4557a383dae1571f9d10c3336f92c4ff6
    master_project_file_id: 56386
    id: 56387
    locale_code: fr
    fresh: true

Implementation Example in Ruby:

require 'net/http'
http = Net::HTTP.new('webtranslateit.com', 443)
http.use_ssl = true
request = Net::HTTP::Get.new('/api/projects/:api_token')
response = http.request(request)

Implementation Example in PHP:

<?php
  $api_key = "sekret";
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_URL, "https://webtranslateit.com/api/projects/" . $api_key . ".json");
  $response = curl_exec($ch);
  $p = json_decode($response, true);
  print_r($p);
  curl_close($ch);
?>

Create Project

This endpoint is accessible by the read-write Organization API.

The call should be made using a POST request.

/api/projects/:organization_token.format [POST]

Parameters

A JSON object modelled after the following:

{
  "name": "Doughnut",
  "url": "https://doughnuts.com",
  "description": "A description of the project (Markdown can be used for formatting)",
  "icon": "An image file (optional, can be JPG, PNG or GIF)",
  "public": "false",
  "webhook": "https://webhook.com"
}
  • name: The project name (mandatory)
  • url: The project URL (optional). An URL linking to your project.
  • description: A project description (optional). Markdown can be used for formatting
  • icon: An image file (optional) passed as a multipart object
  • public: Optional. Sets if the project is open to the public. Can be "true" or "false". If unset, defaults to "false".
  • webhook: Optional. The URL of a webhook.

If everything goes well, a JSON representation of your Project will be returned, including the project’s read-write and read-only API tokens.

{
  "project": {
        "name": "Doughnut",
        "id": 406,
        "created_at": "2022-02-24T23:23:11Z",
        "updated_at": "2022-02-24T23:23:11Z",
        "source_locale": { },
    "url": "https://doughnuts.com",
    "description": "A description of the project",
    "public": "false",
    "webhook": "http://webhook.com",
    "icon": "https://link_to_image"
  }
}