
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
Note: This client has been developed for the Swiftype Site Search API endpoints only. You may refer to the Swiftype Site Search API Documentation for additional context.
With npm:
npm install swiftype
or clone locally:
$ git clone git@github.com:swiftype/swiftype-node.git
$ cd swiftype-node
$ npm install
Create a new instance of the client with your api key:
var SwiftypeApi = require('swiftype')
var swiftype = new SwiftypeApi({
apiKey: 'yourApiKey'
})
Search for cats on the engine my-engine with filters and facets:
swiftype.search({
engine: 'my-engine',
q: 'cats',
filters: {
page: {
'enumField': 'theFilter'
}
},
facets: {
page: ['enumField', 'anotherField']
}
}, function(err, res) {
console.log(res)
})
Autocomplete suggestion for cat on the engine my-engine with filters:
swiftype.suggest({
engine: 'my-engine',
q: 'cat',
filters: {
page: {
'enumField': 'theFilter'
}
}
}, function(err, res) {
console.log(res)
})
Log clickthrough for cat on the engine my-engine for the documentType page:
swiftype.click({
engine: 'my-engine',
q: 'cat',
id: 'the-document-id',
documentType: 'page'
}, function(err, res) {
console.log(res)
})
Create a new document:
swiftype.documents.create({
engine: 'my-engine',
documentType: 'books',
document: {
external_id: '1',
fields: [
{ name: 'title', value: 'The Great Gatsby', type: 'string' },
{ name: 'author', value: 'F. Scott Fitzgerald', type: 'string' },
{ name: 'genre', value: 'fiction', type: 'enum' }
]
}
}, function(err, res) {
console.log(res)
})
Fetch all of your engines:
swiftype.engines.list(function(err, res) {
console.log(res)
})
Fetch a single engine:
swiftype.engines.get({
engine: 'my-engine'
}, function(err, res) {
console.log(res)
})
Fetch all of the document types in the engine my-engine
swiftype.documentTypes.list({
engine: 'my-engine'
}, function(err, res) {
console.log(res)
})
Fetch the document type books in the engine my-engine
swiftype.documentTypes.get({
engine: 'my-engine',
documentType: 'books'
}, function(err, res) {
console.log(res)
})
Check out the tests for more examples!
$ npm test
The tests use stubbed HTTP interactions that are recorded with the node-replay module. By default, HTTP interactions are not allowed when running the tests.
The tests can also use environment variables so that you can create new replays against your own account. Don't forget to change the "authorization" header in the replay files to not give away your api key.
FAQs
Swiftype API client
The npm package swiftype receives a total of 2,289 weekly downloads. As such, swiftype popularity was classified as popular.
We found that swiftype demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.