Version at: 20/11/2022, 20:31 vs. version at: 20/11/2022, 20:32
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
1313### Search: "Canadian" (not an exact match, so also matches "Canadians")
14from: **eng**
15to: **jpn**
16list: **907**
17translations: **direct only**
14
15 - from: **eng**
16 - to: **jpn**
17 - list: **907**
18 - translations: **direct only**
1819
1920 https://tatoeba.org/eng/api_v0/search?from=eng&list=907&query=Canadian&trans_filter=limit&trans_link=direct&trans_to=jpn&to=jpn
2021
2122### Search: "Boston"
22from: **eng**
23to: **jpn**
24audio: **yes**
25sort: **by creation date**
26translations: **direct and indirect**
23
24 - from: **eng**
25 - to: **jpn**
26 - audio: **yes**
27 - sort: **by creation date**
28 - translations: **direct and indirect**
2729
2830 https://tatoeba.org/eng/api_v0/search?from=eng&trans_filter=limit&query=Boston&sort=created&has_audio=yes&trans_to=jpn&to=jpn
2931
3032### Search: "=play" (exact match)
31from: **eng**
32to: **jpn**
33list: **907**
34sort: **words**
35translations: **direct only**
33
34 - from: **eng**
35 - to: **jpn**
36 - list: **907**
37 - sort: **words**
38 - translations: **direct only**
3639
3740 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
3841
3942
4043### Other
4144
4245To figure out how to make a call to the API, perform an advanced search, then change the first part of the URL from this:
4346
4447 https://tatoeba.org/en/sentences
4548
4649to this:
4750
4851 https://tatoeba.org/eng/api_v0
4952
5053For 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:
5154
5255 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=
5356
5457Change the first part of the URL in order to produce this URL that can be called against the API:
5558
5659 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=
5760
5861## Paging
5962
6063You 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:
6164
6265 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
6366
6467will produce the following result:
6568
6669 "paging": {
6770 "Sentences": {
6871 "finder": "all",
6972 "page": 2,
7073 "current": 8,
7174 "count": 18,
7275 "perPage": 10,
7376 "start": 11,
7477 "end": 18,
7578 "prevPage": true,
7679 "nextPage": false,
7780 "pageCount": 2,
7881 "sort": null,
7982 "direction": null,
8083 "limit": null,
8184 "sortDefault": false,
8285 "directionDefault": false,
8386 "scope": null,
8487 "completeSort": []
8588 }
8689 },
8790
8891
8992
9093The relevant properties are:
9194
9295 - `page`: current page
9396 - `current`: number of items displayed in the current page
9497 - `count`: total number of results
9598 - `perPage`: number of results per page
9699
97100To find the number of pages in total, divide `count` by `perPage` and round up to the nearest integer.
98101
99102
100103
101104
102105## For more information on the API
103106
104107See Tatoeba/tatoeba2 GitHub issue [#2669][1].
105108
106109 [1]: https://github.com/Tatoeba/tatoeba2/issues/2669
107110
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

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.