Version at: 20/11/2022, 20:32 vs. version at: 20/11/2022, 20:39
11# API
22
33This page gives a few examples of how to use the Tatoeba API.
44
55## For one sentence
66
77To retrieve sentence number 1:
88
99 https://tatoeba.org/eng/api_v0/sentence/1
1010
1111## Search results
1212
13### Search: "Canadian" (not an exact match, so also matches "Canadians")
13### Search: English sentences containing the word "Canadian" contained in list 907 that have direct Japanese translations
14
15Note that unless the search string is preceded by an equals sign, the search will not be exact, so this query will also match "Canadians".
1416
1517 - from: **eng**
1618 - to: **jpn**
1719 - list: **907**
1820 - translations: **direct only**
1921
2022 https://tatoeba.org/eng/api_v0/search?from=eng&list=907&query=Canadian&trans_filter=limit&trans_link=direct&trans_to=jpn&to=jpn
2123
22### Search: "Boston"
24### Search: English sentences containing the word "Boston" that have audio and Japanese translations, sorted by creation date
2325
2426 - from: **eng**
2527 - to: **jpn**
2628 - audio: **yes**
2729 - sort: **by creation date**
2830 - translations: **direct and indirect**
2931
3032 https://tatoeba.org/eng/api_v0/search?from=eng&trans_filter=limit&query=Boston&sort=created&has_audio=yes&trans_to=jpn&to=jpn
3133
32### Search: "=play" (exact match)
34### Search: English sentences containing the word "=play" (exact match) in list 907 that have direct translations in Japanese
3335
3436 - from: **eng**
3537 - to: **jpn**
3638 - list: **907**
3739 - sort: **words**
3840 - translations: **direct only**
3941
4042 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
4143
4244
4345### Other
4446
45To figure out how to make a call to the API, perform an advanced search, then change the first part of the URL from this:
47To figure out how to make a call to the API, you can perform an advanced search, then change the first part of the URL from this:
4648
4749 https://tatoeba.org/en/sentences
4850
4951to this:
5052
5153 https://tatoeba.org/eng/api_v0
5254
5355For 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:
5456
5557 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=
5658
57Change the first part of the URL in order to produce this URL that can be called against the API:
59Change the first part of the URL in order to produce this URL, which uses the API:
5860
5961 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=
6062
6163## Paging
6264
6365You 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:
6466
6567 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
6668
6769will produce the following result:
6870
6971 "paging": {
7072 "Sentences": {
7173 "finder": "all",
7274 "page": 2,
7375 "current": 8,
7476 "count": 18,
7577 "perPage": 10,
7678 "start": 11,
7779 "end": 18,
7880 "prevPage": true,
7981 "nextPage": false,
8082 "pageCount": 2,
8183 "sort": null,
8284 "direction": null,
8385 "limit": null,
8486 "sortDefault": false,
8587 "directionDefault": false,
8688 "scope": null,
8789 "completeSort": []
8890 }
8991 },
9092
9193
9294
9395The relevant properties are:
9496
9597 - `page`: current page
9698 - `current`: number of items displayed in the current page
9799 - `count`: total number of results
98100 - `perPage`: number of results per page
99101
100102To find the number of pages in total, divide `count` by `perPage` and round up to the nearest integer.
101103
102104
103105
104106
105107## For more information on the API
106108
107109See Tatoeba/tatoeba2 GitHub issue [#2669][1].
108110
109111 [1]: https://github.com/Tatoeba/tatoeba2/issues/2669
110112
diff view generated by jsdifflib

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

version at: 20/11/2022, 20:39

# 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: English sentences containing the word "Canadian" contained in list 907 that have direct Japanese translations

Note that unless the search string is preceded by an equals sign, the search will not be exact, so this query will also match "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: English sentences containing the word "Boston" that have audio and Japanese translations, sorted by creation date

 - 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: English sentences containing the word "=play" (exact match) in list 907 that have direct translations in Japanese

 - 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, you can 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, 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=

## 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

Note

The lines in green are the lines that have been added in the new version. The lines in red are those that have been removed.