Skip to content

Instantly share code, notes, and snippets.

@jparishy
Last active May 1, 2024 21:35
Show Gist options
  • Save jparishy/742843f7e3cc2adc4e7b to your computer and use it in GitHub Desktop.
Save jparishy/742843f7e3cc2adc4e7b to your computer and use it in GitHub Desktop.
Snapchat Example API Doc

Snapchat API

Base URL

https://snapchat-example-api.herokuapp.com/api/v1/

Notes

  • All endpoints accept JSON payloads for parameters
    • Must include "Content-Type" HTTP header with value "application/json"
    • All endpoints accept /users/authenticate require the X-Api-Token HTTP header
  • Test Users
    • jparishy, atecle, adeluca, zallen, enagele
    • All have password: "password" (no quotes)

User APIs

Authentication

  • POST /users/authenticate
  • Parameters
    • username - String
    • password - String
  • Returns
    • 401 if Invalid
    • 200 if Valid

Example:

➜  ~  curl -X POST -H "Content-Type: application/json" -d '{"username":"atecle","password":"password"}' http://snapchat-example-api.herokuapp.com/api/v1/users/authenticate
{"user":{"id":2,"username":"atecle"},"api_token":"588886466b8206a50a0be4189f50c54f"}

Get Friends

  • GET /users/friends
  • Parameters: None
  • Returns
    • Array of User Objects

Example:

➜  ~  curl -H "X-Api-Token: cddb6686e7b408dc7292ea92bd833243" https://snapchat-example-api.herokuapp.com/api/v1/users/friends                                                      
[{"id":2,"username":"atecle"},{"id":3,"username":"zallen"},{"id":4,"username":"adeluca"},{"id":5,"username":"enagele"}]

Register Push Notification Tokens

  • POST /users/push_notification_tokens
  • Parameters
    • token object that contains a value string with the hex representation of the push notification token
  • Return
    • On success, 200 with the created token object
    • On failure, 400 for any invalid or missing parameters

Example:

➜  ~  curl -H "X-Api-Token: 12dd1d4eafeebc09c9151eb47bf3b74b" -H "Content-Type: application/json" -X POST -d '{"token":{"value":"blahblahblah"}}' https://snapchat-example-api.herokuapp.com/api/v1/users/push_notification_tokens
{"token":{"value":"blahblahblah"}}

Snap APIs

Get Snaps

  • GET /snaps
  • Parameters: None
  • Returns
    • 200 with array of snaps
    • Includes outgoing and incoming snaps
    • Snaps previously marked as read do not contain an image_url (it will be null)

Example:

➜  ~  curl -H "X-Api-Token: cddb6686e7b408dc7292ea92bd833243" https://snapchat-example-api.herokuapp.com/api/v1/snaps                                                      
[{"id":1,"image_url":"http://placekitten.com/1080/1920","from_user":{"id":1,"username":"jparishy"},"unread":true,"created_at":"2016-01-20T04:37:41.528Z"},{"id":2,"image_url":"http://placekitten.com/1080/1920","from_user":{"id":1,"username":"jparishy"},"unread":true,"created_at":"2016-01-20T04:37:41.553Z"},{"id":3,"image_url":"http://placekitten.com/1080/1920","from_user":{"id":2,"username":"atecle"},"unread":true,"created_at":"2016-01-20T04:38:53.092Z"}]

Send a Snap

  • POST /snaps
  • Parameters
    • to - Integer OR Array of Integers
    • image_url - String of the S3 URL for the Image returned by the Media API endpoint /media/upload
  • Returns
    • 200 with the array of Snaps created
  • Notes:
    • Sends a push notification to all of the devices of the to users.

Example:

➜  ~  curl -H "X-Api-Token: cddb6686e7b408dc7292ea92bd833243" -H "Content-Type: application/json" -X POST -d '{"to":1, "image_url":"https://snapchat-api-photos.s3.amazonaws.com/snaps/snap_dcd02410e1dff942effa0b42f2df8e93.jpg"}' https://snapchat-example-api.herokuapp.com/api/v1/snaps 
[{"id":42,"image_url":"https://snapchat-api-photos.s3.amazonaws.com/snaps/snap_dcd02410e1dff942effa0b42f2df8e93.jpg","to_user":{"id":1,"username":"jparishy"},"from_user":{"id":1,"username":"jparishy"},"unread":true,"created_at":"2016-01-24T02:32:39.708Z"}]

Mark a Snap as Read

  • PUT /snaps/:snap_id/read
  • Parameters: None
  • Returns
    • The snap object that was updated with the image_url removed

Example:

➜  ~  curl -H "X-Api-Token: cddb6686e7b408dc7292ea92bd833243" -X PUT https://snapchat-example-api.herokuapp.com/api/v1/snaps/3/read
{"id":3,"image_url":null,"created_at":"2016-01-20T04:38:53.092Z","updated_at":"2016-01-20T04:49:15.607Z","unread":false,"to_user_id":1,"from_user_id":2}

Get a Single Snap by ID

  • GET /snaps/:snap_id
  • Parameters: None
  • Returns
    • The snap object
    • 404 if not found
    • 401 if not for you

Example:

➜  ~  curl -H "X-Api-Token: cddb6686e7b408dc7292ea92bd833243" https://snapchat-example-api.herokuapp.com/api/v1/snaps/2            
{"id":2,"image_url":"http://placekitten.com/1080/1920","created_at":"2016-01-20T04:37:41.553Z","updated_at":"2016-01-20T04:37:41.558Z","unread":true,"to_user_id":4,"from_user_id":1}

Media

Upload an Image

  • POST /media/upload
  • Parameters:
    • file - The image using URL encoded form image uploading
  • Returns:
    • image_url - A dictionary containing the URL to the uploaded image on S3

Example:

➜  Desktop  curl -X POST -H "X-Api-Token: af92581a0a48bc113fd3dda4ce543101" https://snapchat-example-api.herokuapp.com/api/v1/media/upload -F "file=@pul.gif"
{"image_url":"https://snapchat-api-photos.s3.amazonaws.com/snaps/snap_dcd02410e1dff942effa0b42f2df8e93.jpg"}
@alex37529
Copy link

http://snapchat-example-api.herokuapp.com/api/v1/users/authenticate - The page you were looking for doesn't exist.

@jakestrouse00
Copy link

Is this project still supported? Your API page seems to be down.

@pj0620
Copy link

pj0620 commented Jul 3, 2021

Any updates on this??

@Ziut3k-dev
Copy link

Any updates on this??

i think no, but i want to build my own scraper as Node App.
Let's do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment