| | Version at: 22/11/2022, 02:22 vs. version at: 22/11/2022, 02:26 |
---|
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 | | Search: English sentences containing the word "=play", where the equals sign (represented by "%3D" in the URL) is necessary in order to specify an exact match. _(For more information about specifying exact matches, see "Main search field" in [How to Search for Text](text-search#).)_ |
---|
| 33 | Search: English sentences containing the word "play". |
---|
34 | 34 | |
---|
| 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 | |
---|
| 37 | - query: **=play** |
---|
35 | 38 | - from: **eng** |
---|
36 | | - sort: **words** |
---|
37 | 39 | |
---|
38 | 40 | URL: |
---|
39 | 41 | `https://tatoeba.org/eng/api_v0/search?from=eng&query=%3Dplay` |
---|
40 | 42 | |
---|
41 | 43 | ### Example 2 |
---|
42 | 44 | |
---|
43 | 45 | Search: English sentences containing the word "Canadian", "Canadians", etc., that have direct Japanese translations |
---|
44 | 46 | |
---|
| 47 | - query: **Canadian** |
---|
45 | 48 | - from: **eng** |
---|
46 | 49 | - to: **jpn** |
---|
47 | 50 | - translations: **direct only** |
---|
48 | 51 | |
---|
49 | 52 | URL: |
---|
50 | 53 | `https://tatoeba.org/eng/api_v0/search?from=eng&query=Canadian&trans_filter=limit&trans_link=direct&trans_to=jpn&to=jpn` |
---|
51 | 54 | |
---|
52 | 55 | ### Example 3 |
---|
53 | 56 | |
---|
54 | 57 | Search: English sentences in list 907 containing the word "Boston" that have audio and Japanese translations (direct or indirect), sorted by creation date |
---|
55 | 58 | |
---|
| 59 | - query: **Boston** |
---|
56 | 60 | - from: **eng** |
---|
57 | 61 | - to: **jpn** |
---|
58 | 62 | - audio: **yes** |
---|
59 | 63 | - list: **907** |
---|
60 | 64 | - sort: **by creation date** |
---|
61 | 65 | - translations: **direct and indirect** |
---|
62 | 66 | |
---|
63 | 67 | URL: |
---|
64 | 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` |
---|
65 | 69 | |
---|
66 | 70 | ## Paging |
---|
67 | 71 | |
---|
68 | 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: |
---|
69 | 73 | |
---|
70 | 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` |
---|
71 | 75 | |
---|
72 | 76 | will produce the following result: |
---|
73 | 77 | |
---|
74 | 78 | "paging": { |
---|
75 | 79 | "Sentences": { |
---|
76 | 80 | "finder": "all", |
---|
77 | 81 | "page": 2, |
---|
78 | 82 | "current": 8, |
---|
79 | 83 | "count": 18, |
---|
80 | 84 | "perPage": 10, |
---|
81 | 85 | "start": 11, |
---|
82 | 86 | "end": 18, |
---|
83 | 87 | "prevPage": true, |
---|
84 | 88 | "nextPage": false, |
---|
85 | 89 | "pageCount": 2, |
---|
86 | 90 | "sort": null, |
---|
87 | 91 | "direction": null, |
---|
88 | 92 | "limit": null, |
---|
89 | 93 | "sortDefault": false, |
---|
90 | 94 | "directionDefault": false, |
---|
91 | 95 | "scope": null, |
---|
92 | 96 | "completeSort": [] |
---|
93 | 97 | } |
---|
94 | 98 | }, |
---|
95 | 99 | |
---|
96 | 100 | |
---|
97 | 101 | |
---|
98 | 102 | The relevant properties are: |
---|
99 | 103 | |
---|
100 | 104 | - `page`: current page |
---|
101 | 105 | - `current`: number of items displayed in the current page |
---|
102 | 106 | - `count`: total number of results |
---|
103 | 107 | - `perPage`: number of results per page |
---|
104 | 108 | |
---|
105 | 109 | To find the number of pages in total, divide `count` by `perPage` and round up to the nearest integer. |
---|
106 | 110 | |
---|
107 | 111 | |
---|
108 | 112 | |
---|
109 | 113 | |
---|
110 | 114 | ## For more information on the API |
---|
111 | 115 | |
---|
112 | 116 | See Tatoeba/tatoeba2 GitHub issue [#2669][1]. |
---|
113 | 117 | |
---|
114 | 118 | [1]: https://github.com/Tatoeba/tatoeba2/issues/2669 |
---|
115 | 119 | |
---|
diff view generated by jsdifflib |
---|
Version at: 22/11/2022, 02: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", where the equals sign (represented by "%3D" in the URL) is necessary in order to specify an exact match. _(For more information about specifying exact matches, see "Main search field" in [How to Search for Text](text-search#).)_
- from: **eng**
- sort: **words**
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
- 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
- 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.
## For more information on the API
See Tatoeba/tatoeba2 GitHub issue [#2669][1].
[1]: https://github.com/Tatoeba/tatoeba2/issues/2669
version at: 22/11/2022, 02:26
# 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.
## For more information on the API
See Tatoeba/tatoeba2 GitHub issue [#2669][1].
[1]: https://github.com/Tatoeba/tatoeba2/issues/2669