Skip to content

Instantly share code, notes, and snippets.

@hn3000
Created March 26, 2019 11:42
Show Gist options
  • Save hn3000/889417bf4d904e7e23dd8c513548eb12 to your computer and use it in GitHub Desktop.
Save hn3000/889417bf4d904e7e23dd8c513548eb12 to your computer and use it in GitHub Desktop.
Algolia API (partial) as swagger 2.0
{
"$schema": "http://json.schemastore.org/swagger-2.0",
"swagger": "2.0",
"info": {
"title": "Swaggerized Algolia API",
"version": "1"
},
"basePath": "/1",
"schemes": [ "https" ],
"host": "${APPLICATION_ID}-dsn.algolia.net",
"paths": {
"/indexes/{indexName}/query": {
"post": {
"operationId": "searchIndex",
"description": "Search index (POST)",
"parameters": [
{
"name": "indexName",
"required": true,
"in": "path",
"type": "string"
},
{
"name": "body",
"required": true,
"in": "body",
"schema": { "$ref": "#/definitions/QueryParams" }
}
],
"security": { "headers": ["algoliaAppId", "algoliaApiKey"] }
}
},
"/indexes/{indexName}": {
"get": {
"description": "Search index (GET)",
"operationId": "searchIndexUsingGET",
"parameters": [
{
"name": "indexName",
"required": true,
"in": "path",
"type": "string"
}
],
"security": { "headers": ["algoliaAppId", "algoliaApiKey"] }
}
},
"/indexes/*/queries": {
"post": {
"description": "Search multiple indices",
"operationId": "searchMultiple",
"parameters": [
{
"name": "body",
"in": "body",
"schema": { "$ref": "#/definitions/QueryMultiple"}
}
],
"security": { "headers": ["algoliaAppId", "algoliaApiKey"] }
}
},
"/indexes/{indexName}/facets/{facetName}/query": {
"post": {
"description": "Search for facet values",
"operationId": "searchFacetValues",
"parameters": [
{
"name": "indexName",
"required": true,
"in": "path",
"type": "string"
},
{
"name": "facetName",
"required": true,
"in": "path",
"type": "string"
},
{
"name": "body",
"required": true,
"in": "body",
"schema": { "$ref": "#/definitions/QueryParams" }
}
]
}
},
"/indexes/{indexName}/browse": {
"post": {
"description": "Browse index (POST)"
},
"get": {
"description": "Browse index (GET)"
}
}
},
"securityDefinitions": {
"applicationId": {
"type": "apiKey",
"in": "header",
"name": "X-Algolia-Application-Id"
},
"apiKey": {
"type": "apiKey",
"in": "header",
"name": "X-Algolia-API-Key"
}
},
"definitions": {
"QueryParams": {
"properties": {
"query": { "type": "string", "maxLength": 512 },
"attributesToRetrieve": {
"type": "array",
"items": { "type": "string" }
},
"restrictSearchableAttributes": {
"type": "array",
"items": { "type": "string" }
},
"filters": {
"description": "filters: 'attribute:value AND | OR | NOT attribute:value', 'numeric_attribute = | != | > | >= | < | <= numeric_value', 'attribute:lower_value TO higher_value', 'facetName:facetValue', '_tags:value', 'attribute:value'",
"type": "string"
},
"facetFilters": {
"description": "The filters parameter provides an easier to use, SQL-like syntax, and it supports both filters and facets. We recommend using it instead of facetFilters.",
"type": "array",
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
}
},
"optionalFilters": {
"description": "Filters for ranking purposes, where records that match the filter are ranked highest.",
"type": "array",
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
}
},
"numericFilters": {
"description": "Filters for ranking purposes, where records that match the filter are ranked highest.",
"type": "array",
"items": {
"description": "'numeric_attribute = | != | > | >= | < | <= numeric_value', 'attribute:lower_value TO higher_value',",
"type": "string"
}
},
"tagFilters": {
"description": "Filter hits by tags. `tagFilters` is a different way of filtering, which relies on the `_tags` attribute. It uses a simpler syntax than `filters`. You can use it when you want to do simple filtering based on tags.",
"type": "array",
"items": {
"x-anyOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
}
},
"sumOrFiltersScores": {
"description": "Determines how to calculate the total score for filtering. alse means that the total score of a record is the maximum score of an individual filter. Setting it to true changes the total score by adding together the scores of each matched filter.",
"type": "boolean"
},
"facets": {
"type": "array",
"items": {
"type": "string"
}
},
"maxValuesPerFacet": {
"type": "integer",
"maximum": 1000,
"default": 100
},
"facetingAfterDistinct": {
"type": "boolean"
},
"sortFacetValuesBy": {
"type": "string",
"enum": ["count", "alpha"]
},
"page": { "type": "integer" },
"hitsPerPage": { "type": "integer" },
"offset": { "type": "integer" },
"length": { "type": "integer" },
"getRankingInfo": { "type": "boolean" }
}
},
"ErrorContent": {
"properties": {
"message": {
"type": "string"
}
}
}
},
"responses": {
"badArguments": {
"description": "Bad request argument",
"schema": { "$ref": "#/definitions/ErrorContent" }
},
"indexNotFound": {
"description": "Index does not exist",
"schema": { "$ref": "#/definitions/ErrorContent" }
},
"error": {
"schema": { "$ref": "#/definitions/ErrorContent" }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment