Git Product home page Git Product logo

node-api-client's Introduction

snoode

Build Status

Someday, it will be a reddit API library.

For now, it handles only a few resources. Building in parallel with reddit-mobile.

Works both client-side and server-side.

Example

// Require snoode.
import { v1 } from 'snoode';
const api = new v1();

// Example call to get links for /r/homebrewing.
api.links.get({
  subredditName: 'homebrewing',
}).then(function(data) {
  console.log(data.body);
});

// Example call to get all comments for this particular listing.
api.comments.get({
  linkId: 't3_ib4bk'
}).then(function(data) {
  console.log(data.body);
});

// Example with auth.
// Pass in an oauth token and new origin to `withConfig`, which returns
// a new instance that inherits the config from the existing api instance
// merged with the new config.

const myOauthToken = 'abcdef1234567890';
const authedAPI = api.withConfig({
  token: myOauthToken,
  origin: 'https://oauth.reddit.com'
});

authedAPI.subscriptions.get().then(function(data) {
  console.log(data.body)
});

Development / Testing

If you chmod +x ./repl, you can start up a repl for testing (and for general use!) An api instance is created in the global scope (api), from which you can call any of the API methods. Use help in the repl to learn more.

Mancy

If you install Mancy you can have a nicer version of using the repl. To set it up, open mancy, and go to Preferences. Under Add node modules path add your local install of Snoode. Then under Startup script add mancyStart.js. You can edit mancyStart.js to include your token and you can then either use api or authed as you'd expect. Mancy supports lots of inspecting and autocomplete tools out of the box.

Example mancyStart.js:

var api = require('mancyLoader.js')
var authed = api.withConfig({
    token: "<YOUR_TOKEN_HERE>",
    origin: "https://oauth.reddit.com"})

Caveats

  • Uses ES7. At reddit, we use babel to run and build ES6+.

node-api-client's People

Contributors

ajacksified avatar arresteddevelopment avatar blha303 avatar curioussavage avatar dwick avatar goldspin avatar jordanmilne avatar nramadas avatar prashtx avatar schwers avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.