Constructor
new SidechatAPIClient(tokenopt, rootUrl)
Create a new instance of the API client
| Name | Type | Attributes | Description |
|---|---|---|---|
token | types. | <optional> | user bearer token |
rootUrl | String | custom API root URL for mocking or using other server |
- Since
- 2.0.0-alpha.0
Members
apiRoot :String
Root URL for every API request
- String
- Default Value
- "https://api.sidechat.lol"
(constant) defaultHeaders :Object
Default headers for every API request
- Object
userToken :types.SidechatAuthToken
User bearer token
- types.
SidechatAuthToken
Methods
authorizeRealtimeChannel(socketID, channelName) → {Promise.<{auth: String}>}
Authorizes a realtime (Pusher) connection to subscribe to a private channel, such as private-chat-<chatID> for live direct messages. Pass the result to your Pusher client's channel authorizer. This hasn't been tested, and is mostly theoretical.
| Name | Type | Description |
|---|---|---|
socketID | String | socket ID assigned by Pusher |
channelName | String | name of the private channel to subscribe to |
- Since
- 2.7.0
signed channel authorization
- Type:
- Promise.<{auth: String}>
blockUser(postID, reportopt, postContextopt)
Blocks the author of a post or comment, hiding all of their content from the user. Replaces hidePostsFromUser.
| Name | Type | Attributes | Description |
|---|---|---|---|
postID | String | alphanumeric ID of a post or comment by the user to block | |
report | Boolean | <optional> | whether or not to also report the content |
postContext | "feed" | | <optional> | where the content was seen |
- Since
- 2.7.0
checkEmailVerification()
Check is the user's email is verified.
- Since
- 1.0.0
checkUsername(username) → {Promise.<Boolean>}
Checks if user can set their username to a string
| Name | Type | Description |
|---|---|---|
username | String | string to check |
- Since
- 2.3.6
whether or not username is valid and unused
- Type:
- Promise.<Boolean>
createComment(parentPostID, text, groupID, replyCommentIDopt, topLevelReplyIDopt, assetListopt, disableDMsopt, anonymousopt) → {Promise.<types.SidechatPostOrComment>}
Creates a comment on a post
| Name | Type | Attributes | Description |
|---|---|---|---|
parentPostID | String | alphanumeric ID of post on which this comment is made | |
text | String | text content of comment | |
groupID | String | alphanumeric ID of group in which the parent post resides | |
replyCommentID | String | <optional> | alphanumeric ID of comment to reply to. Falls back to parentPostID |
topLevelReplyID | String | <optional> | alphanumeric ID of the top-level comment to reply to. Used only when replying to replies. Falls back to parentPostID |
assetList | Array.<types.SidechatSimpleAsset> | <optional> | list of assets to attach |
disableDMs | Boolean | <optional> | prevent direct messages being sent to comment's author |
anonymous | Boolean | <optional> | whether or not to hide user's name and icon on comment |
- Since
- 2.2.0
created comment
- Type:
- Promise.<types.SidechatPostOrComment>
createLinkAttachment(url) → {Promise.<types.SidechatAttachment>}
Creates a link attachment that can be added to a post with createPost(). YouTube links are recognized and shown as embedded videos.
| Name | Type | Description |
|---|---|---|
url | String | URL to attach |
- Since
- 2.7.0
the created attachment
- Type:
- Promise.<types.SidechatAttachment>
createPost(text, groupID, assetListopt, disableDMsopt, disableCommentsopt, anonymousopt, pollOptionsopt, attachmentIDsopt) → {Promise.<types.SidechatPostOrComment>}
Creates a new post in the specified group. Users can only make two posts a minute; if a post is rejected, the thrown error contains the reason from the server.
| Name | Type | Attributes | Description |
|---|---|---|---|
text | String | text content of comment | |
groupID | String | alphanumeric ID of group in which the parent post resides | |
assetList | Array.<types.SidechatSimpleAsset> | <optional> | list of assets to attach. |
disableDMs | Boolean | <optional> | prevent direct messages from being sent to post's author |
disableComments | Boolean | <optional> | whether or not comments should be disabled on post |
anonymous | Boolean | <optional> | whether or not to hide user's name and icon on post |
pollOptions | Array.<String> | <optional> | List of poll options. If provided, a poll will be created with these options. |
attachmentIDs | Array.<String> | <optional> | IDs of link attachments created with createLinkAttachment() |
- Since
- 2.2.0
the created post
- Type:
- Promise.<types.SidechatPostOrComment>
deleteAccount()
Permanently deletes the current user's account. This cannot be undone!
- Since
- 2.7.0
deletePostOrComment(postOrCommentID)
Deletes a post or comment that the user created
| Name | Type | Description |
|---|---|---|
postOrCommentID | String | alphanumeric ID of post to delete |
- Since
- 2.2.0
flagPost(postID, reason, noteopt)
Reports a post or comment to the group's moderators
| Name | Type | Attributes | Description |
|---|---|---|---|
postID | String | alphanumeric ID of post or comment to report | |
reason | types. | why the content is being reported | |
note | String | <optional> | explanation to send along with the report |
- Since
- 2.7.0
getActivity(cursoropt) → {Promise.<types.SidechatActivityList>}
Gets the user's activity feed (notifications for comments, votes, followers, etc.)
| Name | Type | Attributes | Description |
|---|---|---|---|
cursor | types. | <optional> | cursor string |
- Since
- 2.7.0
activity items and cursor
- Type:
- Promise.<types.SidechatActivityList>
getAssetLibrary() → {Promise.<Array.<types.SidechatLibraryAsset>>}
Retrieves the entire accessible asset library. Be warned that as of the time of this documentation, it's a 1.5MB JSON download and this request is very expensive.
- Since
- 2.0.6
- Type:
- Promise.<Array.<types.SidechatLibraryAsset>>
getAvailableGroups(onePage) → {Promise.<Array.<types.SidechatGroup>>}
Gets groups to be displayed on the "Explore Groups" page
| Name | Type | Description |
|---|---|---|
onePage | Boolean | whether or not results should be returned as a single page |
- Since
- 2.0.0-alpha.0
- Type:
- Promise.<Array.<types.SidechatGroup>>
getCurrentUser() → {Promise.<types.SidechatCurrentUser>}
Gets the current authenticated user and a list of the groups of which they are members.
- Since
- 2.1.0
- Type:
- Promise.<types.SidechatCurrentUser>
getDMForPost(postID) → {Promise.<types.SidechatDirectThread>}
Gets the existing direct message thread for a post or comment. Returns undefined if the user hasn't started one.
| Name | Type | Description |
|---|---|---|
postID | String | alphanumeric ID of post or comment |
- Since
- 2.7.0
- Type:
- Promise.<types.SidechatDirectThread>
getDMThread(id) → {Promise.<types.SidechatDirectThread>}
Gets a single direct message thread
| Name | Type | Description |
|---|---|---|
id | String | alphanumeric ID of the chat to fetch |
- Since
- 2.4.4
- Type:
- Promise.<types.SidechatDirectThread>
getDMs(cursoropt) → {Promise.<Array.<types.SidechatDirectThread>>}
Gets a list of the user's direct messages
| Name | Type | Attributes | Description |
|---|---|---|---|
cursor | types. | <optional> | cursor string |
- Since
- 2.4.4
- Type:
- Promise.<Array.<types.SidechatDirectThread>>
getGroupChats()
Retrieves joinable group chats
- Since
- 2.3.5
getGroupInviteLink(groupID) → {Promise.<String>}
Gets a shareable invite link for a group. School groups don't have invite links and will throw an error.
| Name | Type | Description |
|---|---|---|
groupID | String | alphanumeric ID of group |
- Since
- 2.7.0
invite link URL
- Type:
- Promise.<String>
getGroupMetadata(groupIDopt) → {Promise.<types.SidechatGroup>}
Gets the metadata of a group from its ID
| Name | Type | Attributes | Description |
|---|---|---|---|
groupID | String | <optional> | alphanumeric ID of a group to get. Falls back to user's primary group. |
- Since
- 2.1.0
- Type:
- Promise.<types.SidechatGroup>
getGroupPosts(groupID, category, cursoropt, periodopt) → {Promise.<types.SidechatPostsAndCursor>}
Fetches posts from the specified category in a group
| Name | Type | Attributes | Description |
|---|---|---|---|
groupID | String | group ID | |
category | "hot" | | category to filter posts | |
cursor | types. | <optional> | cursor string |
period | "day" | | <optional> | time period to pull top posts from (only if category is "top") |
- Since
- 1.0.0
List of posts and cursor
- Type:
- Promise.<types.SidechatPostsAndCursor>
getGroups() → {Promise.<Array.<types.SidechatGroup>>}
Gets the groups the user is a member of
- Since
- 2.7.0
- Type:
- Promise.<Array.<types.SidechatGroup>>
getHomeFeed(typeopt, schoolGroupIDopt, cursoropt) → {Promise.<types.SidechatFeed>}
Fetches the home feed, which mixes posts from all of the user's groups
| Name | Type | Attributes | Description |
|---|---|---|---|
type | "for_you" | | <optional> | how the feed should be sorted |
schoolGroupID | String | <optional> | alphanumeric ID of the user's school group |
cursor | types. | <optional> | cursor string |
- Since
- 2.7.0
feed items and cursor
- Type:
- Promise.<types.SidechatFeed>
getLeaderboard(groupID) → {Promise.<types.SidechatLeaderboard>}
Gets the yakarma leaderboard for a group, along with the user's own karma
| Name | Type | Description |
|---|---|---|
groupID | String | alphanumeric ID of group |
- Since
- 2.7.0
- Type:
- Promise.<types.SidechatLeaderboard>
getPost(postID, includeDeleted) → {Promise.<types.SidechatPostOrComment>}
Fetches a single post with just its ID
| Name | Type | Description |
|---|---|---|
postID | String | ID of post to fetch |
includeDeleted | Boolean | undocumented |
- Since
- 2.3.0
post object
- Type:
- Promise.<types.SidechatPostOrComment>
getPostComments(postID) → {Promise.<Array.<types.SidechatPostOrComment>>}
Get all the commments on a post
| Name | Type | Description |
|---|---|---|
postID | String | post ID to get comments for |
- Since
- 2.0.0-alpha.0
list of comments
- Type:
- Promise.<Array.<types.SidechatPostOrComment>>
getSuggestedGroups(limitopt) → {Promise.<Array.<types.SidechatGroup>>}
Gets groups suggested for the user to join
| Name | Type | Attributes | Description |
|---|---|---|---|
limit | Number | <optional> | maximum number of groups to return |
- Since
- 2.7.0
- Type:
- Promise.<Array.<types.SidechatGroup>>
getUpdates(groupIDopt)
Get updated status for user and group
| Name | Type | Attributes | Description |
|---|---|---|---|
groupID | String | <optional> | ID of a specific group to retrieve info from. Falls back to user's primary group. |
- Since
- 2.1.0
getUserAndGroup(groupIDopt)
Get updated status for user and group
| Name | Type | Attributes | Description |
|---|---|---|---|
groupID | String | <optional> | ID of a specific group to retrieve info from. Falls back to user's primary group. |
- Since
- 1.0.0
- Deprecated
- since 2.1.0, will be removed by 3.0.0. Please use `getUpdates` instead!
getUserContent(contentType) → {Promise.<Array.<types.SidechatPostOrComment>>}
Fetches the posts or comments that the user has created
| Name | Type | Description |
|---|---|---|
contentType | "posts" | | type of user content to fetch |
- Since
- 2.3.5
post object
- Type:
- Promise.<Array.<types.SidechatPostOrComment>>
getUserPosts(username) → {Promise.<Array.<types.SidechatPostOrComment>>}
Fetches a public user's posts
| Name | Type | Description |
|---|---|---|
username | String | username of the user to fetch |
- Since
- 2.6.0
- Type:
- Promise.<Array.<types.SidechatPostOrComment>>
getUserProfile(username) → {Promise.<types.SidechatProfile>}
Fetches a public user profile
| Name | Type | Description |
|---|---|---|
username | String | username of the user to fetch |
- Since
- 2.6.0
- Type:
- Promise.<types.SidechatProfile>
hidePostsFromUser(postID)
Hides posts from user
| Name | Type | Description |
|---|---|---|
postID | String | alphanumeric ID of post to hide |
- Since
- 2.6.2
- Deprecated
- since 2.7.0. Please use `blockUser` instead!
joinGroupChat(groupChatID, displayName, emoji, primaryColor, secondaryColor)
Joins a group chat. To mimic the official client, use the user's display name and icon by default.
| Name | Type | Description |
|---|---|---|
groupChatID | String | alphanumeric ID of group chat to join |
displayName | String | display name to use in chat |
emoji | String | emoji to use as icon |
primaryColor | String | hex string of primary color |
secondaryColor | String | hex string of secondary color |
- Since
- 2.3.5
loginViaSMS(phoneNumber, useFallbackopt, captchaMethodopt, captchaResponseopt)
Initiate the login process with a phone number. Should be followed up with verifySMSCode(). If the response has an error_code of "captcha_required", the server wants a captcha solved before it will send a code, and the request should be repeated with a captcha response. I haven't been able to recreate this yet, so I honestly don't know what captcha provider they want.
| Name | Type | Attributes | Description |
|---|---|---|---|
phoneNumber | Number | US phone number (WITHOUT +1) to send verification code to | |
useFallback | Boolean | <optional> | send the code through the backup SMS route, which the official app offers when a code doesn't arrive |
captchaMethod | String | <optional> | type of captcha being answered |
captchaResponse | String | <optional> | solved captcha token |
- Since
- 1.0.0
readActivity(activityID)
Marks an activity item as read
| Name | Type | Description |
|---|---|---|
activityID | String | alphanumeric ID of activity object |
- Since
- 2.3.2
registerEmail(email)
Initiate the email setup process. Should be followed up with checkEmailVerification().
| Name | Type | Description |
|---|---|---|
email | String | school email address to send verification code to |
- Since
- 1.0.0
- Tutorials
reportDM(chatID, reason)
Reports a direct message thread
| Name | Type | Description |
|---|---|---|
chatID | String | alphanumeric ID of the thread to report |
reason | types. | why the thread is being reported |
- Since
- 2.7.0
searchAvailableGroups(query) → {Promise.<Array.<types.SidechatGroup>>}
Searches for new groups based on a query keyword
| Name | Type | Description |
|---|---|---|
query | String | the string to search for. This will be encoded, so strings with spaces and special characters are okay. |
- Since
- 2.6.0
- Type:
- Promise.<Array.<types.SidechatGroup>>
sendDM(chatID, text, clientID, assets, anonymous)
Sends a message to an existing direct message thread - note that you must first use startDM() to start a thread.
| Name | Type | Description |
|---|---|---|
chatID | String | alphanumeric ID of the chat to send to |
text | String | text content of message |
clientID | String | alphanumeric device ID |
assets | Array.<types.SidechatAsset> | array of assets to send |
anonymous | Boolean | whether the DM should be sent anonymously |
- Since
- 2.4.4
sendRequest(endpoint, methodopt, bodyopt, headersopt, stripHeadersopt)
Run an arbitrary API request using the current client's authentication
| Name | Type | Attributes | Description |
|---|---|---|---|
endpoint | String | API endpoint to request (e.g. "/v1/posts") | |
method | "GET" | | <optional> | HTTP method to use |
body | Object | <optional> | body to send with the request |
headers | Object | <optional> | custom headers to send with the request |
stripHeaders | Boolean | <optional> | remove the default headers from the request |
- Since
- 2.4.9
setAPIRoot(url)
Manually set the root URL for all API requests. This can be used for mocking requests or redirecting them to a different server
| Name | Type | Description |
|---|---|---|
url | String | new root URL to set |
- Since
- 2.3.9
setAge(age, registrationID, timeZoneopt, inviteLinkURLopt)
Set the user's age. If this function succeeds, the user will be authenticated for future requests.
| Name | Type | Attributes | Description |
|---|---|---|---|
age | Number | user's age in years | |
registrationID | String | the registration ID generated by verifySMSCode() | |
timeZone | String | <optional> | time zone of the user (e.g. "America/Chicago"). Falls back to the system time zone. |
inviteLinkURL | String | <optional> | group invite link that the user signed up through |
- Since
- 1.0.0
setDeviceID(deviceId, bundleIDopt)
Set the device ID of the current user
| Name | Type | Attributes | Description |
|---|---|---|---|
deviceId | String | the device ID to set | |
bundleID | "com. | <optional> | bundle ID of the app the push token belongs to |
- Since
- 1.0.0
setDeviceIdentifier(deviceIdentifier)
Set an identifier for this device, which will be sent with every request in the X-Device-ID header. Should be stable across sessions on the same device.
| Name | Type | Description |
|---|---|---|
deviceIdentifier | String | stable identifier for this device |
- Since
- 2.7.0
setGroupMembership(groupID, isMember)
Joins or leaves a group
| Name | Type | Description |
|---|---|---|
groupID | String | alphanumeric ID of group to join or leave |
isMember | Boolean | whether or not the user should be a member of the group |
- Since
- 2.3.8
setNotificationPreferences(preferences)
Sets which push notifications the user receives
| Name | Type | Description |
|---|---|---|
preferences | types. | notification types to enable or disable |
- Since
- 2.7.0
setPostFollowing(postID, following) → {Promise.<{post: types.SidechatPostOrComment}>}
Follows or unfollows a post. Followed posts send activity notifications when they get new comments.
| Name | Type | Description |
|---|---|---|
postID | String | alphanumeric ID of post |
following | Boolean | whether or not the user should follow the post |
- Since
- 2.7.0
the updated post
- Type:
- Promise.<{post: types.SidechatPostOrComment}>
setToken(token)
Manually set the currently signed in user's token. Generally try to avoid this and instead either pass a token to the constructor or login automatically through the auth functions
| Name | Type | Description |
|---|---|---|
token | types. | user bearer token |
setUserBio(userID, bio)
Sets the bio text of a user
| Name | Type | Description |
|---|---|---|
userID | String | alphanumeric ID of user |
bio | String | text to set as bio |
- Since
- 2.5.6
setUserIcon(userID, emoji, primaryColor, secondaryColor)
Sets the conversation icon of a user
| Name | Type | Description |
|---|---|---|
userID | String | alphanumeric ID of user |
emoji | String | emoji to set as icon |
primaryColor | String | hex string (including #) of primary color |
secondaryColor | String | hex string (including #) of secondary color |
- Since
- 2.2.1
setUsername(userID, username)
Changes the username of the current user
| Name | Type | Description |
|---|---|---|
userID | String | alphanumeric ID of user |
username | String | new username to set |
- Since
- 2.3.6
setVote(postID, action)
Upvote or downvote, or unvote a post
| Name | Type | Description |
|---|---|---|
postID | String | post ID to vote on |
action | types. | whether to upvote, downvote, or reset vote |
- Since
- 2.0.0-alpha.0
startDM(text, clientID, postID, anonymous, postContext)
Creates a new direct message thread
| Name | Type | Description |
|---|---|---|
text | String | text content of message |
clientID | String | alphanumeric ID of devide |
postID | String | alphanumeric ID of post or comment |
anonymous | Boolean | whether the DM should be sent anonymously |
postContext | "feed" | context of post (mostly undocumented, defaults to "feed") |
- Since
- 2.4.4
unhidePostsFromAllUsers()
Unhides all posts from all users
- Since
- 2.6.2
- Deprecated
- since 2.7.0. No longer used by the official app and may stop working.
uploadAsset(uri, mimeType, nameopt, contextopt) → {Promise.<String>}
Uploads an asset to AWS S3 for use in posts and comments. Supports images and videos (videos must be under 50MB and are processed after upload)
| Name | Type | Attributes | Description |
|---|---|---|---|
uri | String | URI of the asset to upload | |
mimeType | String | mimetype of the asset (e.g. "image/png" or "video/mp4") | |
name | String | <optional> | filename of the asset |
context | "post" | | <optional> | where the asset will be used. Videos default to "post_vod_source", which is required for them to be processed into a playable stream. |
- Since
- 2.5.1
URL of the uploaded asset
- Type:
- Promise.<String>
verifyEmailWithThirdParty(authToken, authType, isIncomingFreshmanopt)
Verifies the user's school email by signing in with Google or Microsoft instead of clicking an emailed link. Returns the same object as checkEmailVerification(). This was discovered from me decompiling the new Android app, I haven't tested this but based on the implementation it should work fine and might resolve the problem that a lot of people have with their accounts not being associated with their school automatically.
| Name | Type | Attributes | Description |
|---|---|---|---|
authToken | String | token from the Google or Microsoft sign-in | |
authType | "google" | | provider the token came from | |
isIncomingFreshman | Boolean | <optional> | whether or not the user is an incoming freshman |
- Since
- 2.7.0
- Tutorials
verifySMSCode(phoneNumber, code)
Verify the code sent via SMS with loginViaSMS(). If this function succeeds, the user will be authenticated for future requests.
| Name | Type | Description |
|---|---|---|
phoneNumber | Number | US phone number (WITHOUT +1) that verification code was sent to |
code | String | the verification code |
- Since
- 1.0.0
viewPollResults(pollId)
Marks that the user has viewed results on a poll. Note that this does not actually return the results of the poll.
| Name | Type | Description |
|---|---|---|
pollId | String | alphanumeric ID of poll to vote on |
- Since
- 2.5.4
voteOnPoll(pollId, choiceIndex)
Votes on a poll attached to a post
| Name | Type | Description |
|---|---|---|
pollId | String | alphanumeric ID of poll to vote on |
choiceIndex | Number | index of the choice to vote on |
- Since
- 2.5.4