data API
The data API allows you to get information and metadata exposed from Replit's GraphQL API.
Usage
import { data } from '@replit/extensions';
Methods
data.currentUser
Fetches the current user via graphql
currentUser(args: CurrentUserDataInclusion): Promise<{ user: CurrentUser }>
data.userById
Fetches a user by their id via graphql
userById(args: { id: number } & UserDataInclusion): Promise<{ user: User }>
data.userByUsername
Fetches a user by their username via graphql
userByUsername(args: { username: string } & UserDataInclusion): Promise<{ userByUsername: User }>
data.currentRepl
Fetches the current Repl via graphql
currentRepl(args: ReplDataInclusion): Promise<{ repl: Repl }>
data.replById
Fetches a Repl by its ID via graphql
replById(args: { id: string } & ReplDataInclusion): Promise<{ repl: Repl }>
data.replByUrl
Fetches a Repl by its URL via graphql
replByUrl(args: { url: string } & ReplDataInclusion): Promise<{ repl: Repl }>
Types
CurrentUser
Extended values for the current user
Property | Type |
---|---|
bio? | string |
displayName? | string |
firstName? | string |
followCount? | number |
followerCount? | number |
fullName? | string |
id | number |
image | string |
isUserHacker? | boolean |
isUserPro? | boolean |
lastName? | string |
roles? | UserRole[] |
socials? | UserSocial[] |
url? | string |
username | string |
CurrentUserDataInclusion
Options for the currentUser query
Property | Type |
---|---|
includePlan? | boolean |
includeRoles? | boolean |
includeSocialData? | boolean |
EditorPreferences
Editor Preferences
Property | Type |
---|---|
__typename | string |
codeIntelligence | boolean |
codeSuggestion | boolean |
fontSize | number |
indentIsSpaces | boolean |
indentSize | number |
keyboardHandler | string |
minimapDisplay | string |
multiselectModifierKey | string |
wrapping | boolean |
Repl
A Repl
Property | Type |
---|---|
commentCount? | number |
comments? | ReplCommentConnection |
description | string |
iconUrl? | string |
id | string |
imageUrl? | string |
isPrivate | boolean |
likeCount? | number |
multiplayers? | User[] |
owner? | ReplOwner |
publicForkCount? | number |
runCount? | number |
slug | string |
tags? | Tag[] |
timeCreated | string |
title | string |
url | string |
ReplComment
A Repl Comment
Property | Type |
---|---|
body | string |
id | number |
user | User |
ReplCommentConnection
An array of ReplComments as items
Property | Type |
---|---|
items | ReplComment[] |
ReplDataInclusion
Options for repl queries
Property | Type |
---|---|
includeComments? | boolean |
includeMultiplayers? | boolean |
includeOwner? | boolean |
includeSocialData? | boolean |
ReplOwner
A Repl Owner, can be either a User or a Team
Property | Type |
---|---|
__typename | string |
description? | string |
id | number |
image | string |
username | string |
Tag
A Repl tag
Property | Type |
---|---|
id | string |
isOfficial | boolean |
User
A Replit user
Property | Type |
---|---|
bio? | string |
displayName? | string |
firstName? | string |
followCount? | number |
followerCount? | number |
fullName? | string |
id | number |
image | string |
isUserHacker? | boolean |
isUserPro? | boolean |
lastName? | string |
roles? | UserRole[] |
socials? | UserSocial[] |
url? | string |
username | string |
UserDataInclusion
Options for user queries
Property | Type |
---|---|
includePlan? | boolean |
includeRoles? | boolean |
includeSocialData? | boolean |
UserRole
A user role
Property | Type |
---|---|
id | number |
key | string |
name | string |
tagline | string |
UserSocial
A user social media link
Property | Type |
---|---|
id | number |
type | UserSocialType |
url | string |
UserSocialType
An enumerated type of social media links
Property | Type |
---|
UserSocialType
An enumerated type of social media links
discord = 'discord'
facebook = 'facebook'
github = 'github'
linkedin = 'linkedin'
twitch = 'twitch'
twitter = 'twitter'
website = 'website'
youtube = 'youtube'
CurrentUserQueryOutput
A graphql response for the currentUser query
GraphResponse<{
user: CurrentUser;
}>
GraphResponse<T
>
A graphql response
Promise<T | never>
ReplQueryOutput
A graphql response for the repl query
GraphResponse<{
repl: Repl;
}>
UserByUsernameQueryOutput
A graphql response for the userByUsername query
GraphResponse<{
userByUsername: User;
}>
UserQueryOutput
A graphql response for the user query
GraphResponse<{
user: User;
}>