https://snapchat-example-api.herokuapp.com/api/v1/
- All endpoints accept JSON payloads for parameters
- Must include "Content-Type" HTTP header with value "application/json"
- All endpoints accept
/users/authenticate
require theX-Api-Token
HTTP header
- Test Users
- jparishy, atecle, adeluca, zallen, enagele
- All have password: "password" (no quotes)
- POST /users/authenticate
- Parameters
username
- Stringpassword
- 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 /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"}]
- POST /users/push_notification_tokens
- Parameters
token
object that contains avalue
string with the hex representation of the push notification token
- Return
- On success,
200
with the createdtoken
object - On failure,
400
for any invalid or missing parameters
- On success,
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"}}
- 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 benull
)
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"}]
- POST /snaps
- Parameters
to
- Integer OR Array of Integersimage_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"}]
- PUT /snaps/:snap_id/read
- Parameters: None
- Returns
- The snap object that was updated with the
image_url
removed
- The snap object that was updated with the
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 /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}
- 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 "[email protected]"
{"image_url":"https://snapchat-api-photos.s3.amazonaws.com/snaps/snap_dcd02410e1dff942effa0b42f2df8e93.jpg"}
http://snapchat-example-api.herokuapp.com/api/v1/users/authenticate - The page you were looking for doesn't exist.