Author: Hugh
Tatoeba: https://tatoeba.org/eng/user/profile/tatoebashrek
Introduction
Problem definition
I would like to build an API for Tatoeba to allow easy and direct use by other websites.
I am the owner of the language-learning website https://lingopolo.org/ which is a sort of cross between Anki (flashcard tool), Duolingo (language-learning tool) and Tatoeba. It builds language lessons automatically based on the added sentence content.
Recently we have started to use content from Tatoeba, e.g. see the Tatoeba acknowledgement at the bottom of these pages:
What we would like to do is automatically add sentences from Tatoeba, directly and programatically from the Lingopolo website. The Lingopolo website would regularly, via cron, make requests to Tatoeba of the type:
- give me the ids of 100 sentences in NL with an EN translation and audio
- for each of the ids, give me the full content of that particular sentence, such as:
- id
- EN text
- NL text
- copyright information
- user
- audio
Proposed solution summary
This describes part of a possible Tatoeba API, which would allow users to directly via API (on a URL):
query the ids of sentences matching a particular tag
query an individual sentence
I see that there have been some attempts at building an API before:
Lingopolo
Lingopolo consists of 2 developers, myself and Alex. It is based on Drupal (which means it is written in PHP like Tatoeba). We would anticipate that we would do most of the development of this API.
Useful links on API structure
There are many external APIs which it would be worth studying to get the best structure, but here are a few recent links I was looking at.
Wikidata API:
See how Wikidata offers two formats, one which shows HTML and one which shows Json, by adding the "format=json" parameter:
In the description below I use 2 different formats inconsistently for the API:
- /api.php?action=show_sentences_with_tag=7770&offset=0&limit=100
- GET /sentence/1111401
Get the list of sentences which match a given tag
HTML
https://tatoeba.org/eng/tags/show_sentences_with_tag/7770
Example API call
/api.php?action=show_sentences_with_tag=7770&offset=0&limit=100
Pagination based on https://nordicapis.com/everything-you-need-to-know-about-api-pagination/
Example Response
100 rows in the following format:
{
"id": 6549421,
"id": 6627714,
"id": 6996983,
"id": 2722194,
…
}
Get a sentence
This call returns the detail of a single sentence.
Example: "Tom asked me who walked home with me last night."
https://tatoeba.org/eng/sentences/show/6432721
{
"id": 6432721,
"text": "Tom asked me who walked home with me last night.",
"language": "en",
"derivedFrom": "",
"belongsTo": "CK",
"tags": [],
"textLicence": "CC BY 2.0 FR",
"audioLicence": "CC BY 2.0 FR",
"audio": "https://audio.tatoeba.org/sentences/eng/6432721.mp3",
"translations": [
{
"id": 9672097,
"language": "epo",
"text": "Tomo demandis al mi, kiu marŝis hejmen kun mi hieraŭ nokte."
}
]
}
Example "VK is de afkorting van het Verenigd Koninkrijk"
Gets the information for a single sentence such as https://tatoeba.org/eng/sentences/show/1111401
This example demonstrates how the direct and indirect translations would be arranged in two separate arrays.
Example call:
GET /sentence/1111401
Response:
{
"id": 1111401,
"lang": "nl",
"text": "VK is de afkorting van het Verenigd Koninkrijk",
"textLicence": "CC BY 2.0 FR",
"audioLicence": "CC BY 2.0 FR",
"owner": "megamanenm",
"directTranslations": [
{
"id": 1067763,
"lang": "en",
"text": "UK is the abbreviation for the United Kingdom"
}
{
"id": 1208155,
"lang": "esp",
"text": "UR estas mallongigo por Unuiĝinta Reĝlando."
}
]
"indirectTranslations": [
{
"id": 7527207
"lang": "ber",
"text": "TY d asegzel n Tgelda Yedduklen."
}
]
}
Get user (member)
Get the details of a particular user (member).
HTML
https://tatoeba.org/eng/user/profile/Guybrush88
Example API call
/api.php?action=get_user&user=Guybrush88
Example response
{
"user": "Guybrush88",
"country": "Italy",
"birthday": "1988-12-27",
"homepage": "",
"commentsPosted": 6717,
"sentencesOwned": 687581,
"audioRecordings": 0,
"sentencesFavorited": 45,
"contributions": 2243651,
"languages": [
{
"language": "it",
"level": 5,
"details": "Native speaker"
}
{
"language": "en",
"level": 4,
"details": "C1 level of Cambridge, C2 of my University"
}
{
"language": "fr",
"level": 4,
"details": "C1 level of my University"
}
{
"language": "egl",
"level": 4,
"details": "The dialect from my province"
}
}
Get the list of supported languages
This is not seen as currently required, but is included as one of the many other API endpoints which might eventually be built.
returns something like:
{
"languages": ["en", "fr", "nl", ....]
}
Author: Hugh
Tatoeba: https://tatoeba.org/eng/user/profile/tatoebashrek
Introduction
Problem definition
I would like to build an API for Tatoeba to allow easy and direct use by other websites.
I am the owner of the language-learning website https://lingopolo.org/ which is a sort of cross between Anki (flashcard tool), Duolingo (language-learning tool) and Tatoeba. It builds language lessons automatically based on the added sentence content.
Recently we have started to use content from Tatoeba, e.g. see the Tatoeba acknowledgement at the bottom of these pages:
What we would like to do is automatically add sentences from Tatoeba, directly and programatically from the Lingopolo website. The Lingopolo website would regularly, via cron, make requests to Tatoeba of the type:
Proposed solution summary
This describes part of a possible Tatoeba API, which would allow users to directly via API (on a URL):
query the ids of sentences matching a particular tag
query an individual sentence
I see that there have been some attempts at building an API before:
Lingopolo
Lingopolo consists of 2 developers, myself and Alex. It is based on Drupal (which means it is written in PHP like Tatoeba). We would anticipate that we would do most of the development of this API.
Useful links on API structure
There are many external APIs which it would be worth studying to get the best structure, but here are a few recent links I was looking at.
Wikidata API:
See how Wikidata offers two formats, one which shows HTML and one which shows Json, by adding the "format=json" parameter:
In the description below I use 2 different formats inconsistently for the API:
Get the list of sentences which match a given tag
HTML
https://tatoeba.org/eng/tags/show_sentences_with_tag/7770
Example API call
/api.php?action=show_sentences_with_tag=7770&offset=0&limit=100
Pagination based on https://nordicapis.com/everything-you-need-to-know-about-api-pagination/
Example Response
100 rows in the following format:
Get a sentence
This call returns the detail of a single sentence.
Example: "Tom asked me who walked home with me last night."
https://tatoeba.org/eng/sentences/show/6432721
Example "VK is de afkorting van het Verenigd Koninkrijk"
Gets the information for a single sentence such as https://tatoeba.org/eng/sentences/show/1111401
This example demonstrates how the direct and indirect translations would be arranged in two separate arrays.
Example call:
GET /sentence/1111401
Response:
Get user (member)
Get the details of a particular user (member).
HTML
https://tatoeba.org/eng/user/profile/Guybrush88
Example API call
/api.php?action=get_user&user=Guybrush88
Example response
Get the list of supported languages
This is not seen as currently required, but is included as one of the many other API endpoints which might eventually be built.
returns something like: