npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

apiaryio

v1.0.5

Published

Command-line utility for apiary.io

Downloads

259

Readme

Apiary.io command-line tool

This tool allows to fetch and publish API Blueprint documentation into Apiary.io.

Install

npm install -g apiaryio

Use CLI

CLI tool allows to fetch and publish API Blueprint file from any environment. It may be useful in CI processes. Use apiary help to see full list of commands.

Fetch blueprint

Saves blueprint to local file.

apiary fetch <api_name> <token> --path=apiary.apib

Publish blueprint

Publishes blueprint to Apiary. Overwrites existing documentation.

apiary publish <api_name> <token> --path=apiary.apib

Preview blueprint

Open docs (http://docs.api_name.apiary.io) in browser.

apiary preview <api_name>

Use in code

var apiary = require('apiaryio');

// Publish code

apiary.publish("<API Blueprint source code>", "<api_name>", "<token>", function () {
    console.log("Docs successfully published");
}, function () {
    console.error("Error publishing docs");
});

// Fetch code

apiary.fetch("<api_name>", "<token>", function (code) {
    console.log("Blueprint content:")
    console.log(code);
}, function () {
    console.log("Error fetching docs");
});

Use in gulp with aglio

The best way to manage apiary docs is to use aglio. It allows to split huge API Blueprint file to small pieces with its own include mechanism.

Example of gulp file:

var gulp = require('gulp');
var gutil = require('gulp-util');
var gaglio = require('gulp-aglio');
var aglio = require('aglio');
var fs = require('fs');
var request = require('request');
var apiary = require('apiaryio');

var apiaryApiName = process.env.APIARY_NAME;
var apiaryApiKey = process.env.APIARY_KEY;

gulp.task('default', ['html'], function () {
});

gulp.task('compile', function (callback) {
    aglio.compileFile('api/main.apib', 'apiary.apib', function () {
        console.log("Compiled apiary.apib");
        callback();
    });
});

gulp.task('html', ['compile'], function () {
    gulp.src('apiary.apib')
        .pipe(gaglio({template: 'default'}))
        .on('error', gutil.log)
        .pipe(gulp.dest('html'));
    console.log("Rendered to html/apiary.html");
});

gulp.task('watch', ['html'], function () {
    gulp.watch('api/**/*.apib', ['html']);
});

gulp.task('publish', ['compile'], function (callback) {
    fs.readFile('apiary.apib', 'utf8', function (err, code) {
        apiary.publish(code, apiaryApiName, apiaryApiKey, function () {
            console.log("Successfully published to apiary.io!");
            console.log("http://docs." + apiaryApiName + ".apiary.io/");
            callback();
        }, function (response, body) {
            console.warn("Publish error");
            console.log('Response:', body);
            process.exit(1);
        });
    });
});

Help is required

I am not node.js developer, so any help is appreciated.

This library needs a refactoring and better error handling.

Thanks

Thanks to Apiary.io team for support.