🐢🚀 Twingly Blog Search API in JavaScript
JavaScript
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
lib
test
.gitignore
.travis.yml
README.md
package-lock.json
package.json

README.md

Twingly Search API Node

Build Status

A Node.js library for Twingly's Search API (previously known as Analytics API). Twingly is a blog search service that provides a searchable API known as Twingly Search API.

Installation

Install npm

npm install --save twingly-search

Usage

var Client = require('twingly-search').Client;

var client = new Client();
var query = client.query();
query.searchQuery = 'github page-size:10 lang:sv';

query.execute(function(error, result){
    if (error != false) {
        console.error(error);
    } else {
        for(var i in result.posts) {
            console.log(result.posts[i].url);
        }
    }
});

The twingly-search library talks to a commercial blog search API and requires an API key. Best practice is to set the TWINGLY_SEARCH_KEY environment variable to the obtained key. Client can be passed a key at initialization if your setup does not allow environment variables.

The library is documented with jsdoc. To generate the documentation run

npm run doc

Example code can be found in examples/.

To learn more about the capabilities of the API, please read the Twingly Search API documentation.

Requirements

Development

Testing

To run all tests simply execute

npm test

Run with test order (per file) randomized by rocha

npm run random

To run a particular test case

npm test test/test_query

or use --grep

npm test -- --grep parser

Release workflow

Docs: npm-version, npm-publish, npm-adduser (npm login is an alias to adduser)

Bump the version in client.js and commit.

Make sure you are logged in as twingly:

npm login

Bump the version:

npm version [<newversion> | major | minor | patch]

Example (current version is 0.0.0):

npm version major

npm version will bump the version in package.json to 1.0.0, make a commit with that change, tag that commit v1.0.0 and push the commit and tag.

Publish the latest version to the registry:

npm publish .

License

The MIT License (MIT)

Copyright (c) 2016 Twingly AB

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.