Api Libraries Powered And Created by Alpaca
Tired of maintaining API libraries in different languages for your website API? This is for you
You have an API for your website but no API libraries for whatever reason? This is for you
You are planning to build an API for your website and develop API libraries? This is for you
You define your API according to the format given below, alpaca builds the API libraries along with their documentation. All you have to do is publishing them to their respective package managers.
Join us at gitter if you need any help. Or at #alpaca
on freenode IRC.
You can download the binaries
- Architecture i386 [ linux / darwin / freebsd / openbsd ]
- Architecture amd64 [ linux / darwin / freebsd / openbsd ]
- Architecture arm [ linux / freebsd ]
Or by using deb packages
Or by using golang
# Clone the project into your golang workspace
$ git clone git://github.com/pksunkara/alpaca
$ cd alpaca
# Install program
$ make && make install
You can find some api definitions in the examples directory. The api libraries generated are at https://github.com/alpaca-api
Completed api definitions are buffer.
$ alpaca </path/to/dir>
The path here should be a directory with api.json
, pkg.json
, doc.json
All the following fields are required unless mentioned.
{
"name": "Example", // Name of the api (also used as class name for the library)
"package": "example-alpaca", // Name of the package
"version": "0.1.0", // Version of the package
"url": "https://exampleapp.com", // URL of the api
"keywords": ["alpaca", "exampleapp", "api"], // Keywords for the package
"official": false, // Are the api libraries official?
"author": {
"name": "Pavan Kumar Sunkara", // Name of the package author
"email": "pavan.sss1991@gmail.com", // Email of the package author
"url": "http://github.com/pksunkara" // URL of the package author
},
"git": { // Used in the package definition
"site": "github.com", // Name of the git website
"user": "alpaca-api", // Username of the git website
"name": "buffer" // Namespace of the git repositories
},
"license": "MIT", // License of the package
"php": { // Required only if creating php api lib
"vendor": "pksunkara" // Packagist vendor name for the package
},
"python": { // Required only if creating python api lib
"license": "MIT License" // Classifier of the license used for the module
}
}
All the following fields are required unless mentioned.
{
"base": "https://exampleapp.com", // Base URL of the api
"version": "v1", // Default version for the api (https://api.example.com{/version}/users) [optional]
"no_verify_ssl": "true", // Do not verify SSL cert [optional] (default: false)
"authorization": { // Authorization strategies
"basic" : true, // Basic authentication [optional] (default: false)
"header": true, // Token in authorization header [optional] (default: false)
"oauth" : true // OAUTH authorization [optional] (default: false)
},
"request": { // Settings for requests to the api
"formats": { // Format of the request body
"default": "form", // Default format for the request body [optional] (default: raw)
"json": true // Support json? [optional] (default: false)
}
},
"response": { // Settings for responses from the api
"formats": { // Format of the response body
"default": "json", // Default response format. Used when 'suffix' is true [optional] (default: html)
"json": true // Support json? [optional] (default: false)
},
"suffix": true // Should the urls be suffixed with response format? [optional] (default: false)
},
"error": { // Required if response format is 'json'
"message": "error" // The field to be used from the response body for error message
},
"class": { // The classes for the api
"users": { // Name of a class of the api
"args": ["login"], // Arguments required for the api class [optional]
"profile": { // Name of a method of the api
"path": "/users/:login/profile", // Url of the api method
"method": "post", // HTTP method of the api method [optional] (default: get)
"params": ["bio"] // Arguments required for the api method [optional]
}
}
}
}
The following is filled according to the entries in api.json
{
"users": { // Name of a class of the api
"title": "Users", // Title of the api class
"desc": "Returns user api instance", // Description of the api class
"args": [{
"desc": "Username of the user", // Description of the argument
"value": "pksunkara" // Value of the argument in docs
}],
"profile": { // Name of a method of the api
"title": "Edit profile", // Title of the api method
"desc": "Edit the user's profile", // Description of the api method
"params": [{
"desc": "Short bio in profile", // Description of the argument
"value": "I am awesome!" // Value of the argument in docs
}]
}
}
}
Supported request formats are raw
, form
, json
.
The formats raw
and form
are always true.
Supported response formats are html
, json
.
The format html
is always true.
Supported are basic
, header
, oauth
- node: https://npmjs.org
- php: https://packagist.org
- python: https://pypi.python.org
- ruby: https://rubygems.org
Check here to learn about testing.
Here is a list of Contributors
I accept pull requests and guarantee a reply back within a day
- Support YAML configuration
- Add support for XML
- Add support for CSV
- HTTP Method Overloading
- What about file uploads?
- Check returned status code
- Special case for 204:true and 404:false
- Pagination support
- Classes inside classes (so on..)
- Validations for params/body in api methods
- Allow customization of errors
- Tests for libraries (lots and lots of tests)
- Optional params available
- Return types of api calls
- The descriptions should be wrapped
- Align @param descriptions
- Support Java, Go, Perl, Clojure, Scala, Obj-C
- Build API docs (Resulting in bloated definitions?)
- Build cli tool for APIs (bash? python? go?)
MIT/X11
Report here. Guaranteed reply within a day.
Pavan Kumar Sunkara (pavan.sss1991@gmail.com)