Skip to content

Commit

Permalink
Add API changes to docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Jun 27, 2022
1 parent 1a335ed commit d22e63f
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 8 deletions.
151 changes: 151 additions & 0 deletions docs/documentation/docs/api/entries.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,156 @@
# Entries

### GET /api/entries/:fromLang/:toLang/:searchQuery
Search the dictionary and retrieve paginated results. `:searchQuery` should be URL encoded.

This is identication to the public API `/api/dictionary/:fromLang/:toLang/:searchQuery` except that the public API does not return numerical database `id`s of entries.


#### Request
```bash
curl http://localhost:9000/api/dictionary/english/english/apple
```

**Response**

```json
{
"data": {
"entries": [
{
"id": 1,
"guid": "17e7a544-5b55-4c6c-8cfc-8fbe2f5ea747",
"weight": 0,
"initial": "A",
"lang": "english",
"content": "Apple",
"tokens": "",
"tags": [
"optional-tag1",
"tag2"
],
"phones": [
"ˈæp.əl",
"aapl"
],
"notes": "Optional note",
"status": "enabled",
"relations": [
{
"id": 3,
"guid": "61f76f4d-ee87-4efc-b2b2-845125585bcf",
"weight": 0,
"initial": "R",
"lang": "english",
"content": "round, red or yellow, edible fruit of a small tree",
"tokens": "",
"tags": [],
"phones": [
""
],
"notes": "",
"status": "enabled",
"created_at": "2022-06-26T08:33:34.842429Z",
"updated_at": "2022-06-26T08:33:34.842429Z",
"relation": {
"id": 1,
"types": [
"noun"
],
"tags": [
""
],
"notes": "",
"weight": 0,
"status": "enabled",
"created_at": "2022-06-26T08:33:34.844822Z",
"updated_at": "2022-06-26T08:33:34.844822Z"
}
},
{
"id": 4,
"guid": "72ee1c06-d3fc-4b5e-8fa7-ad868c12475d",
"weight": 1,
"initial": "T",
"lang": "english",
"content": "the tree, cultivated in most temperate regions.",
"tokens": "",
"tags": [],
"phones": [
""
],
"notes": "",
"status": "enabled",
"created_at": "2022-06-26T08:33:34.842429Z",
"updated_at": "2022-06-26T08:33:34.842429Z",
"relation": {
"id": 2,
"types": [
"noun"
],
"tags": [
""
],
"notes": "",
"weight": 1,
"status": "enabled",
"created_at": "2022-06-26T08:33:34.844822Z",
"updated_at": "2022-06-26T08:33:34.844822Z"
}
},
{
"id": 5,
"guid": "653fc521-f917-4049-99fc-5281b3e2e300",
"weight": 2,
"initial": "I",
"lang": "italian",
"content": "il pomo.",
"tokens": "",
"tags": [],
"phones": [
""
],
"notes": "",
"status": "enabled",
"created_at": "2022-06-26T08:33:34.842429Z",
"updated_at": "2022-06-26T08:33:34.842429Z",
"relation": {
"id": 3,
"types": [
"noun"
],
"tags": [
""
],
"notes": "",
"weight": 2,
"status": "enabled",
"created_at": "2022-06-26T08:33:34.844822Z",
"updated_at": "2022-06-26T08:33:34.844822Z"
}
}
],
"created_at": "2022-06-26T08:33:34.83976Z",
"updated_at": "2022-06-26T08:33:34.83976Z"
}
],
"page": 1,
"per_page": 10,
"total_pages": 0,
"total": 1
}
}
```

#### Query params
| Param | Type | |
|-----------|------------|-------------------------------------------------------------------------------------------------------------------------------------|
| `type` | `string` | Filter results by the given type. eg: `noun`. |
| `tag` | `string` | Filter results by the given tag. eg: `my-tag`. |
| `per_page` | `int` | Number of results to return per page (query) |
| `page` | `int` | Page number for paginated results. |


### GET /api/entries/:id
Retrieve a single entry by its database ID.

Expand Down
9 changes: 1 addition & 8 deletions docs/documentation/docs/api/search.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Search

### GET /api/dictionary/:fromLang/:toLang/:searchWords
Search the dictionary and retrieve paginated results.
Search the dictionary and retrieve paginated results. `:searchQuery` should be URL encoded.


#### Request
Expand All @@ -16,7 +16,6 @@ curl http://localhost:9000/api/dictionary/english/english/apple
"data": {
"entries": [
{
"id": 1,
"guid": "17e7a544-5b55-4c6c-8cfc-8fbe2f5ea747",
"weight": 0,
"initial": "A",
Expand All @@ -35,7 +34,6 @@ curl http://localhost:9000/api/dictionary/english/english/apple
"status": "enabled",
"relations": [
{
"id": 3,
"guid": "61f76f4d-ee87-4efc-b2b2-845125585bcf",
"weight": 0,
"initial": "R",
Expand All @@ -51,7 +49,6 @@ curl http://localhost:9000/api/dictionary/english/english/apple
"created_at": "2022-06-26T08:33:34.842429Z",
"updated_at": "2022-06-26T08:33:34.842429Z",
"relation": {
"id": 1,
"types": [
"noun"
],
Expand All @@ -66,7 +63,6 @@ curl http://localhost:9000/api/dictionary/english/english/apple
}
},
{
"id": 4,
"guid": "72ee1c06-d3fc-4b5e-8fa7-ad868c12475d",
"weight": 1,
"initial": "T",
Expand All @@ -82,7 +78,6 @@ curl http://localhost:9000/api/dictionary/english/english/apple
"created_at": "2022-06-26T08:33:34.842429Z",
"updated_at": "2022-06-26T08:33:34.842429Z",
"relation": {
"id": 2,
"types": [
"noun"
],
Expand All @@ -97,7 +92,6 @@ curl http://localhost:9000/api/dictionary/english/english/apple
}
},
{
"id": 5,
"guid": "653fc521-f917-4049-99fc-5281b3e2e300",
"weight": 2,
"initial": "I",
Expand All @@ -113,7 +107,6 @@ curl http://localhost:9000/api/dictionary/english/english/apple
"created_at": "2022-06-26T08:33:34.842429Z",
"updated_at": "2022-06-26T08:33:34.842429Z",
"relation": {
"id": 3,
"types": [
"noun"
],
Expand Down

0 comments on commit d22e63f

Please sign in to comment.