-
Notifications
You must be signed in to change notification settings - Fork 48
JSON API
Transvision allows external tools to retrieve data through a JSON API
Please note that:
- Data generated as JSON or JSONP output is sent with CORS headers.
- JSON data is sent with the application/json Mime Type
- JSONP data is sent with the application/javascript Mime Type
The format of a Transvision query is as such:
api/<api version>/<service requested>/<parameter 1>/<parameter 2>/<parameter x>/?optional_parameter1=foo&optional_parameter2=bar
A malformed query generates a response with an HTTP of 400 instead of 200 and the returned Json contains information about what was incorrectly set in the query.
Examples:
- http://transvision-beta.mozfr.org/api/v10/
- http://transvision-beta.mozfr.org/api/v1/tm/release/en-US/foobar/string/Bookmark/
- http://transvision-beta.mozfr.org/api/v1/foobar/
There are currently 6 services in our first version of the API (v1):
- entity: Return all translations for an entiry (equivalent to /string/ Json API)
- locales: Return the list of locales for a repository
- repositories: Return the list of repositories supported by the API
- search: Search on repositories (equivalent to current Json API on main page for strings and entities)
- tm: Translation memory, similar to the Amagama service
- versions: returns the different versions of the API with their status (beta, stable, deprecated)
This service returns the tranlation of a string in a mozilla repository for which we know the entity reference in all of the languages available.
/api/v1/entity/<repository>/?id=<unique ID for entity>
Example:
This API is mostly useful to Mozilla translation tools (/ex: Mozilla Translator) since you need to be able to build the correct unique ID for the entity which is based on its path in the Mozilla repository.
This service returns the list of locales available in Transvision for a repository
/api/v1/locales/<repository>/
Example:
http://transvision-beta.mozfr.org/api/v1/locales/gaia_1_4/
This service returns the list of repositories supported by Transvision
/api/v1/repositories/
Example:
http://transvision-beta.mozfr.org/api/v1/repositories/
This service performs a search on a repository and returns the list of strings matching this search with the unique identifier of the string as a key. This is the strict equivalent of the old Transvision API (before version 3.4) which allowed returning a search via the website as a JSON source by adding &json to the url. The old service is discontinued and redirected transparently to the new API.
Here is the syntax:
/api/v1/search/<search type>/<repository>/<source locale>/<target locale>/<search terms>/?<extra_parameter=1>
Example:
There are 3 extra parameters that can be set:
- case_sensitive: Makes a case sensitive search.
- perfect_match: Return only strings that match perfectly the searched terms
- whole_word: Return only results that have whole words marching
This service allows returning search results that are only strings and which contain a quality index based on the Levenshtein distance between the searched string for the source locales and the results. The results can be limited to a maximum number and can also be limited to a minimum quality.
Here is the syntax:
/api/v1/tm/<repository>/<source locale>/<target locale>/<search terms>/?<extra_parameter=integer>
List of extra parameters:
- max_results: an integer
- min_quality: an integer
Example:
This API returns the status of the versions of the API with their status (beta, stable, deprecated).
Here is the syntax:
/api/v1/versions/
Example: