Synonyms
Create synonym sets.
Authentication
For authentication, the Synonyms endpoint requires...
- A Host Identifier:
[HOST_IDENTIFIER]
- The name of your Engine:
[ENGINE]
- A Private API Key:
[PRIVATE_API_KEY]
curl -X GET 'https://[HOST_IDENTIFIER].api.swiftype.com/api/as/v1/engines/[ENGINE]/synonyms' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer [PRIVATE_API_KEY]'
List Synonyms
List All Synonyms
Retrieves synonym sets for an Engine.
- page
- optional
- A JSON object containing
current
andsize
, wherecurrent
is the current page number andsize
is the page size. The maximum forsize
is25
, and be will truncated if a largersize
is requested. The default is the first page of synonym sets with pagination at25
.
GET
request for all synonyms, paginated. Returns the 2nd page of results, with 20 results per page.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"meta": {
"page": {
"current": 1,
"total_pages": 1,
"total_results": 3,
"size": 25
}
},
"results": [
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"park",
"trail"
]
},
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"protected",
"heritage"
]
},
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"hectares",
"acres"
]
}
]
}
GET
request for all synonyms, paginated. Returns the 2nd page of results, with 20 results per page.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"meta": {
"page": {
"current": 1,
"total_pages": 1,
"total_results": 3,
"size": 25
}
},
"results": [
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"park",
"trail"
]
},
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"protected",
"heritage"
]
},
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"hectares",
"acres"
]
}
]
}
GET
request for all synonyms, paginated. Returns the 2nd page of results, with 20 results per page.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"meta": {
"page": {
"current": 1,
"total_pages": 1,
"total_results": 3,
"size": 25
}
},
"results": [
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"park",
"trail"
]
},
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"protected",
"heritage"
]
},
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"hectares",
"acres"
]
}
]
}
GET
request for all synonyms, paginated. Returns the 2nd page of results, with 20 results per page.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"meta": {
"page": {
"current": 1,
"total_pages": 1,
"total_results": 3,
"size": 25
}
},
"results": [
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"park",
"trail"
]
},
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"protected",
"heritage"
]
},
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"hectares",
"acres"
]
}
]
}
GET
request for all synonyms, paginated. Returns the 2nd page of results, with 20 results per page.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"meta": {
"page": {
"current": 1,
"total_pages": 1,
"total_results": 3,
"size": 25
}
},
"results": [
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"park",
"trail"
]
},
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"protected",
"heritage"
]
},
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"hectares",
"acres"
]
}
]
}
GET
request for all synonyms, paginated. Returns the 2nd page of results, with 20 results per page.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"meta": {
"page": {
"current": 1,
"total_pages": 1,
"total_results": 3,
"size": 25
}
},
"results": [
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"park",
"trail"
]
},
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"protected",
"heritage"
]
},
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"hectares",
"acres"
]
}
]
}
List All Synonyms with Pagination
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"page": {
"size": 20,
"current": 2
}
}'
{
"meta": {
"page": {
"current": 2,
"total_pages": 2,
"total_results": 30,
"size": 20
}
},
"results": [
## Truncated!
]
}
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"page": {
"size": 20,
"current": 2
}
}'
{
"meta": {
"page": {
"current": 2,
"total_pages": 2,
"total_results": 30,
"size": 20
}
},
"results": [
## Truncated!
]
}
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"page": {
"size": 20,
"current": 2
}
}'
{
"meta": {
"page": {
"current": 2,
"total_pages": 2,
"total_results": 30,
"size": 20
}
},
"results": [
## Truncated!
]
}
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"page": {
"size": 20,
"current": 2
}
}'
{
"meta": {
"page": {
"current": 2,
"total_pages": 2,
"total_results": 30,
"size": 20
}
},
"results": [
## Truncated!
]
}
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"page": {
"size": 20,
"current": 2
}
}'
{
"meta": {
"page": {
"current": 2,
"total_pages": 2,
"total_results": 30,
"size": 20
}
},
"results": [
## Truncated!
]
}
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"page": {
"size": 20,
"current": 2
}
}'
{
"meta": {
"page": {
"current": 2,
"total_pages": 2,
"total_results": 30,
"size": 20
}
},
"results": [
## Truncated!
]
}
Lists a Single Synonym
Retrieves a synonym set by id
.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac66c9f9292013220ad3' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"park",
"trail"
]
}
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac66c9f9292013220ad3' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"park",
"trail"
]
}
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac66c9f9292013220ad3' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"park",
"trail"
]
}
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac66c9f9292013220ad3' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"park",
"trail"
]
}
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac66c9f9292013220ad3' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"park",
"trail"
]
}
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac66c9f9292013220ad3' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"id": "syn-5b11ac66c9f9292013220ad3",
"synonyms": [
"park",
"trail"
]
}
Create a Synonym Set
Creates a new synonym set for an Engine.
You may only create one set of synonyms per API call.
The endpoint will not accept an array of arrays!
A synonym set can contain up to 32 words.
- synonyms
- required
- An array of strings containing at least two unique strings.
curl -X POST 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"synonyms": ["park", "trail"]
}'
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"park",
"trail"
]
}
curl -X POST 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"synonyms": ["park", "trail"]
}'
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"park",
"trail"
]
}
curl -X POST 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"synonyms": ["park", "trail"]
}'
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"park",
"trail"
]
}
curl -X POST 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"synonyms": ["park", "trail"]
}'
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"park",
"trail"
]
}
curl -X POST 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"synonyms": ["park", "trail"]
}'
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"park",
"trail"
]
}
curl -X POST 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"synonyms": ["park", "trail"]
}'
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"park",
"trail"
]
}
Update a Synonym Set
Updates an existing synonym set for an Engine by id
.
You may only update one set of synonyms per API call.
The endpoint will not accept an array of arrays!
A synonym set can contain up to 32 words.
- synonyms
- required
- An array of strings containing at least two unique strings.
curl -X PUT 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac72c9f9296b35220ac9' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"synonyms": ["road", "trail"]
}'
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"road",
"trail"
]
}
curl -X PUT 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac72c9f9296b35220ac9' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"synonyms": ["road", "trail"]
}'
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"road",
"trail"
]
}
curl -X PUT 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac72c9f9296b35220ac9' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"synonyms": ["road", "trail"]
}'
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"road",
"trail"
]
}
curl -X PUT 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac72c9f9296b35220ac9' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"synonyms": ["road", "trail"]
}'
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"road",
"trail"
]
}
curl -X PUT 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac72c9f9296b35220ac9' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"synonyms": ["road", "trail"]
}'
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"road",
"trail"
]
}
curl -X PUT 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac72c9f9296b35220ac9' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '{
"synonyms": ["road", "trail"]
}'
{
"id": "syn-5b11ac72c9f9296b35220ac9",
"synonyms": [
"road",
"trail"
]
}
Delete a Synonym
Delete a synonym set by id
.
curl -X DELETE 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac66c9f9292013220ad3' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"deleted": true
}
curl -X DELETE 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac66c9f9292013220ad3' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"deleted": true
}
curl -X DELETE 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac66c9f9292013220ad3' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"deleted": true
}
curl -X DELETE 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac66c9f9292013220ad3' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"deleted": true
}
curl -X DELETE 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac66c9f9292013220ad3' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"deleted": true
}
curl -X DELETE 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/synonyms/syn-5b11ac66c9f9292013220ad3' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx'
{
"deleted": true
}
Errors
The endpoint will return an error if:
- The API Key does not have write permissions for the requested Engine.
- The requested synonym set does not exist.
- The synonym object is not well formed.
- The request tried to create multiple synonym sets.
What's Next?
Configuring Synonyms is a useful way to guide your users to 'the right' content. It is most useful when you know the precise terms that they are searching for. For that, you should explore the Analytics and Clickthrough end-points, so that you are aware of your insightful capabilities. If you are looking to provide even more precise and curated results, venture to the Curations end-point.
Stuck? Looking for help? Contact support or check out the App Search community forum!