@windingtree/wt-search-api
Version:
NodeJS app that enables quick search over data from Winding Tree platform
120 lines (119 loc) • 13 kB
YAML
openapi: 3.0.0
servers:
-
description: Localhost
url: 'http://localhost:1918'
info:
description: 'API for access to filterable and sortable cached collection of inventory from Winding Tree platform'
version: will-be-set-at-runtime
title: 'WT Search API'
paths:
/:
get:
summary: 'API info'
responses: {'200': {description: 'Basic information about this API instance.', content: {application/json: {schema: {type: object, properties: {docs: {type: string, description: 'Link to the API documentation.'}, info: {type: string, description: 'Link to more information about the API.'}, version: {type: string, description: 'Deployed API version number.'}, config: {type: string, description: 'Which config is the API using.'}}}}}}}
/hotels:
get:
summary: 'Get a list of hotels.'
parameters: [{name: location, in: query, description: 'Filter by distance (in kilometers) to the given location. Maximum allowed distance in the filter is 200 km. Format is "lat,long:distance" and you can specify multiple areas as multiple query parameters with this name.', required: false, schema: {type: array, items: {type: string, pattern: '^[\d.]+,[\d.]+:[\d.]+$'}}, example: '50.08,14.44:20'}, {name: sortByDistance, in: query, description: 'Sort by distance (in kilometers) from given point (lat, long).', required: false, schema: {type: string, pattern: '^[\d.]+,[\d.]+$'}, example: '50.08,14.44'}]
responses: {'200': {description: 'A list of hotels matching the input criteria.', content: {application/json: {schema: {type: object, properties: {items: {type: array, description: 'List of resolved hotels.', items: {$ref: 'https://raw.githubusercontent.com/windingtree/wt-read-api/v0.12.0/docs/swagger.yaml#/components/schemas/HotelListItem'}}, sortingScores: {type: array, description: 'List of item scores used for sorting (if applicable).', items: {type: object, required: [id, score], properties: {id: {$ref: '#/components/schemas/windingtree-wt-shared-schemas-EthereumAddressType'}, score: {type: object, required: [name, value], properties: {name: {description: 'Name of the metric that was used for sorting.', type: string}, value: {description: 'Value of the sorting metric.', type: number}}}}}}, next: {description: 'Uri to next page of records. When there''s no next page, this is not set.', $ref: '#/components/schemas/windingtree-wt-shared-schemas-UriType'}}}}}}, '400': {$ref: '#/components/responses/BadRequestError'}}
'/notifications/{subscription_token}':
parameters:
- {name: subscription_token, required: true, in: path, description: 'An opaque subscription token.', schema: {type: string}}
post:
summary: 'Publish an update notification. Facilitates the consumer webhook endpoint for wt-update-api.'
requestBody: {required: true, content: {application/json: {schema: {$ref: 'https://raw.githubusercontent.com/windingtree/wt-notification-api/v0.4.2/docs/swagger.yaml#/components/schemas/Notification'}}}}
responses: {'200': {description: 'Notification has been accepted.'}, '400': {$ref: '#/components/responses/BadRequestError'}, '401': {$ref: '#/components/responses/UnauthorizedError'}}
components:
responses:
BadRequestError:
description: 'The server does not understand the request (HTTP code 400)'
content: {application/json: {schema: {$ref: '#/components/schemas/Error'}}}
UnprocessableEntityError:
description: 'Request body or params validation failed.'
content: {application/json: {schema: {$ref: '#/components/schemas/Error'}}}
UnauthorizedError:
description: 'The provided subscription token and hotel address pair does not match any existing subscription.'
content: {application/json: {schema: {$ref: '#/components/schemas/Error'}}}
schemas:
Error:
title: Error
description: 'Default schema for errors returned by API.'
properties: {status: {type: number, description: 'HTTP status'}, code: {type: string, description: 'Computer-readable error. Use this for comparison.'}, short: {type: string, description: 'Human-readable error with a short description of the error.'}, long: {type: string, description: 'Verbose explanation of what happened.'}}
windingtree-wt-shared-schemas-Contact:
title: Contact
type: object
properties: {email: {description: 'E-mail contact', type: string, format: email, example: joseph.urban@example.com, maxLength: 150}, phone: {description: 'Phone number (with country prefix and a leading + sign)', type: string, maxLength: 18, example: '+44123456789', format: phone}, url: {description: 'Url to the contact web page', type: string, format: uri}, ethereum: {description: 'Address of wallet on Ethereum', $ref: '#/components/schemas/windingtree-wt-shared-schemas-EthereumAddressType'}, additionalContacts: {description: 'More contact options, such as Whatsapp, WeChat, Telegram, twitter handle, facebook address. Once we see high demand for a particular type of contact, we can promote them to regular contact types.', type: array, items: {type: object, required: [title, value], properties: {title: {description: 'Name of this contact options', type: string, maxLength: 100}, value: {description: 'The actual contact', type: string, maxLength: 100}}}}}
windingtree-wt-shared-schemas-CancellationPolicy:
title: 'Cancellation policy'
type: object
description: 'What is the penalty when a guest/passenger wants to cancel a reservation.'
required: [amount]
properties: {from: {description: 'After which date does this cancellation policy apply (including). If not present, this policy applies since the beginning of time. This is related to arrival and departure dates, not the date of the booking.', type: string, format: date, example: '2018-01-30'}, to: {description: 'Before which date does this cancellation policy apply(including). If not present, this policy applies until the end of the universe. This is related to arrival and departure dates, not the date of the booking.', type: string, format: date, example: '2018-02-20'}, deadline: {type: integer, description: 'How many days before hotel arrival or flight departure does this first apply. If not present, this policy applies any time.', example: 30}, amount: {type: number, format: float, description: 'Cost of cancellation in percents of the final price, 100 means non refundable. This means how much money will the hotel keep.', example: 25}}
windingtree-wt-shared-schemas-AddressType:
title: 'Postal address'
description: 'Based on output of Open Street Map''s [Nominatim](https://wiki.openstreetmap.org/wiki/Nominatim). For formatting, take a look [here](https://github.com/OpenCageData/address-formatting).'
type: object
required: [road, houseNumber, city, countryCode]
properties: {houseNumber: {type: string, maxLength: 150}, road: {type: string, maxLength: 150}, city: {type: string, maxLength: 150}, county: {type: string, maxLength: 150}, stateDistrict: {type: string, maxLength: 150}, state: {type: string, maxLength: 150}, postcode: {type: string, maxLength: 13}, countryCode: {type: string, maxLength: 2, minLength: 2, description: 'ISO 3166-1 alpha-2 codes', format: country-code}}
windingtree-wt-shared-schemas-LegalEntityType:
title: 'Legal entity'
type: object
description: 'A legal entity that can be held responsible'
required: [name, address, contact]
properties: {name: {description: 'Entity''s name as registered with the authorities', type: string, maxLength: 300}, address: {description: 'Entity''s postal address as registered with the authorities', $ref: '#/components/schemas/windingtree-wt-shared-schemas-AddressType'}, contact: {description: 'Any way of contacting the entity', $ref: '#/components/schemas/windingtree-wt-shared-schemas-Contact'}, vatin: {description: 'VAT identification number ([EU](https://en.wikipedia.org/wiki/VAT_identification_number), [US](https://www.irs.gov/individuals/international-taxpayers/taxpayer-identification-numbers-tin), or equivalents)', type: string, maxLength: 50}, lei: {description: 'Legal Entity Identifier as defined in ISO 17442, https://en.wikipedia.org/wiki/Legal_Entity_Identifier', type: string, length: 20}}
windingtree-wt-shared-schemas-CurrencyType:
title: 'Currency code'
type: string
minLength: 3
maxLength: 3
description: 'Three letter ISO 4217 currency code.'
format: currency-code
windingtree-wt-shared-schemas-DescriptionType:
title: 'Markdown description'
description: 'Text description in simple Markdown format (bold, italic, titles, line break and paragraph format). Particular flavour of markdown is yet to be decided.'
type: string
maxLength: 3000
windingtree-wt-shared-schemas-EthereumAddressType:
title: 'Ethereum address'
type: string
description: 'Ethereum address in hexadecimal format (with leading 0x) or an ENS name.'
maxLength: 300
windingtree-wt-shared-schemas-NameType:
title: 'Entity name'
description: 'Human readable name identifying an entity (shown to users in search results, hotel/room details, etc)'
type: string
maxLength: 150
windingtree-wt-shared-schemas-ObjectIdType:
title: ID
description: 'Vendor string ID'
type: string
maxLength: 100
example: 1234-abcd
windingtree-wt-shared-schemas-TimezoneType:
title: 'Timezone code'
description: 'Timezone name according to https://www.iana.org/time-zones (refer to zone.tab)'
type: string
maxLength: 40
format: timezone
windingtree-wt-shared-schemas-UriType:
title: URI
description: 'URI for linking resources. The maximal length is 1500 to save space.'
type: string
format: uri
maxLength: 1500
windingtree-wt-shared-schemas-LanguageCodeType:
title: 'Language code'
description: 'Two letter language code based on ISO 639-1 standard'
type: string
format: language-code
length: 2
windingtree-wt-shared-schemas-RelationshipSignatureType:
description: "Organization A (`subject`) publishes this object to tell the world that an Organization B (`guarantor`)\nagreed to be in an asymmetric relationship with the `subject`. Nature of such relationship can change\nto fit any particular use case.\nThe flow should be like this:\n 1. `subject` asks `guarantor` to establish a certain kind of relationship.\n 2. `guarantor` does its due dilligence of the `subject`.\n 3. `guarantor` creates `claim` and signs it. Typically, a `guarantor` address will be of a smart contract,\n which cannot sign data. So a `guarantor` would sign the data with a private key associated with one of\n the `associatedKeys` of the `guarantor`'s Organization smart contract. That is the `signature`.\n 6. `guarantor` sends the `claim` and the `signature` back to the `subject`.\n 7. `subject` publishes the `claim` and `signature` in its data.\n"
type: object
properties: {claim: {description: "A message that is signed by `guarantor`. This cannot be a JSON object due to its serialization rules\nambiguity. Instead, this is a hex encoded representation of a `RelationshipClaimType`\nserialized by the signing party to prevent inconsistencies.\n", type: string}, signature: {description: "Signature of a serialized `claim` signed by a private key associated (either directly or via a `associatedKeys`\nrelationship) with the `claim.guarantor` ETH address. The signature has to conform to the\n[eth_sign](https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign) method.\n", type: string}}
windingtree-wt-shared-schemas-RelationshipClaimType:
description: 'A message used to prove an asymmetric relationship between two subjects. It has a limited validity in time.'
type: object
required: [subject, guarantor, expiresAt]
properties: {subject: {description: 'Subjects''s ethereum address', $ref: '#/components/schemas/windingtree-wt-shared-schemas-EthereumAddressType'}, guarantor: {description: 'Guarantor''s ethereum address', $ref: '#/components/schemas/windingtree-wt-shared-schemas-EthereumAddressType'}, expiresAt: {description: 'When the relationship will expire. UNIX timestamp in seconds.', type: string, format: timestamp}}