Skip to content

Client (OO Wrapper)

Lucas Dohring edited this page Dec 6, 2013 · 3 revisions

This is an OO wrapper for the procedural api.

Constructor

new Client()

Create a new client instance.

Methods

Client#login(String username, String password)

  • username
  • password Sign in to Snapchat. On success, it will return sync data.

Client#register(String username, String email, String password)

  • username
  • email
  • password Register an account. On success, it will return sync data.

Client#logout()

Delete the auth_token property. (No way to really sign out)

Client#sync()

Get new sync data
You must have either signed in or signed up.

Client#clear()

Clear your feed

Client#getBlob(String id)

Fetches a blob (image or video)

  • id The blob's id. This is a number followed by 'r'

Returns a promise of a readable stream. IMPORTANT The stream is paused to prevent data loss. You MUST call resume() on it after setting up your handlers or pipe()ing it.

Client#upload(Stream blob, Boolean isVideo=false)

Upload an blob

  • blob A Readable stream of an image or video to upload. (The official app can view jpeg and pngs images; and mp4 video. It can not view gifs. [possibly more])
  • isVideo Set this to true if you are uploading a video.

Returns a promise of it's media_id

Client#send(String mediaId, Array(String) recipients, Number time=undefined)

Send the snap to people

  • mediaId The blobs's media_id
  • friends A list of people to send the snap to.
  • time How long (in seconds) a snap should be visible. This should only be set if the snap is a picture.

Client#addFriend(String friend)

Add a friend

  • friend The username of your soon-to-be friend

Client#rename(String friend, String newName)

Set a friend's display name.

  • friend The friend to rename.
  • newName Their new display name.

Client#unfriend(String friend)

Remove a friend.

  • friend The friend to remove

Client#privacy(Boolean onlyFriends)

Update your privacy setting

  • onlyFriends If true, only friends can send you snaps.

Client#updateEmail(String email)

Change your email

  • email Your new email