Giter Site home page Giter Site logo

tinderjs's Introduction

tinderjs-browserify

Programmatic access to the Tinder API

Installation

$ npm install tinderjs

Introduction

tinderjs is a simple node.js wrapper around the Tinder API. Below is a simple example which gets a list of nearby profiles and prints them out:

var tinder = require('tinderjs');
var client = new tinder.TinderClient();

client.authorize(
  <fb user token>,
  <fb user id>,
  function() {
    client.getRecommendations(10, function(error, data){
      console.log(data.results);
    });
  });
});

Supported APIs

.authorize(fb token, fb id, callback)

Authorizes the TinderClient. You must call this before any other method.

  • fb token is a facebook user access token. You would acquire this by having your user log in using your application
  • fb id is the id of the facebook user
  • callback is called when the request completes

.getDefaults()

Returns information from tinder about your client, where you can find your user data and also globals (e.g: recs_size) that allows you to interact where api timeouts and limits.

.userId

Once authorized, this property will be set the current profile's tinder user id.

.sendMessage(match id, message, callback)

Sends a message to a user.

  • match id is the match id
  • message is the message to send.
  • callback is called when the request completes

.like(user id, callback)

Likes a user (swipes right).

  • user id is the user's id. This is obtained e.g via getRecommendations
  • callback is called when the request completes

.pass(user id, callback)

Pass on a user (swipes left).

  • user id is the user's id. This is obtained e.g via getRecommendations
  • callback is called when the request completes

.getRecommendations(limit, callback)

Gets nearby users

  • limit is how many results to limit the search to
  • callback is called when the request completes

.getUpdates(callback)

Checks for updates. The response will show you new messages, new matches, new blocks, etc.

  • callback is called when the request completes

.getHistory(callback)

Gets the complete history for the user (all matches, messages, blocks, etc.).

NOTE: Old messages seem to not be returned after a certain threshold. Not yet sure what exactly that timeout is. The official client seems to get this update once when the app is installed then cache the results and only rely on the incremental updates

  • callback is called when the request completes

.updatePosition(longitude, latitude, callback)

Updates your profile's geographic position

  • longitude is the longitude of the new position
  • latitude is the latitude of the new position
  • callback is called when the request completes

.getUser(user id, callback)

Get user information by id

  • user id is the user's id. This is obtained e.g via getRecommendations
  • callback is called when the request completes

Examples

The following example authorizes a client, gets some nearby profiles, likes all of them, and sends a message to any of the ones that match

var tinder = require('tinderjs');
var client = new tinder.TinderClient();
var _ = require('underscore')

client.authorize(
  <fb user token>,
  <fb user id>,
  function() {
    
    var defaults = client.getDefaults()
    var recs_size = defaults.globals.recs_size;
    
    client.getRecommendations(recs_size, function(error, data){
      _.chain(data.results)
        .pluck('_id')
        .each(function(id) {
          client.like(id, function(error, data) {
            if (data.matched) {
              client.sendMessage(id, "hey ;)");
            }
          });
        });
    });
  });
});

License

MIT

tinderjs's People

Contributors

mfkp avatar akawry avatar alkawryk avatar perezpaya avatar tomlandia avatar stevenirby avatar yefim avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar  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.