Skip to main content

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

PropertyType
bio?string
displayName?string
firstName?string
followCount?number
followerCount?number
fullName?string
idnumber
imagestring
isUserHacker?boolean
isUserPro?boolean
lastName?string
roles?UserRole[]
socials?UserSocial[]
url?string
usernamestring

CurrentUserDataInclusion

Options for the currentUser query

PropertyType
includePlan?boolean
includeRoles?boolean
includeSocialData?boolean

EditorPreferences

Editor Preferences

PropertyType
__typenamestring
codeIntelligenceboolean
codeSuggestionboolean
fontSizenumber
indentIsSpacesboolean
indentSizenumber
keyboardHandlerstring
minimapDisplaystring
multiselectModifierKeystring
wrappingboolean

Repl

A Repl

PropertyType
commentCount?number
comments?ReplCommentConnection
descriptionstring
iconUrl?string
idstring
imageUrl?string
isPrivateboolean
likeCount?number
multiplayers?User[]
owner?ReplOwner
publicForkCount?number
runCount?number
slugstring
tags?Tag[]
timeCreatedstring
titlestring
urlstring

ReplComment

A Repl Comment

PropertyType
bodystring
idnumber
userUser

ReplCommentConnection

An array of ReplComments as items

PropertyType
itemsReplComment[]

ReplDataInclusion

Options for repl queries

PropertyType
includeComments?boolean
includeMultiplayers?boolean
includeOwner?boolean
includeSocialData?boolean

ReplOwner

A Repl Owner, can be either a User or a Team

PropertyType
__typenamestring
description?string
idnumber
imagestring
usernamestring

Tag

A Repl tag

PropertyType
idstring
isOfficialboolean

User

A Replit user

PropertyType
bio?string
displayName?string
firstName?string
followCount?number
followerCount?number
fullName?string
idnumber
imagestring
isUserHacker?boolean
isUserPro?boolean
lastName?string
roles?UserRole[]
socials?UserSocial[]
url?string
usernamestring

UserDataInclusion

Options for user queries

PropertyType
includePlan?boolean
includeRoles?boolean
includeSocialData?boolean

UserRole

A user role

PropertyType
idnumber
keystring
namestring
taglinestring

UserSocial

A user social media link

PropertyType
idnumber
typeUserSocialType
urlstring

UserSocialType

An enumerated type of social media links

PropertyType

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;
}>
Was this helpful?