| | Version at: 07/10/2023, 03:20 vs. version at: 12/02/2025, 03:22 |
|---|
| 1 | 1 | # API |
|---|
| 2 | 2 | |
|---|
| 3 | 3 | This page describes how to get started with the Tatoeba API. |
|---|
| 4 | 4 | |
|---|
| 5 | 5 | ## Retrieving a sentence with a known ID |
|---|
| 6 | 6 | |
|---|
| 7 | 7 | To retrieve sentence number 1: |
|---|
| 8 | 8 | |
|---|
| 9 | 9 | `https://tatoeba.org/eng/api_v0/sentence/1` |
|---|
| 10 | 10 | |
|---|
| 11 | 11 | ## Search results |
|---|
| 12 | 12 | |
|---|
| 13 | 13 | ### How to Construct a Call Based on an Advanced Search |
|---|
| 14 | 14 | |
|---|
| 15 | 15 | To figure out how to make a call to the API, you can perform an advanced search from the Tatoeba website, then change the first part of the URL from this: |
|---|
| 16 | 16 | |
|---|
| 17 | 17 | `https://tatoeba.org/en/sentences` |
|---|
| 18 | 18 | |
|---|
| 19 | 19 | to this: |
|---|
| 20 | 20 | |
|---|
| 21 | 21 | `https://tatoeba.org/eng/api_v0` |
|---|
| 22 | 22 | |
|---|
| 23 | 23 | For instance, if you use the advanced search interface to select English sentences without audio that contain the word "those", you will see that the URL looks like this: |
|---|
| 24 | 24 | |
|---|
| 25 | 25 | `https://tatoeba.org/en/sentences/search?from=eng&has_audio=no&native=&orphans=no&query=those&sort=relevance&sort_reverse=&tags=&to=&trans_filter=limit&trans_has_audio=&trans_link=&trans_orphan=&trans_to=&trans_unapproved=&trans_user=&unapproved=no&user=` |
|---|
| 26 | 26 | |
|---|
| 27 | 27 | Change the first part of the URL in order to produce this URL, which uses the API: |
|---|
| 28 | 28 | |
|---|
| 29 | 29 | `https://tatoeba.org/eng/api_v0/search?from=eng&has_audio=no&native=&orphans=no&query=those&sort=relevance&sort_reverse=&tags=&to=&trans_filter=limit&trans_has_audio=&trans_link=&trans_orphan=&trans_to=&trans_unapproved=&trans_user=&unapproved=no&user=` |
|---|
| 30 | 30 | |
|---|
| 31 | 31 | ### Example 1 |
|---|
| 32 | 32 | |
|---|
| 33 | 33 | Search: English sentences containing the word "play". |
|---|
| 34 | 34 | |
|---|
| 35 | 35 | _Note: The equals sign, represented by "%3D" in the URL, is necessary in order to specify an exact match in English and several other languages. For more information about specifying exact matches, see "Main search field" in [How to Search for Text](text-search#)._ |
|---|
| 36 | 36 | |
|---|
| 37 | 37 | - query: **=play** |
|---|
| 38 | 38 | - from: **eng** |
|---|
| 39 | 39 | |
|---|
| 40 | 40 | URL: |
|---|
| 41 | 41 | `https://tatoeba.org/eng/api_v0/search?from=eng&query=%3Dplay` |
|---|
| 42 | 42 | |
|---|
| 43 | 43 | ### Example 2 |
|---|
| 44 | 44 | |
|---|
| 45 | 45 | Search: English sentences containing the word "Canadian", "Canadians", etc., that have direct Japanese translations |
|---|
| 46 | 46 | |
|---|
| 47 | 47 | - query: **Canadian** |
|---|
| 48 | 48 | - from: **eng** |
|---|
| 49 | 49 | - to: **jpn** |
|---|
| 50 | 50 | - translations: **direct only** |
|---|
| 51 | 51 | |
|---|
| 52 | 52 | URL: |
|---|
| 53 | 53 | `https://tatoeba.org/eng/api_v0/search?from=eng&query=Canadian&trans_filter=limit&trans_link=direct&trans_to=jpn&to=jpn` |
|---|
| 54 | 54 | |
|---|
| 55 | 55 | ### Example 3 |
|---|
| 56 | 56 | |
|---|
| 57 | 57 | Search: English sentences in list 907 containing the word "Boston" that have audio and Japanese translations (direct or indirect), sorted by creation date |
|---|
| 58 | 58 | |
|---|
| 59 | 59 | - query: **Boston** |
|---|
| 60 | 60 | - from: **eng** |
|---|
| 61 | 61 | - to: **jpn** |
|---|
| 62 | 62 | - audio: **yes** |
|---|
| 63 | 63 | - list: **907** |
|---|
| 64 | 64 | - sort: **by creation date** |
|---|
| 65 | 65 | - translations: **direct and indirect** |
|---|
| 66 | 66 | |
|---|
| 67 | 67 | URL: |
|---|
| 68 | 68 | `https://tatoeba.org/eng/api_v0/search?from=eng&trans_filter=limit&query=Boston&sort=created&has_audio=yes&list=907&trans_to=jpn&to=jpn` |
|---|
| 69 | 69 | |
|---|
| 70 | 70 | ## Paging |
|---|
| 71 | 71 | |
|---|
| 72 | 72 | You can use the count and perPage in the paging information to find out how many pages are contained in the search results. For instance, the following call: |
|---|
| 73 | 73 | |
|---|
| 74 | 74 | `https://dev.tatoeba.org/eng/api_v0/search?from=eng&list=907&query=Canadian&trans_filter=limit&trans_link=direct&trans_to=jpn&to=jpn&page=2` |
|---|
| 75 | 75 | |
|---|
| 76 | 76 | will produce the following result: |
|---|
| 77 | 77 | |
|---|
| 78 | 78 | "paging": { |
|---|
| 79 | 79 | "Sentences": { |
|---|
| 80 | 80 | "finder": "all", |
|---|
| 81 | 81 | "page": 2, |
|---|
| 82 | 82 | "current": 8, |
|---|
| 83 | 83 | "count": 18, |
|---|
| 84 | 84 | "perPage": 10, |
|---|
| 85 | 85 | "start": 11, |
|---|
| 86 | 86 | "end": 18, |
|---|
| 87 | 87 | "prevPage": true, |
|---|
| 88 | 88 | "nextPage": false, |
|---|
| 89 | 89 | "pageCount": 2, |
|---|
| 90 | 90 | "sort": null, |
|---|
| 91 | 91 | "direction": null, |
|---|
| 92 | 92 | "limit": null, |
|---|
| 93 | 93 | "sortDefault": false, |
|---|
| 94 | 94 | "directionDefault": false, |
|---|
| 95 | 95 | "scope": null, |
|---|
| 96 | 96 | "completeSort": [] |
|---|
| 97 | 97 | } |
|---|
| 98 | 98 | }, |
|---|
| 99 | 99 | |
|---|
| 100 | 100 | |
|---|
| 101 | 101 | |
|---|
| 102 | 102 | The relevant properties are: |
|---|
| 103 | 103 | |
|---|
| 104 | 104 | - `page`: current page |
|---|
| 105 | 105 | - `current`: number of items displayed in the current page |
|---|
| 106 | 106 | - `count`: total number of results |
|---|
| 107 | 107 | - `perPage`: number of results per page |
|---|
| 108 | 108 | |
|---|
| 109 | 109 | To find the number of pages in total, divide `count` by `perPage` and round up to the nearest integer. |
|---|
| 110 | 110 | |
|---|
| 111 | 111 | |
|---|
| 112 | 112 | |
|---|
| 113 | 113 | |
|---|
| 114 | 114 | ## GitHub issue |
|---|
| 115 | 115 | |
|---|
| 116 | 116 | GitHub issue [#2669][1] contains discussion of the API, beginning with the initial proposal. |
|---|
| 117 | 117 | |
|---|
| 118 | 118 | * [https://github.com/Tatoeba/tatoeba2/issues/2669](https://github.com/Tatoeba/tatoeba2/issues/2669) |
|---|
| 119 | 119 | |
|---|
| 120 | 120 | ## Also read .... |
|---|
| 121 | 121 | |
|---|
| 122 | 122 | * [Using the Tatoeba Corpus for Your Own Projects](https://en.wiki.tatoeba.org/articles/show/using-the-tatoeba-corpus) |
|---|
| 123 | 123 | |
|---|
| 124 | | * [api.dev.tatoeba.org](https://api.dev.tatoeba.org/) |
|---|
| 124 | * A new API is being developed at [api.tatoeba.org](https://api.tatoeba.org/) |
|---|
| 125 | 125 | |
|---|
| diff view generated by jsdifflib |
|---|
Version at: 07/10/2023, 03:20
# API
This page describes how to get started with the Tatoeba API.
## Retrieving a sentence with a known ID
To retrieve sentence number 1:
`https://tatoeba.org/eng/api_v0/sentence/1`
## Search results
### How to Construct a Call Based on an Advanced Search
To figure out how to make a call to the API, you can perform an advanced search from the Tatoeba website, then change the first part of the URL from this:
`https://tatoeba.org/en/sentences`
to this:
`https://tatoeba.org/eng/api_v0`
For instance, if you use the advanced search interface to select English sentences without audio that contain the word "those", you will see that the URL looks like this:
`https://tatoeba.org/en/sentences/search?from=eng&has_audio=no&native=&orphans=no&query=those&sort=relevance&sort_reverse=&tags=&to=&trans_filter=limit&trans_has_audio=&trans_link=&trans_orphan=&trans_to=&trans_unapproved=&trans_user=&unapproved=no&user=`
Change the first part of the URL in order to produce this URL, which uses the API:
`https://tatoeba.org/eng/api_v0/search?from=eng&has_audio=no&native=&orphans=no&query=those&sort=relevance&sort_reverse=&tags=&to=&trans_filter=limit&trans_has_audio=&trans_link=&trans_orphan=&trans_to=&trans_unapproved=&trans_user=&unapproved=no&user=`
### Example 1
Search: English sentences containing the word "play".
_Note: The equals sign, represented by "%3D" in the URL, is necessary in order to specify an exact match in English and several other languages. For more information about specifying exact matches, see "Main search field" in [How to Search for Text](text-search#)._
- query: **=play**
- from: **eng**
URL:
`https://tatoeba.org/eng/api_v0/search?from=eng&query=%3Dplay`
### Example 2
Search: English sentences containing the word "Canadian", "Canadians", etc., that have direct Japanese translations
- query: **Canadian**
- from: **eng**
- to: **jpn**
- translations: **direct only**
URL:
`https://tatoeba.org/eng/api_v0/search?from=eng&query=Canadian&trans_filter=limit&trans_link=direct&trans_to=jpn&to=jpn`
### Example 3
Search: English sentences in list 907 containing the word "Boston" that have audio and Japanese translations (direct or indirect), sorted by creation date
- query: **Boston**
- from: **eng**
- to: **jpn**
- audio: **yes**
- list: **907**
- sort: **by creation date**
- translations: **direct and indirect**
URL:
`https://tatoeba.org/eng/api_v0/search?from=eng&trans_filter=limit&query=Boston&sort=created&has_audio=yes&list=907&trans_to=jpn&to=jpn`
## Paging
You can use the count and perPage in the paging information to find out how many pages are contained in the search results. For instance, the following call:
`https://dev.tatoeba.org/eng/api_v0/search?from=eng&list=907&query=Canadian&trans_filter=limit&trans_link=direct&trans_to=jpn&to=jpn&page=2`
will produce the following result:
"paging": {
"Sentences": {
"finder": "all",
"page": 2,
"current": 8,
"count": 18,
"perPage": 10,
"start": 11,
"end": 18,
"prevPage": true,
"nextPage": false,
"pageCount": 2,
"sort": null,
"direction": null,
"limit": null,
"sortDefault": false,
"directionDefault": false,
"scope": null,
"completeSort": []
}
},
The relevant properties are:
- `page`: current page
- `current`: number of items displayed in the current page
- `count`: total number of results
- `perPage`: number of results per page
To find the number of pages in total, divide `count` by `perPage` and round up to the nearest integer.
## GitHub issue
GitHub issue [#2669][1] contains discussion of the API, beginning with the initial proposal.
* [https://github.com/Tatoeba/tatoeba2/issues/2669](https://github.com/Tatoeba/tatoeba2/issues/2669)
## Also read ....
* [Using the Tatoeba Corpus for Your Own Projects](https://en.wiki.tatoeba.org/articles/show/using-the-tatoeba-corpus)
* [api.dev.tatoeba.org](https://api.dev.tatoeba.org/)
version at: 12/02/2025, 03:22
# API
This page describes how to get started with the Tatoeba API.
## Retrieving a sentence with a known ID
To retrieve sentence number 1:
`https://tatoeba.org/eng/api_v0/sentence/1`
## Search results
### How to Construct a Call Based on an Advanced Search
To figure out how to make a call to the API, you can perform an advanced search from the Tatoeba website, then change the first part of the URL from this:
`https://tatoeba.org/en/sentences`
to this:
`https://tatoeba.org/eng/api_v0`
For instance, if you use the advanced search interface to select English sentences without audio that contain the word "those", you will see that the URL looks like this:
`https://tatoeba.org/en/sentences/search?from=eng&has_audio=no&native=&orphans=no&query=those&sort=relevance&sort_reverse=&tags=&to=&trans_filter=limit&trans_has_audio=&trans_link=&trans_orphan=&trans_to=&trans_unapproved=&trans_user=&unapproved=no&user=`
Change the first part of the URL in order to produce this URL, which uses the API:
`https://tatoeba.org/eng/api_v0/search?from=eng&has_audio=no&native=&orphans=no&query=those&sort=relevance&sort_reverse=&tags=&to=&trans_filter=limit&trans_has_audio=&trans_link=&trans_orphan=&trans_to=&trans_unapproved=&trans_user=&unapproved=no&user=`
### Example 1
Search: English sentences containing the word "play".
_Note: The equals sign, represented by "%3D" in the URL, is necessary in order to specify an exact match in English and several other languages. For more information about specifying exact matches, see "Main search field" in [How to Search for Text](text-search#)._
- query: **=play**
- from: **eng**
URL:
`https://tatoeba.org/eng/api_v0/search?from=eng&query=%3Dplay`
### Example 2
Search: English sentences containing the word "Canadian", "Canadians", etc., that have direct Japanese translations
- query: **Canadian**
- from: **eng**
- to: **jpn**
- translations: **direct only**
URL:
`https://tatoeba.org/eng/api_v0/search?from=eng&query=Canadian&trans_filter=limit&trans_link=direct&trans_to=jpn&to=jpn`
### Example 3
Search: English sentences in list 907 containing the word "Boston" that have audio and Japanese translations (direct or indirect), sorted by creation date
- query: **Boston**
- from: **eng**
- to: **jpn**
- audio: **yes**
- list: **907**
- sort: **by creation date**
- translations: **direct and indirect**
URL:
`https://tatoeba.org/eng/api_v0/search?from=eng&trans_filter=limit&query=Boston&sort=created&has_audio=yes&list=907&trans_to=jpn&to=jpn`
## Paging
You can use the count and perPage in the paging information to find out how many pages are contained in the search results. For instance, the following call:
`https://dev.tatoeba.org/eng/api_v0/search?from=eng&list=907&query=Canadian&trans_filter=limit&trans_link=direct&trans_to=jpn&to=jpn&page=2`
will produce the following result:
"paging": {
"Sentences": {
"finder": "all",
"page": 2,
"current": 8,
"count": 18,
"perPage": 10,
"start": 11,
"end": 18,
"prevPage": true,
"nextPage": false,
"pageCount": 2,
"sort": null,
"direction": null,
"limit": null,
"sortDefault": false,
"directionDefault": false,
"scope": null,
"completeSort": []
}
},
The relevant properties are:
- `page`: current page
- `current`: number of items displayed in the current page
- `count`: total number of results
- `perPage`: number of results per page
To find the number of pages in total, divide `count` by `perPage` and round up to the nearest integer.
## GitHub issue
GitHub issue [#2669][1] contains discussion of the API, beginning with the initial proposal.
* [https://github.com/Tatoeba/tatoeba2/issues/2669](https://github.com/Tatoeba/tatoeba2/issues/2669)
## Also read ....
* [Using the Tatoeba Corpus for Your Own Projects](https://en.wiki.tatoeba.org/articles/show/using-the-tatoeba-corpus)
* A new API is being developed at [api.tatoeba.org](https://api.tatoeba.org/)