Happn REST API - skipperbent/happn-php-sdk GitHub Wiki

Happn REST API

A more recently updated description of the API could be find here: https://github.com/rickhousley/happn/wiki/Happn-REST-API - mfld-fr

Overview

Current version: 19.1.0 (Android)

Except for the Facebook authentication, where a web browser is needed to display the authentication dialog, the API is exercised with the CURL command for the portability of the given examples.

All the HTTP requests shall contain the common following headers:

User-Agent: Happn/19.1.0 AndroidSDK/19

For readability, the CURL command lines only set the operation-specific headers, not the whole set of headers. So remember to add the following option to all the below CURL invocations:

-H 'User-Agent: Happn/19.1.0 AndroidSDK/19'

Authentication

Facebook authentication

Using your favorite web browser, get an access token from Facebook for the registered Happn application:

https://www.facebook.com/dialog/oauth?client_id=247294518656661&redirect_uri=https://www.happn.fr&scope=basic_info&response_type=token

TODO: Identify the minimal scope required by Happn to create the user's account for the first time (minimal scope "basic_info" allows to renew the FB token if the Happn account was already created). Untested scope items are: email, public_profile, user_about_me, user_activities, user_birthday, user_education_history, user_friends, user_interests, user_likes, user_location, user_photos, user_relationship_details

After the authentication dialog, your browser is redirected by Facebook to the Happn website, and the token is part of the URL displayed in the address bar:

https://www.happn.com/en/#access_token=XXXXX&expires_in=5183805

Token can be verified with: https://developers.facebook.com/tools/debug/accesstoken

Use the returned Facebook access token XXXXX to authenticate with Happn, and keep in mind to check its expiration time (it is quite long, but not infinite).

Access & refresh tokens

Happn has internally the following client credentials:

client_id=FUE-idSEP-f7AqCyuMcPr2K-1iCIU_YlvK-M-im3c (as YYYYY)
client_secret=brGoHSwZsPjJ-lBk0HqEXVtb3UFu-y5l_JcOjD-Ekv (as ZZZZZ)

Happn has the following default scope:

achievement_type_read      GET /api/achievement_types/
countries_read             GET /api/countries/
language_read              GET /api/languages/
locale_read
pack_read
subscription_type_read
report_type_read
user_mode_read
notification_type_read     _GET /api/notification_types/ does not work_
search_user
all_user_read
all_image_read
user_device_create
user_device_read           GET /api/users/<user_id>/devices/
user_device_update
user_device_delete
user_position_read
user_position_update
user_notifications_read
user_poke_create
user_message_create
user_message_read
user_message_update
user_message_delete
user_image_create
user_image_read
user_image_update
user_image_delete
user_conversation_create
user_conversation_read
user_conversation_update
user_conversation_delete
user_order_create
user_order_read
user_order_update
user_applications_read
user_applications_update
user_applications_delete
user_blocked_read
user_blocked_create
user_blocked_delete
user_accepted_read
user_accepted_create
user_accepted_delete        _looks like one could revise his opinion, not as in the application_
user_rejected_read
user_rejected_create
user_rejected_delete
user_subscription_create
user_subscription_read
user_subscription_update
user_subscription_delete
user_achievement_create
user_achievement_read
user_achievement_update
user_achievement_delete
user_availability_create
user_availability_read
user_availability_update
user_availability_delete
user_social_create
user_social_read
user_social_update
user_social_delete
user_update
user_delete
user_read
user_report_read
user_report_create
user_report_update
user_report_delete

Request an access token and a refresh token from Happn:

curl -k -X POST \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
-d 'client_id=YYYYY&client_secret=ZZZZZ&grant_type=assertion&assertion_type=facebook_access_token&assertion=XXXXX&scope=mobile_app' \
'https://api.happn.fr/connect/oauth/token'

Happn JSON response:

{"access_token":"TTTTT","expires_in":172800,"scope":".....","user_id":"UUUUU","is_new":false,"refresh_token":"VVVVV","error_code":0}

Use the access token TTTTT, refresh token VVVVV and user identifier UUUUU.

If requesting tokens for the first time, the response delay is quite long, because Happn fetches the user's profile data from Facebook before returning a new user identifier.

Tokens refresh

Avoid requesting a new access token after expiration of the old one (resulting in response delay), and prefer refreshing the tokens:

curl -k -X POST -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
-d 'grant_type=refresh_token&refresh_token=VVVVV&client_id=YYYYY&client_secret=ZZZZZ' \
'https://api.happn.fr/connect/oauth/token'

Use the new access token TTTTT, new refresh token VVVVV and check the user identifier UUUUU (should be the same as the one returned during first authentication).

User confirmation

Service informations

Countries

Langages

Report types

Achievement types

Devices

Creating new device

Location

With location URL

With device URL

User information

Self information

Other information

  • is_accepted: 1 = other has accepted you
  • distance: rounded to 249 (within 250 meters), 499 (within 500 meters) and above
  • my_relation: 0 = none, 1 = accepted by me, 4 = mutual acceptance

Accepting and rejecting

Accepting (aka "Liking")

Accepted users

Rejecting (aka "Blocking")

Rejected users

Poking (aka "Charming")

Notifications

Notification types

  • 468: NEAR_YOU (within 500 meters radius, now or before)
  • 471: ???

Notifications list

Conversations

Conversations list

Mark message as read

Post message

⚠️ **GitHub.com Fallback** ⚠️