0.1.1 • Published 11 years ago

snooform v0.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
11 years ago

snooform

Transforms the Reddit API into various structured formats. Useful for anyone looking to write an API Wrapper for Reddit.

Output Formats

  • json
  • Node.js
  • AMD
  • ... that's it for now. open an issue / pull request for more

Install

npm

npm install -g snooform

Usage

Command Line

Take a look at the man pages, or the --help flag for more information

man snooform
snooform -h

Node module

var build = require('snooform');

var options = {}; // customize the output

build.jsonApi(options).done(function(output) {
  console.log(output);
});

Data Format (JSON example)

The data format is a flat array of endpoints.

Every endpoint has enough data with it to create a call to the Reddit API. Here is a sample of one endpoint [/r/subreddit]/new:

[
    {
        "path": "/r/$subreddit/new",
        "url": {
            "oauth": "https://oauth.reddit.com/r/$subreddit/new",
            "standard": "http://www.reddit.com/r/$subreddit/new"
        },
        "oauth": [
            "read"
        ],
        "extensions": [
            ".json",
            ".xml"
        ],
        "method": "GET",
        "describe": "This endpoint is a listing.",
        "args": {
            "after": {
                "describe": "fullname of a thing"
            },
            "before": {
                "describe": "fullname of a thing"
            },
            "count": {
                "describe": "a positive integer (default: 0)"
            },
            "limit": {
                "describe": "the maximum number of items desired (default: 25, maximum: 100)"
            },
            "show": {
                "describe": "(optional) the string all"
            }
        }
    },
    {/* another endpoint */},
    {/* and another... */}
]

Url parameters

Sometimes there are parameters in the url. These are represented with a "$" prepending the name of the variable. Given this path, the path in the endpoint will look like:

/api/multi/$multipath/r/$srname

Test

npm test
0.1.1

11 years ago

0.1.0

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago

0.0.0

11 years ago