├── .gitignore ├── LICENSE.txt ├── README.md ├── lib ├── client.js ├── requester.js └── utilities.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) [2014] [Hung Tran] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Tinder Pro 2 | ========== 3 | A wrapper for the Tinder API 4 | 5 | Installation 6 | ------------ 7 | via `npm` 8 | 9 | ``` 10 | npm install tinder_pro 11 | ``` 12 | 13 | via `git` 14 | 15 | ``` 16 | git clone https://github.com/tranhungt/tinder_pro.git 17 | ``` 18 | 19 | Getting the Facebook OAUTH Tokens 20 | --------------------------------- 21 | In order to use the API, you will need the facebook oauth token. To get the facebook oauth token, it's best to use a proxy service such as [Charles Proxy](http://www.charlesproxy.com/). You can set up Charles Proxy by following a simple walkthrough here: 22 | 23 | [http://hungtran.co/discovering-tinders-private-api/](http://hungtran.co/discovering-tinders-private-api/) 24 | 25 | After setting up the proxy, initiate the tinder app on your phone, and you will see the http request to `https://api.gotinder.com/auth`. Check the request json body, and you will see something like 26 | 27 | ```javascript 28 | { 29 | "facebook_token": "CAAGm0PX4ZCps............", 30 | 31 | "facebook_id": "761..." 32 | } 33 | ``` 34 | 35 | Usage 36 | ----- 37 | 38 | ###Authenticating 39 | With the facebook auth token, you can plug it into the app's auth. 40 | 41 | ```javascript 42 | var FACEBOOK_ID = "761..." 43 | 44 | var FACEBOOK_TOKEN = "BAAGm0PX4ZCps............" 45 | 46 | var TinderPro = require('tinder_pro') 47 | var tinder = new TinderPro() 48 | 49 | tinder.sign_in(FACEBOOK_ID, FACEBOOK_TOKEN, function(err, res, body){}) 50 | ``` 51 | 52 | Every function is an asynchronous request to Tinder's API, therefore takes a callback with the params `callback(err, res, body)` that reflects the API's response. 53 | 54 | ###Interacting with Users 55 | ```` 56 | .get_nearby_users(callback) 57 | ``` 58 | 59 | Returns an array of json user objects. 60 | 61 | ``` 62 | .like(user_id, callback) 63 | ``` 64 | 65 | Likes a user, equivalent of swiping right. 66 | 67 | 68 | ``` 69 | .dislike(user_id, callback) 70 | ``` 71 | 72 | Passes on the user. 73 | 74 | ``` 75 | .send_message(user_id, message, callback) 76 | ``` 77 | 78 | Sends a message to the user. You can only do this to users whom you've been matched with. 79 | Generally used after you call `.like` and the response body.match is true. 80 | 81 | ``` 82 | .fetch_updates(callback) 83 | ``` 84 | Gets updates from your last visit, ie. messages, likes, blocks. 85 | 86 | 87 | ###Updating preferences 88 | ``` 89 | .update_search_distance(distance, callback) 90 | ``` 91 | 92 | Takes an integer distance in miles and updates your search distance preference. 93 | 94 | ``` 95 | .update_location(latitude, longitude, callback) 96 | ``` 97 | 98 | Updates your current position. Latitude and longitude are float precision. 99 | 100 | 101 | Credits 102 | ------- 103 | Copyright © 2014 Hung Tran 104 | 105 | Released under the MIT License, which can be found in the repository in `LICENSE.txt`. 106 | -------------------------------------------------------------------------------- /lib/client.js: -------------------------------------------------------------------------------- 1 | var Requester = require('./requester') 2 | var utils = require('./utilities') 3 | 4 | var URLS = { 5 | update_location: 'user/ping', 6 | like: 'like/#{user_id}', 7 | dislike: 'pass/#{user_id}', 8 | get_nearby_users: 'user/recs', 9 | get_user_info: 'user/#{user_id}', 10 | send_message: 'user/matches/#{user_id}', 11 | profile: 'profile', 12 | fetch_updates: 'updates' 13 | } 14 | 15 | var Client = function(){ 16 | this.requester = new Requester() 17 | } 18 | 19 | Client.prototype.fetch_updates = function(callback){ 20 | var url = URLS.fetch_updates 21 | var date = new Date() 22 | return this.requester.post_request( 23 | url, 24 | { 25 | last_activity_date: date.toISOString() 26 | }, 27 | callback 28 | ) 29 | } 30 | 31 | Client.prototype.get_user_info = function(user_id, callback){ 32 | var url = URLS.get_user_info 33 | url = utils.interpolate_string(url, user_id) 34 | return this.requester.get_request(url, callback) 35 | } 36 | 37 | Client.prototype.get_nearby_users = function(callback){ 38 | var url = URLS.get_nearby_users 39 | return this.requester.get_request(url, callback) 40 | } 41 | 42 | Client.prototype.like = function(user_id, callback){ 43 | var url = URLS.like 44 | url = utils.interpolate_string(url, user_id) 45 | return this.requester.get_request(url, callback) 46 | } 47 | 48 | Client.prototype.update_search_distance = function(distance, callback){ 49 | var url = URLS.profile 50 | var data = {distance_filter: distance} 51 | return this.requester.post_request(url, data, function(err, res, body){ 52 | if(callback) callback(err, res, body) 53 | }) 54 | } 55 | 56 | Client.prototype.send_message = function(user_id, message, callback){ 57 | var url = URLS.send_message 58 | url = utils.interpolate_string(url, user_id) 59 | var data = {message: message} 60 | return this.requester.post_request(url, data, callback) 61 | } 62 | 63 | Client.prototype.dislike = function(user_id, callback){ 64 | var url = utils.interpolate_string(URLS.dislike, user_id) 65 | return this.requester.get_request(url, callback) 66 | } 67 | 68 | Client.prototype.sign_in = function(facebook_id, facebook_token, callback){ 69 | return this.requester.auth_request(facebook_id, facebook_token, callback) 70 | } 71 | 72 | Client.prototype.update_location = function(latitude, longitude, callback){ 73 | var data = {lat: latitude, lon: longitude} 74 | return this.requester.post_request(URLS.update_location, data, callback) 75 | } 76 | 77 | module.exports = Client -------------------------------------------------------------------------------- /lib/requester.js: -------------------------------------------------------------------------------- 1 | var request = require('request') 2 | var request = request.defaults({jar: true}) 3 | var _ = require('underscore') 4 | var jsesc = require('jsesc') 5 | var utils = require('./utilities') 6 | var util = require('util') 7 | 8 | var Requester = function(){ 9 | this.auth_token = ''; 10 | this.base_uri = 'https://api.gotinder.com/'; 11 | } 12 | 13 | Requester.prototype.auth_request = function(facebook_id, facebook_token, callback){ 14 | var data = { 15 | facebook_id: facebook_id, 16 | facebook_token: facebook_token 17 | } 18 | var that = this 19 | this.post_request( 20 | 'auth', data, 21 | function(err, res, body){ 22 | that.auth_token = body.token 23 | if(callback) callback(err, res, body) 24 | } 25 | ) 26 | } 27 | 28 | Requester.prototype.get_request = function(endpoint, callback){ 29 | url = utils.resolve_url(this.base_uri, endpoint) 30 | request({method: 'GET', url: url, headers: this.all_headers(), json:true}, 31 | function(err, res, body){ 32 | if(callback) callback(err, res, body) 33 | }) 34 | } 35 | 36 | Requester.prototype.post_request = function(endpoint, data, callback){ 37 | url = utils.resolve_url(this.base_uri, endpoint) 38 | request({method: 'POST', url: url, body: data, headers: this.all_headers(), json: true}, 39 | function(err, res, body){ 40 | if(callback) callback(err, res, body) 41 | }) 42 | } 43 | 44 | Requester.prototype.all_headers = function(){ 45 | return _.extend(this.default_headers(), this.auth_headers()) 46 | } 47 | 48 | Requester.prototype.auth_headers = function(){ 49 | if(this.auth_token){ 50 | return { 51 | "X-Auth-Token": this.auth_token, 52 | "Authorization": jsesc( 53 | 'Token token="' + this.auth_token + '"', 54 | {quotes: 'double'} 55 | ) 56 | } 57 | } 58 | else{ 59 | return {} 60 | } 61 | } 62 | 63 | Requester.prototype.default_headers = function(){ 64 | return { 65 | 'User-Agent': 'Tinder/4.0.4 (iPhone; iOS 7.1.1; Scale/2.00)' 66 | } 67 | } 68 | 69 | module.exports = Requester 70 | -------------------------------------------------------------------------------- /lib/utilities.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | resolve_url: function(base_uri, path){ 3 | return base_uri + path; 4 | }, 5 | interpolate_string: function(url, data){ 6 | regex = /#{.+}/; 7 | return url.replace(regex, data); 8 | } 9 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Hung Tran", 3 | "name": "tinder_pro", 4 | "description": "API Wrapper for Tinder app", 5 | "version": "1.0.4", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/tranhungt/tinder_pro.git" 9 | }, 10 | "keywords": ["tinder", "api", "wrapper", "tinderjs", "bot", "tinderbot"], 11 | "main": "./lib/client.js", 12 | "dependencies": { 13 | "request": "2.36.0", 14 | "jsesc": "0.4.3", 15 | "underscore": "~1.6.0" 16 | }, 17 | "devDependencies": {}, 18 | "optionalDependencies": {}, 19 | "engines": { 20 | "node": "*" 21 | } 22 | } 23 | --------------------------------------------------------------------------------