Skip to content

Lexonomy API

rambousek edited this page Feb 4, 2021 · 11 revisions

Description of public APIs that can be used by external applications.

For some API calls, API key is needed. You can get your API key in User profile (One-Click Dictionary API key).

For local installations, change server name in URL.

Push data

Use this API to create dictionary and import entries. Examples and test at https://www.lexonomy.eu/push.api

Create new dictionary, with Lexonomy "One-Click Dictionary" template

{
  "email": "your Lexonomy user email",
  "apikey": "your Lexonomy API key",
  "command": "makeDict",
  "dictTitle": "dictionary title",
  "dictBlurb": "dictionary information",
  "poses": "array of PoS values",
  "labels": "array of entry labels"
}

example

{
  "email": "[email protected]",
  "apikey": "4HNA6VI6C9MROAENNYJQJPLL53HCAJMA",
  "command": "makeDict",
  "dictTitle": "My New Dictionary",
  "dictBlurb": "Yet another dictionary draft.",
  "poses": ["n", "v", "adj", "adv"],
  "labels": ["colloquial", "formal", "mostly plural", "Irish English", "vulgar"]
}
  • response: JSON encoded, in case of failure {"success": false}, in case of successful dictionary creation {"success": true, "dictID": "ID of new dictionary"}. You will need dictID for entry import.

Create new dictionary, with TEI-Lex0 template

{
  "email": "your Lexonomy user email",
  "apikey": "your Lexonomy API key",
  "command": "makeDict",
  "format": "teilex0",
  "dictTitle": "dictionary title",
  "dictBlurb": "dictionary information",
  "poses": "array of PoS values",
  "labels": "array of entry labels"
}
  • response: JSON encoded, in case of failure {"success": false}, in case of successful dictionary creation {"success": true, "dictID": "ID of new dictionary"}. You will need dictID for entry import.

List dictionaries

{
  "email": "your Lexonomy user email",
  "apikey": "your Lexonomy API key",
  "command": "listDicts",
}
  • response: JSON encoded, list of dictionaries accessible for given user
{
  "success": true,
  "entries": [
    {"id": "dictionary ID", "title": "dictionary title"}
  ]
}

Import entries into dictionary, general entry format

{
  "email": "your Lexonomy user email",
  "apikey": "your Lexonomy API key",
  "command": "createEntries",
  "dictID": "dictionary ID",
  "entryXmls": "array of XML strings"
}

example

{
  "email": "[email protected]",
  "apikey": "4HNA6VI6C9MROAENNYJQJPLL53HCAJMA",
  "command": "createEntries",
  "dictID": "4eve25a",
  "entryXmls": ["<entry><headword>Brno</headword></entry>", "<entry><headword>Prague</headword></entry>"]
}
  • response: JSON encoded, in case of failure {"success": false}, in case of successful entry import {"success": true}.

Import entries into dictionary, TEI-Lex0 entry format

{
  "email": "your Lexonomy user email",
  "apikey": "your Lexonomy API key",
  "command": "createEntries",
  "format": "teilex0",
  "dictID": "dictionary ID",
  "entryXmls": "array of XML strings"
}

example

{
  "email": "[email protected]",
  "apikey": "4HNA6VI6C9MROAENNYJQJPLL53HCAJMA",
  "command": "createEntries",
  "format": "teilex0",
  "dictID": "4eve25a",
  "entryXmls": ["<entry><form type='lemma'><orth>Earth</orth></form></entry>", "<entry><form type='lemma'><orth>Mars</orth></form></entry>"]
}
  • response: JSON encoded, in case of failure {"success": false}, in case of successful entry import {"success": true}.

Linking

API used to create links between dictionary elements. In user interface, linkable elements in dictionary have to be configured first. In each dictionary you want to link, go to Configure-Expert settings-Manual linking and set up elements to link and their unique identifiers. After that, you are able to create and view links in entry editor and browser. However, you can use API directly without dictionary config.

Add link

  • method: GET
  • request URI: https://www.lexonomy.eu/dictID/links/add?source_id=source_element_id&target_dict=target_dictionary&target_id=target_element_id
  • parameters:
    • dictID: source dictionary ID, user needs edit permission on source dictionary
    • source_id: unique ID of source element to link
    • target_dict: target dictionary ID
    • target_id: unique ID of target element to link
  • response: in case of error {"success": false, "error": "error message"}. For successful link creation {"success": true, "links": {"link_id": "new unique link ID", "source_dict": "source dictionary ID", "source_el": "source element", "source_id": "source element ID", "target_dict": "target dictionary ID", "target_el": "target element", "target_id": "target element ID"}}

Delete link

Get links going from dictionary

  • method: GET

  • request URI: https://www.lexonomy.eu/dictID/links/from

  • parameters:

    • dictID: source dictionary ID, user needs any permission on source dictionary
    • source_id: (optional) source element ID to filter results
    • target_dict: (optional) target dictionary ID to filter results
    • target_id: (optional) target element ID to filter results
  • response: JSON encoded array of links with dictID as source dictionary: {"links": [{"link_id": "new unique link ID", "source_dict": "source dictionary ID", "source_el": "source element", "source_id": "source element ID", "target_dict": "target dictionary ID", "target_el": "target element", "target_id": "target element ID"}]}

Get links going to dictionary

  • method: GET
  • request URI: https://www.lexonomy.eu/dictID/links/from
  • parameters:
    • dictID: target dictionary ID, user needs any permission on target dictionary
    • source_id: (optional) source element ID to filter results
    • source_dict: (optional) source dictionary ID to filter results
    • target_id: (optional) target element ID to filter results
  • response: JSON encoded array of links with dictID as target dictionary {"links": [{"link_id": "new unique link ID", "source_dict": "source dictionary ID", "source_el": "source element", "source_id": "source element ID", "target_dict": "target dictionary ID", "target_el": "target element", "target_id": "target element ID"}]}

OntoLex

Download dictionary data in OntoLex N-Triple format. For the moment, headword is used as set in the dictionary config, sense definitions are detected using most common entry elements.

{
  "email": "your Lexonomy user email",
  "apikey": "your Lexonomy API key"
}
  • response: text/plain, Ontolex N-Triple format

  • example response:

<https://www.lexonomy.eu/elexis-idiotikon#galsterig_26313> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/lemon/ontolex#LexicalEntry> .
<https://www.lexonomy.eu/elexis-idiotikon#galsterig_26313> <http://www.w3.org/2000/01/rdf-schema#label> "galsterig"@de .
<https://www.lexonomy.eu/elexis-idiotikon#galsterig_26313> <http://www.w3.org/ns/lemon/ontolex#sense> <https://www.lexonomy.eu/elexis-idiotikon#26313_1> .
<https://www.lexonomy.eu/elexis-idiotikon#26313_1> <http://www.w3.org/2004/02/skos/core#definition> "'ausser sich gebracht, seiner selbst nicht mehr mächtig'"@de .
<https://www.lexonomy.eu/elexis-idiotikon#galsterig_26313> <http://www.w3.org/ns/lemon/ontolex#sense> <https://www.lexonomy.eu/elexis-idiotikon#26313_2> .
<https://www.lexonomy.eu/elexis-idiotikon#26313_2> <http://www.w3.org/2004/02/skos/core#definition> "ausgelassen, mutwillig, übermütig lustig, von Mädchen"@de .