Skip to content

Latest commit

 

History

History
78 lines (58 loc) · 3.35 KB

DictionaryAPI.md

File metadata and controls

78 lines (58 loc) · 3.35 KB

Pearson Dictionaries API

This document describes how to use the Pearson SDK to access the Dictionaries API. For further details of this API and it's usage, please see Pearson Dictionaries API.

Accessing the Dictionaries API

Start be connecting to the Dictionaries API object provided by the Pearson SDK (see example below).

var dict = PearsonApis.dictionaries(apikey);

where the apikey is you key to access the Pearson Dictionaries API.

If no key is specified, or the key is a 'sandbox' key, then you will be limitied to searching and retrieving from only a subset of the data available in the dictionaries API (generally, this is words begining 'a' to 'c').

Dictionary API Endpoints

Entries

In order to search or retrieve entries from the Dictionaries API, you need to use the 'entries' object that the API provides.

var dict = PearsonApis.dicitonaries(my_apikey);
var entries = dict.entries;

The entries endpoint provides methods to search for and retrieve entries from the Dictionaries API.

Searching for Entries

entries.search(searchobj,offset,limit)

Searches the dictionaries API. The searchobj should be a JSON object containing one or more of the following proprerties used to direct the search results:

  • headword - (string) search for entries with matching headword.
  • related_words - (string) search for entries woth with matching related_words.
  • synonyms - (string) search for entries with matching synonyms.
  • phrasal_verbs - (string) search for entries with matching phrasal_verbs.
  • part_of_speech - (string) search for entries with containing matching part_of_speech.
  • images - (string) search for entries with matching images (note that only picture is currently supported).
  • audio - (string) search for entries with matching audio (note that only example, pronunciation and effect are currently supported).
  • search - (string) Generic search across all fields on an entry in the dictionary.

offset and limit are optional zero-based indexes into the results returned, and can be used for paging through results. limit defaults to 10, and has a maximum value of 25. An offset greater than total number of results available will cause the return of zero results.

An example of a search might be as follows:

var searchobj = { headword: "(+cat -fish)",
                  images: "picture",
                  audio: "pronunciation"};

var results = entries.search(searchobj,0,25);

Retrieving an Entry

Use the getById method on the entries endpoint to retrieve the full detail of a specific entry.

var result = entries.getById(id)

where id is the Id of the entry you wish to retrieve.

Limiting Search to Specific Dictionaries

You can limit the search of the Dictionaries API to spefic datasets prior to searching.

entries.setDatasets("ldoce5,lasde");
entries.search(searchobj);

This will ensure that only the specified dictionaries are searched. The datasets should be specified as a comma-delimited string of one or more of the following allowable datasets:

  • ldoce5 - Longman Dictionary of Contemporary English
  • lasde - Longman Active Study Guide
  • ldec - Longman English Chinese dictionary
  • wordwise - Longman WordWise dictionary
  • laad3 - Longman Advanced American English dictionary