| | Version at: 20/11/2022, 20:31 vs. version at: 20/11/2022, 20:32 |
---|
1 | 1 | # API |
---|
2 | 2 | |
---|
3 | 3 | This page gives a few examples of how to use the Tatoeba API. |
---|
4 | 4 | |
---|
5 | 5 | ## For one sentence |
---|
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 | ### Search: "Canadian" (not an exact match, so also matches "Canadians") |
---|
14 | | from: **eng** |
---|
15 | | to: **jpn** |
---|
16 | | list: **907** |
---|
17 | | translations: **direct only** |
---|
|
| 14 | |
---|
| 15 | - from: **eng** |
---|
| 16 | - to: **jpn** |
---|
| 17 | - list: **907** |
---|
| 18 | - translations: **direct only** |
---|
18 | 19 | |
---|
19 | 20 | https://tatoeba.org/eng/api_v0/search?from=eng&list=907&query=Canadian&trans_filter=limit&trans_link=direct&trans_to=jpn&to=jpn |
---|
20 | 21 | |
---|
21 | 22 | ### Search: "Boston" |
---|
22 | | from: **eng** |
---|
23 | | to: **jpn** |
---|
24 | | audio: **yes** |
---|
25 | | sort: **by creation date** |
---|
26 | | translations: **direct and indirect** |
---|
|
| 23 | |
---|
| 24 | - from: **eng** |
---|
| 25 | - to: **jpn** |
---|
| 26 | - audio: **yes** |
---|
| 27 | - sort: **by creation date** |
---|
| 28 | - translations: **direct and indirect** |
---|
27 | 29 | |
---|
28 | 30 | https://tatoeba.org/eng/api_v0/search?from=eng&trans_filter=limit&query=Boston&sort=created&has_audio=yes&trans_to=jpn&to=jpn |
---|
29 | 31 | |
---|
30 | 32 | ### Search: "=play" (exact match) |
---|
31 | | from: **eng** |
---|
32 | | to: **jpn** |
---|
33 | | list: **907** |
---|
34 | | sort: **words** |
---|
35 | | translations: **direct only** |
---|
|
| 33 | |
---|
| 34 | - from: **eng** |
---|
| 35 | - to: **jpn** |
---|
| 36 | - list: **907** |
---|
| 37 | - sort: **words** |
---|
| 38 | - translations: **direct only** |
---|
36 | 39 | |
---|
37 | 40 | https://tatoeba.org/eng/api_v0/search?from=eng&list=907&query=%3Dplay&sort=created&trans_filter=limit&trans_link=direct&trans_to=jpn&to=jpn |
---|
38 | 41 | |
---|
39 | 42 | |
---|
40 | 43 | ### Other |
---|
41 | 44 | |
---|
42 | 45 | To figure out how to make a call to the API, perform an advanced search, then change the first part of the URL from this: |
---|
43 | 46 | |
---|
44 | 47 | https://tatoeba.org/en/sentences |
---|
45 | 48 | |
---|
46 | 49 | to this: |
---|
47 | 50 | |
---|
48 | 51 | https://tatoeba.org/eng/api_v0 |
---|
49 | 52 | |
---|
50 | 53 | 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: |
---|
51 | 54 | |
---|
52 | 55 | 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= |
---|
53 | 56 | |
---|
54 | 57 | Change the first part of the URL in order to produce this URL that can be called against the API: |
---|
55 | 58 | |
---|
56 | 59 | 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= |
---|
57 | 60 | |
---|
58 | 61 | ## Paging |
---|
59 | 62 | |
---|
60 | 63 | 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: |
---|
61 | 64 | |
---|
62 | 65 | 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 |
---|
63 | 66 | |
---|
64 | 67 | will produce the following result: |
---|
65 | 68 | |
---|
66 | 69 | "paging": { |
---|
67 | 70 | "Sentences": { |
---|
68 | 71 | "finder": "all", |
---|
69 | 72 | "page": 2, |
---|
70 | 73 | "current": 8, |
---|
71 | 74 | "count": 18, |
---|
72 | 75 | "perPage": 10, |
---|
73 | 76 | "start": 11, |
---|
74 | 77 | "end": 18, |
---|
75 | 78 | "prevPage": true, |
---|
76 | 79 | "nextPage": false, |
---|
77 | 80 | "pageCount": 2, |
---|
78 | 81 | "sort": null, |
---|
79 | 82 | "direction": null, |
---|
80 | 83 | "limit": null, |
---|
81 | 84 | "sortDefault": false, |
---|
82 | 85 | "directionDefault": false, |
---|
83 | 86 | "scope": null, |
---|
84 | 87 | "completeSort": [] |
---|
85 | 88 | } |
---|
86 | 89 | }, |
---|
87 | 90 | |
---|
88 | 91 | |
---|
89 | 92 | |
---|
90 | 93 | The relevant properties are: |
---|
91 | 94 | |
---|
92 | 95 | - `page`: current page |
---|
93 | 96 | - `current`: number of items displayed in the current page |
---|
94 | 97 | - `count`: total number of results |
---|
95 | 98 | - `perPage`: number of results per page |
---|
96 | 99 | |
---|
97 | 100 | To find the number of pages in total, divide `count` by `perPage` and round up to the nearest integer. |
---|
98 | 101 | |
---|
99 | 102 | |
---|
100 | 103 | |
---|
101 | 104 | |
---|
102 | 105 | ## For more information on the API |
---|
103 | 106 | |
---|
104 | 107 | See Tatoeba/tatoeba2 GitHub issue [#2669][1]. |
---|
105 | 108 | |
---|
106 | 109 | [1]: https://github.com/Tatoeba/tatoeba2/issues/2669 |
---|
107 | 110 | |
---|
diff view generated by jsdifflib |
---|
Version at: 20/11/2022, 20:31
# API
This page gives a few examples of how to use the Tatoeba API.
## For one sentence
To retrieve sentence number 1:
https://tatoeba.org/eng/api_v0/sentence/1
## Search results
### Search: "Canadian" (not an exact match, so also matches "Canadians")
from: **eng**
to: **jpn**
list: **907**
translations: **direct only**
https://tatoeba.org/eng/api_v0/search?from=eng&list=907&query=Canadian&trans_filter=limit&trans_link=direct&trans_to=jpn&to=jpn
### Search: "Boston"
from: **eng**
to: **jpn**
audio: **yes**
sort: **by creation date**
translations: **direct and indirect**
https://tatoeba.org/eng/api_v0/search?from=eng&trans_filter=limit&query=Boston&sort=created&has_audio=yes&trans_to=jpn&to=jpn
### Search: "=play" (exact match)
from: **eng**
to: **jpn**
list: **907**
sort: **words**
translations: **direct only**
https://tatoeba.org/eng/api_v0/search?from=eng&list=907&query=%3Dplay&sort=created&trans_filter=limit&trans_link=direct&trans_to=jpn&to=jpn
### Other
To figure out how to make a call to the API, perform an advanced search, 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 that can be called against 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=
## 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: 20/11/2022, 20:32
# API
This page gives a few examples of how to use the Tatoeba API.
## For one sentence
To retrieve sentence number 1:
https://tatoeba.org/eng/api_v0/sentence/1
## Search results
### Search: "Canadian" (not an exact match, so also matches "Canadians")
- from: **eng**
- to: **jpn**
- list: **907**
- translations: **direct only**
https://tatoeba.org/eng/api_v0/search?from=eng&list=907&query=Canadian&trans_filter=limit&trans_link=direct&trans_to=jpn&to=jpn
### Search: "Boston"
- from: **eng**
- to: **jpn**
- audio: **yes**
- sort: **by creation date**
- translations: **direct and indirect**
https://tatoeba.org/eng/api_v0/search?from=eng&trans_filter=limit&query=Boston&sort=created&has_audio=yes&trans_to=jpn&to=jpn
### Search: "=play" (exact match)
- from: **eng**
- to: **jpn**
- list: **907**
- sort: **words**
- translations: **direct only**
https://tatoeba.org/eng/api_v0/search?from=eng&list=907&query=%3Dplay&sort=created&trans_filter=limit&trans_link=direct&trans_to=jpn&to=jpn
### Other
To figure out how to make a call to the API, perform an advanced search, 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 that can be called against 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=
## 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