Skip to content

Instantly share code, notes, and snippets.

@jparishy
Last active September 30, 2025 20:14
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.

Revisions

  1. Julius Parishy revised this gist Jan 29, 2016. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions doc.md
    Original file line number Diff line number Diff line change
    @@ -78,6 +78,8 @@ Example:
    - `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:
    ```
  2. Julius Parishy revised this gist Jan 29, 2016. 1 changed file with 14 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions doc.md
    Original file line number Diff line number Diff line change
    @@ -41,6 +41,20 @@ Example:
    [{"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
  3. Julius Parishy revised this gist Jan 24, 2016. 1 changed file with 19 additions and 4 deletions.
    23 changes: 19 additions & 4 deletions doc.md
    Original file line number Diff line number Diff line change
    @@ -61,15 +61,14 @@ Example:
    - 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

    *Note: In v1 of this API, I did not include the actual image data, the API will populate it with an image automatically. You should still build the UI and application flow as if it were sending a real one though as I will add image uploading in the next day or so*

    Example:
    ```
    ➜ ~ curl -H "X-Api-Token: cddb6686e7b408dc7292ea92bd833243" -H "Content-Type: application/json" -X POST -d '{"to":[3,4]}' https://snapchat-example-api.herokuapp.com/api/v1/snaps
    [{"id":1,"image_url":"http://placekitten.com/1080/1920","created_at":"2016-01-20T04:37:41.528Z","updated_at":"2016-01-20T04:37:41.544Z","unread":true,"to_user_id":3,"from_user_id":1},{"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}]
    ➜ ~ 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
    @@ -96,4 +95,20 @@ 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 "[email protected]"
    {"image_url":"https://snapchat-api-photos.s3.amazonaws.com/snaps/snap_dcd02410e1dff942effa0b42f2df8e93.jpg"}
    ```
  4. Julius Parishy revised this gist Jan 20, 2016. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions doc.md
    Original file line number Diff line number Diff line change
    @@ -64,6 +64,8 @@ Example:
    - Returns
    - 200 with the array of Snaps created

    *Note: In v1 of this API, I did not include the actual image data, the API will populate it with an image automatically. You should still build the UI and application flow as if it were sending a real one though as I will add image uploading in the next day or so*

    Example:
    ```
    ➜ ~ curl -H "X-Api-Token: cddb6686e7b408dc7292ea92bd833243" -H "Content-Type: application/json" -X POST -d '{"to":[3,4]}' https://snapchat-example-api.herokuapp.com/api/v1/snaps
  5. Julius Parishy created this gist Jan 20, 2016.
    97 changes: 97 additions & 0 deletions doc.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,97 @@
    # 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"}]
    ```

    ## 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
    - Returns
    - 200 with the array of Snaps created

    Example:
    ```
    ➜ ~ curl -H "X-Api-Token: cddb6686e7b408dc7292ea92bd833243" -H "Content-Type: application/json" -X POST -d '{"to":[3,4]}' https://snapchat-example-api.herokuapp.com/api/v1/snaps
    [{"id":1,"image_url":"http://placekitten.com/1080/1920","created_at":"2016-01-20T04:37:41.528Z","updated_at":"2016-01-20T04:37:41.544Z","unread":true,"to_user_id":3,"from_user_id":1},{"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}]
    ```

    ### 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}
    ```