Odnoklassniki REST API client for node

npm install ok.ru
26 downloads in the last month

Ok.ru API with node

This npm module allows you to simplify making API requests into odnoklassniki REST API.

Example usage

ok = require("ok.ru")

# Basic configuration params
requestOptions = {
  applicationSecretKey: '{secretKey}',
  applicationKey: '{applicationKey}',
  applicationId: '{applicationId}',

# You can specify accessToken in requestOptions or separately
# For example: if you have many users and you whant to iterate through them

# All data passed in Object
ok.post { method: 'group.getUserGroupsV2' }, (err, data) ->
  # Some actions with data

# You can also specify types of requests
ok.post, ok.get

# Or pass in, as argument
new ok.api 'get', { method: 'users.isAppUser' }, (err, data) ->
  # some actions with data

# It properly handle errors
ok.setAccessToken('invalid_token') # Invalid token

new ok.api 'get', { method: 'users.isAppUser' }, (err, data, response) ->
  # some actions with data
  alert "Alarm! Error! #{err}" if err?
  # It can transport all response and headers
  console.log response

Refresh user token method

ok.refresh '{refresh_token}', (err, data) ->
  data.access_token # new token

Test it!

Add your params at test/settings.yml and you are ready to go!
$ mocha



  • What do you need? Let me know or fork.
npm loves you