WordReference APIOverviewWe are happy to provide an API to be used by developers and are looking forward to seeing what innovative and useful tools might result. For those accustomed to Google Translate's API, please understand that this is very different. WordReference offers dictionary translations of words and phrases, not machine translation of sentences. ImplementationThe API comes in two varieties: a JSON format and a regular-HTML/web format. The URL for the HTML API is
You must include the API key in the requesting URL. See below for how to get an API key. If you are including a version number in the request, the API key must go after the version number. Additionally, for JSPONp, the JSON API can take an optional callback function in the query string; simply add "?callback={yourCallback}" to the end of the URL. Examples: The dictionary that you want to look up your term in is specified by a combination of the two-letter code for the original language and the two-letter code for the target language. For example, if you are looking up the word "house" from English to French, the URL would be '/enfr/house', where en stands for English, and fr for French. The two letter language abbreviations are below:
Please note:
The encoding is UTF-8, so "más" must show as "m%C3%A1s". English thesaurus support HTML APIIn the HTML API, you can perform searches by either manually changing the URL to indicate which dictionary and what term you want to search for, or you can use a search-box and dropdown dictionary selector on the page itself. If you search a term on the opposite side of the dictionary, the HTML API will automatically redirect you to the correct page. For instance, if you went to the page http://api.wordreference.com/1/enfr/aller, you would be redirected to the page /fren/aller. JSON APIThe structure of the JSON API differs between requests to the thesaurus and requests to all other dictionaries. An example of the typical output from most dictionaries is displayed below. See here for an explanation of the JSON output for the thesaurus. Here is an example of output from the JSON API, for /enfr/keys :
{
"term0" : {
"PrincipalTranslations" : {
"0" : {
"OriginalTerm" : {
"term" : "keys",
"POS" : "",
"sense" : "door",
"usage" : ""
},
"FirstTranslation" : {
"term" : "clés",
"POS" : "nfpl",
"sense" : "de serrure"
},
"Note" : ""
},
"1" : {
"OriginalTerm" : {
"term" : "keys",
"POS" : "",
"sense" : "on computer, piano, phone etc.",
"usage" : ""
},
"FirstTranslation" : {
"term" : "touches",
"POS" : "nfpl",
"sense" : "ordinateur piano téléphone etc."
},
"Note" : ""
},
"2" : {
"OriginalTerm" : {
"term" : "keys",
"POS" : "",
"sense" : "",
"usage" : "figurative meaning"
},
"FirstTranslation" : {
"term" : "clés",
"POS" : "nfpl",
"sense" : "secrets sens figuré"
},
"Note" : ""
}
}
},
"original" : {
"Compounds" : {
"0" : {
"OriginalTerm" : {
"term" : "piano keys",
"POS" : "",
"sense" : "",
"usage" : ""
},
"FirstTranslation" : {
"term" : "le clavier du piano, les touches",
"POS" : "",
"sense" : ""
},
"Note" : ""
}
}
},
"Lines" : "End Reached",
"END" : true
}
The API will return a series of zero or more objects of the type The category blocks that the API returns can be any of the following:
The
Within each category block, the data comes in a pair in the form of The entry-block has three types of objects:
After the note, the entry-block is complete, and the entry-number ( If no entry is found for the searched term, the output is :
If a term is searched for on the wrong side of the dictionary, the page returns the relative
redirect-url under the element "URL". For example, if you went to http://api.wordreference.com/1/json/enfr/aller,
the API would return :
There can be up to four translations for a given entry, and there can be several
entries for a given term (for instance, all compound terms that include the
searched-for-term will show up). Getting an API keyTo get an API key:
Whenever you make a request to the API, make sure your URL includes this unique ID --- otherwise the API will not work, and you will be prompted to include this. Terms of Service
Share your work!If you have made something cool with the API that you want to share with others, feel free to post it in the forums. You can post any full-blown applications here or post any programming language-specific code-snippets or SDKS here. Questions? Comments? Suggestions? Send us a message.
|

