@bhavjit/khan-api
Version:
A Khan Academy API client and wrapper
845 lines (830 loc) • 130 kB
TypeScript
/**
* @file Low-level enums with one-to-one mappings to the API
*/
/** */
declare enum ServiceErrorCode {
DOWNSTREAM_SERVICE_ERROR = "DOWNSTREAM_SERVICE_ERROR"
}
declare enum ServiceErrorName {
users = "users"
}
declare enum UserAccessLevel {
COACH = "COACH",
PUBLIC = "PUBLIC"
}
declare enum ProgramEditorType {
pjs = "pjs",
webpage = "webpage",
ace_sql = "ace_sql",
unknown = ""
}
declare enum FeedbackFocusKind {
Challenge = "Challenge",
Interactive = "Interactive",
Project = "Project",
Scratchpad = "Scratchpad",
Talkthrough = "Talkthrough"
}
/**
* @remarks
* Not all feedback types are supported by every query/mutation.
*
* @link {@link https://khan-api.bhavjit.com/reference/view/19553924/2s8YzQUiXU#afc29a01-a4d7-45db-bb1f-82ea66eb210a | Reference}
*/
declare enum FeedbackType {
ALL_PROJECT_ANSWER = "ALL_PROJECT_ANSWER",
ALL_PROJECT_QUESTION = "ALL_PROJECT_QUESTION",
ANSWER = "ANSWER",
COMMENT = "COMMENT",
PROGRAM = "PROGRAM",
PROJECTFEEDBACK = "PROJECTFEEDBACK",
PROJECT_CRITIQUE_ANSWER = "PROJECT_CRITIQUE_ANSWER",
PROJECT_CRITIQUE_QUESTION = "PROJECT_CRITIQUE_QUESTION",
PROJECT_EVAL_ANSWER = "PROJECT_EVAL_ANSWER",
PROJECT_EVAL_QUESTION = "PROJECT_EVAL_QUESTION",
PROJECT_HELP_ANSWER = "PROJECT_HELP_ANSWER",
PROJECT_HELP_QUESTION = "PROJECT_HELP_QUESTION",
QUESTION = "QUESTION",
REPLY = "REPLY",
SUGGESTED_CLARIFICATION = "SUGGESTED_CLARIFICATION"
}
declare enum FeedbackTypename {
AnswerFeedback = "AnswerFeedback",
BasicFeedback = "BasicFeedback",
LowQualityFeedback = "LowQualityFeedback",
QuestionFeedback = "QuestionFeedback"
}
declare enum FeedbackSort {
TopVoted = 1,
Recent = 2,
Trending = 5
}
declare enum ListProgramSortOrder {
TOP = "TOP",
RECENT = "RECENT",
HOT = "HOT",
OFFICIAL = "OFFICIAL",
UPVOTE = "UPVOTE",
OLDEST = "OLDEST"
}
type DataResponse<T = unknown> = {
data: T;
};
type ServiceErrorsResponse = {
data: unknown;
errors: Array<{
extensions: {
code: ServiceErrorCode;
serviceName: ServiceErrorName;
};
message: string;
path: Array<string>;
}>;
};
interface InputErrorResponse {
errors: Array<{
message: string;
}>;
}
type StandardResponse<T = unknown> = DataResponse<T> | ServiceErrorsResponse | InputErrorResponse;
declare function isDataResponse<T>(response: StandardResponse<T>): response is DataResponse<T>;
declare function isServiceErrorsResponse(response: StandardResponse): response is ServiceErrorsResponse;
declare function isInputErrorResponse(response: StandardResponse): response is InputErrorResponse;
declare function assertDataResponse<T>(response: StandardResponse<T>): asserts response is DataResponse<T>;
declare const avatarNames: readonly ["blobby_green_style", "blobby_yellow_style", "blobby_blue_style", "blobby_purple_style", "area_52_yellow_style", "area_52_blue_style", "area_52_green_style", "area_52_purple_style", "eggleston_blue_style", "eggleston_yellow_style", "eggleston_green_style", "eggleston_orange_style", "scuttlebug_purple_style", "scuttlebug_yellow_style", "scuttlebug_blue_style", "scuttlebug_green_style", "boggle_yellow_style", "boggle_blue_style", "boggle_green_style", "boggle_purple_style", "sneak_peak_green_style", "sneak_peak_yellow_style", "sneak_peak_blue_style", "sneak_peak_purple_style", "stelly_blue_style", "stelly_yellow_style", "stelly_green_style", "stelly_orange_style", "cacteye_purple_style", "cacteye_yellow_style", "cacteye_blue_style", "cacteye_green_style", "leaf_green_style", "leaf_blue_style", "leaf_grey_style", "leaf_red_style", "leaf_orange_style", "leaf_yellow_style", "leafers_seed_style", "leafers_seedling_style", "leafers_sapling_style", "leafers_tree_style", "leafers_ultimate_style", "piceratops_seed_style", "piceratops_seedling_style", "piceratops_sapling_style", "piceratops_tree_style", "piceratops_ultimate_style", "duskpin_seed_style", "duskpin_seedling_style", "duskpin_sapling_style", "duskpin_tree_style", "duskpin_ultimate_style", "primosaur_seed_style", "primosaur_seedling_style", "primosaur_sapling_style", "primosaur_tree_style", "primosaur_ultimate_style", "starky_seed_style", "starky_seedling_style", "starky_sapling_style", "starky_tree_style", "starky_ultimate_style", "aqualine_seed_style", "aqualine_seedling_style", "aqualine_sapling_style", "aqualine_tree_style", "aqualine_ultimate_style", "spunky_sam_blue_style", "spunky_sam_green_style", "spunky_sam_orange_style", "spunky_sam_red_style", "marcimus_pink_style", "marcimus_orange_style", "marcimus_red_style", "marcimus_purple_style", "mr_pink_red_style", "mr_pink_green_style", "mr_pink_orange_style", "female_robot_amelia_style", "female_robot_ada_style", "female_robot_grace_style", "male_robot_johnny_style", "male_robot_donald_style", "male_robot_hal_style", "orange_juice_squid_orange_style", "purple_pi_purple_style", "purple_pi_pink_style", "purple_pi_teal_style", "mr_pants_teal_style", "mr_pants_green_style", "mr_pants_orange_style", "mr_pants_pink_style", "mr_pants_purple_style", "old_spice_man_green_style", "old_spice_man_blue_style", "winston_default_style", "winston_baby_style", "ohnoes_default_style", "hopper_happy_style", "hopper_jumping_style", "hopper_cool_style"];
declare const avatarSlugs: readonly ["blobby-green", "blobby-yellow", "blobby-blue", "blobby-purple", "area-52-yellow", "area-52-blue", "area-52-green", "area-52-purple", "eggleston-blue", "eggleston-yellow", "eggleston-green", "eggleston-orange", "scuttlebug-purple", "scuttlebug-yellow", "scuttlebug-blue", "scuttlebug-green", "boggle-yellow", "boggle-blue", "boggle-green", "boggle-purple", "sneak-peak-green", "sneak-peak-yellow", "sneak-peak-blue", "sneak-peak-purple", "stelly-blue", "stelly-yellow", "stelly-green", "stelly-orange", "cacteye-purple", "cacteye-yellow", "cacteye-blue", "cacteye-green", "leaf-green", "leaf-blue", "leaf-grey", "leaf-red", "leaf-orange", "leaf-yellow", "leafers-seed", "leafers-seedling", "leafers-sapling", "leafers-tree", "leafers-ultimate", "piceratops-seed", "piceratops-seedling", "piceratops-sapling", "piceratops-tree", "piceratops-ultimate", "duskpin-seed", "duskpin-seedling", "duskpin-sapling", "duskpin-tree", "duskpin-ultimate", "primosaur-seed", "primosaur-seedling", "primosaur-sapling", "primosaur-tree", "primosaur-ultimate", "starky-seed", "starky-seedling", "starky-sapling", "starky-tree", "starky-ultimate", "aqualine-seed", "aqualine-seedling", "aqualine-sapling", "aqualine-tree", "aqualine-ultimate", "spunky-sam", "spunky-sam-green", "spunky-sam-orange", "spunky-sam-red", "marcimus", "marcimus-orange", "marcimus-red", "marcimus-purple", "mr-pink", "mr-pink-green", "mr-pink-orange", "robot_female_1", "robot_female_2", "robot_female_3", "robot_male_1", "robot_male_2", "robot_male_3", "orange-juice-squid", "purple-pi", "purple-pi-pink", "purple-pi-teal", "mr-pants", "mr-pants-green", "mr-pants-orange", "mr-pants-pink", "mr-pants-purple", "old-spice-man", "old-spice-man-blue", "cs-winston", "cs-winston-baby", "cs-ohnoes", "cs-hopper-happy", "cs-hopper-jumping", "cs-hopper-cool"];
declare function avatarNameToSlug(name: AvatarName): "blobby-green" | "blobby-yellow" | "blobby-blue" | "blobby-purple" | "area-52-yellow" | "area-52-blue" | "area-52-green" | "area-52-purple" | "eggleston-blue" | "eggleston-yellow" | "eggleston-green" | "eggleston-orange" | "scuttlebug-purple" | "scuttlebug-yellow" | "scuttlebug-blue" | "scuttlebug-green" | "boggle-yellow" | "boggle-blue" | "boggle-green" | "boggle-purple" | "sneak-peak-green" | "sneak-peak-yellow" | "sneak-peak-blue" | "sneak-peak-purple" | "stelly-blue" | "stelly-yellow" | "stelly-green" | "stelly-orange" | "cacteye-purple" | "cacteye-yellow" | "cacteye-blue" | "cacteye-green" | "leaf-green" | "leaf-blue" | "leaf-grey" | "leaf-red" | "leaf-orange" | "leaf-yellow" | "leafers-seed" | "leafers-seedling" | "leafers-sapling" | "leafers-tree" | "leafers-ultimate" | "piceratops-seed" | "piceratops-seedling" | "piceratops-sapling" | "piceratops-tree" | "piceratops-ultimate" | "duskpin-seed" | "duskpin-seedling" | "duskpin-sapling" | "duskpin-tree" | "duskpin-ultimate" | "primosaur-seed" | "primosaur-seedling" | "primosaur-sapling" | "primosaur-tree" | "primosaur-ultimate" | "starky-seed" | "starky-seedling" | "starky-sapling" | "starky-tree" | "starky-ultimate" | "aqualine-seed" | "aqualine-seedling" | "aqualine-sapling" | "aqualine-tree" | "aqualine-ultimate" | "spunky-sam" | "spunky-sam-green" | "spunky-sam-orange" | "spunky-sam-red" | "marcimus" | "marcimus-orange" | "marcimus-red" | "marcimus-purple" | "mr-pink" | "mr-pink-green" | "mr-pink-orange" | "robot_female_1" | "robot_female_2" | "robot_female_3" | "robot_male_1" | "robot_male_2" | "robot_male_3" | "orange-juice-squid" | "purple-pi" | "purple-pi-pink" | "purple-pi-teal" | "mr-pants" | "mr-pants-green" | "mr-pants-orange" | "mr-pants-pink" | "mr-pants-purple" | "old-spice-man" | "old-spice-man-blue" | "cs-winston" | "cs-winston-baby" | "cs-ohnoes" | "cs-hopper-happy" | "cs-hopper-jumping" | "cs-hopper-cool";
declare function avatarSlugToName(slug: AvatarSlug): "blobby_green_style" | "blobby_yellow_style" | "blobby_blue_style" | "blobby_purple_style" | "area_52_yellow_style" | "area_52_blue_style" | "area_52_green_style" | "area_52_purple_style" | "eggleston_blue_style" | "eggleston_yellow_style" | "eggleston_green_style" | "eggleston_orange_style" | "scuttlebug_purple_style" | "scuttlebug_yellow_style" | "scuttlebug_blue_style" | "scuttlebug_green_style" | "boggle_yellow_style" | "boggle_blue_style" | "boggle_green_style" | "boggle_purple_style" | "sneak_peak_green_style" | "sneak_peak_yellow_style" | "sneak_peak_blue_style" | "sneak_peak_purple_style" | "stelly_blue_style" | "stelly_yellow_style" | "stelly_green_style" | "stelly_orange_style" | "cacteye_purple_style" | "cacteye_yellow_style" | "cacteye_blue_style" | "cacteye_green_style" | "leaf_green_style" | "leaf_blue_style" | "leaf_grey_style" | "leaf_red_style" | "leaf_orange_style" | "leaf_yellow_style" | "leafers_seed_style" | "leafers_seedling_style" | "leafers_sapling_style" | "leafers_tree_style" | "leafers_ultimate_style" | "piceratops_seed_style" | "piceratops_seedling_style" | "piceratops_sapling_style" | "piceratops_tree_style" | "piceratops_ultimate_style" | "duskpin_seed_style" | "duskpin_seedling_style" | "duskpin_sapling_style" | "duskpin_tree_style" | "duskpin_ultimate_style" | "primosaur_seed_style" | "primosaur_seedling_style" | "primosaur_sapling_style" | "primosaur_tree_style" | "primosaur_ultimate_style" | "starky_seed_style" | "starky_seedling_style" | "starky_sapling_style" | "starky_tree_style" | "starky_ultimate_style" | "aqualine_seed_style" | "aqualine_seedling_style" | "aqualine_sapling_style" | "aqualine_tree_style" | "aqualine_ultimate_style" | "spunky_sam_blue_style" | "spunky_sam_green_style" | "spunky_sam_orange_style" | "spunky_sam_red_style" | "marcimus_pink_style" | "marcimus_orange_style" | "marcimus_red_style" | "marcimus_purple_style" | "mr_pink_red_style" | "mr_pink_green_style" | "mr_pink_orange_style" | "female_robot_amelia_style" | "female_robot_ada_style" | "female_robot_grace_style" | "male_robot_johnny_style" | "male_robot_donald_style" | "male_robot_hal_style" | "orange_juice_squid_orange_style" | "purple_pi_purple_style" | "purple_pi_pink_style" | "purple_pi_teal_style" | "mr_pants_teal_style" | "mr_pants_green_style" | "mr_pants_orange_style" | "mr_pants_pink_style" | "mr_pants_purple_style" | "old_spice_man_green_style" | "old_spice_man_blue_style" | "winston_default_style" | "winston_baby_style" | "ohnoes_default_style" | "hopper_happy_style" | "hopper_jumping_style" | "hopper_cool_style";
/**
* Generates a URL to an avatar SVG
*/
declare function generateAvatarSVG(slug: AvatarSlug): AvatarSVG;
/**
* Generates a URL to an avatar PNG
*/
declare function generateAvatarPNG(slug: AvatarSlug): AvatarPNG;
/**
* Extracts the avatar slug from a path or URL
*
* @param path Relative or absolute path to an avatar
* @returns The avatar slug if the path is valid, null otherwise
*
* @example
* extractAvatarSlug('/images/avatars/blobby-green.svg') // 'blobby-green'
*
* @example
* extractAvatarSlug('https://www.khanacademy.org/images/avatars/svg/blobby-green.svg') // 'blobby-green'
*
* @example
* extractAvatarSlug('https://www.khanacademy.org/images/avatars/blobby-green.png') // 'blobby-green'
*/
declare function extractAvatarSlug(path: AvatarPath | AvatarURL): AvatarSlug | null;
declare function convertAvatarSVGToPNG(url: AvatarSVG): AvatarPNG | null;
declare function convertAvatarPNGToSVG(url: AvatarPNG): AvatarSVG | null;
declare const URL_TLDS: readonly ["com", "org"];
declare const URL_LOCALES: readonly ["as", "az", "cs", "da", "el", "gu", "hu", "id", "it", "lt", "ja", "kk", "kn", "ky", "lv", "mn", "mr", "my", "nl", "pt-pt", "ru", "sv", "ta", "uz", "bg", "bn", "de", "en", "es", "fr", "hi", "hy", "ka", "km", "ko", "nb", "pa", "pl", "pt", "ro", "sr", "tr", "vi", "zh-hans", "sgn-us"];
declare const KaidRegex: RegExp;
declare const KaidRegexMatch: RegExp;
declare const isKaid: (str: string) => str is Kaid;
declare const UserURLRegex: RegExp;
declare const UserURLRegexMatch: RegExp;
declare const isUserURL: (str: string) => str is UserURL;
declare const PROGRAM_ID_LENGTHS: readonly [9, 10, 16];
declare const ProgramIDRegex: RegExp;
declare const ProgramIDRegexMatch: RegExp;
declare function isProgramID(strOrNum: string | number): strOrNum is ProgramID;
declare const PROGRAM_URL_PATHS: readonly ["computer-programming", "cs", "pixar", "nasa", "piab-sandbox", "computer-science", "hour-of-code", "math", "differential-equations", "electrical-engineering", "mcat", "apchem-topic", "chemistry", "art-history-basics", "biology"];
declare const ProgramURLRegex: RegExp;
declare const ProgramURLRegexMatch: RegExp;
declare function isProgramURL(str: string): str is ProgramURL;
declare const ProgramImagePathRegex: RegExp;
declare const ProgramImagePathRegexMatch: RegExp;
declare const PROGRAM_KEY_LENGTHS: readonly [51, 54];
declare const ProgramKeyRegex: RegExp;
declare const ProgramKeyRegexMatch: RegExp;
/**
* Checks if a string is a valid program key
*
* @remarks
* This function will only check the format of the string and not the existence
* of the program on Khan Academy.
*
* Program keys are not the same format as lesson keys or other keys
* that may look similar at first glance.
*
* This function has been tested against more than 1,000,000 program keys but it
* is possible that in the future, new program key formats will be introduced.
*/
declare function isProgramKey(str: string): str is ProgramKey;
declare const MESSAGE_KEY_LENGTHS: readonly [106, 107, 108, 110, 111];
declare const FeedbackKeyRegex: RegExp;
declare const FeedbackKeyRegexMatch: RegExp;
declare const isFeedbackKey: (str: string) => str is FeedbackKey;
declare const MESSAGE_ENCRYPTED_KEY_LENGTHS: readonly [301];
declare const MessageEncryptedKeyRegex: RegExp;
declare const MessageEncryptedKeyRegexMatch: RegExp;
declare const isEncryptedFeedbackKey: (str: string) => str is EncryptedFeedbackKey;
declare const GoogleIDRegex: RegExp;
declare const GoogleIDRegexMatch: RegExp;
declare const isGoogleID: (str: string) => str is GoogleID;
declare const QualarooIDRegex: RegExp;
declare const QualarooIDRegexMatch: RegExp;
declare const isQualarooID: (str: string) => str is QualarooID;
declare const EmailRegex: RegExp;
declare const EmailRegexMatch: RegExp;
declare const isEmail: (str: string) => str is Email;
/**
* @file Low-level string types with one-to-one mappings to the API
*/
type Email = `${string}@${string}.${string}`;
type Locale = (typeof URL_LOCALES)[number];
type Kaid = `kaid_${number}`;
type QualarooID = `_gae_bingo_random:${string}`;
type GoogleID = `http://googleid.khanacademy.org/${number}`;
type UserURL = `http${string}://${string}khanacademy.${string}/profile/${string}`;
type AvatarName = (typeof avatarNames)[number];
type AvatarSlug = (typeof avatarSlugs)[number];
type AvatarPath = `/images/avatars/svg/${AvatarSlug}.svg`;
type AvatarSVG = `https://www.khanacademy.org${AvatarPath}`;
type AvatarPNG = `https://www.khanacademy.org/images/avatars/${AvatarSlug}.png`;
type AvatarURL = AvatarSVG | AvatarPNG;
type ProgramIDString = `${number}`;
type ProgramIDNumber = number;
type ProgramID = `${number}` | number;
type ProgramURLPath = (typeof PROGRAM_URL_PATHS)[number];
type ProgramURL = `http${string}://${string}khanacademy.${string}/${string}/${string}/${number}`;
type ProgramKey = `ag5zfmtoYW4tYWNhZGVteXI${string}CxIKU2NyYXRjaHBhZB${string}${string}`;
type FeedbackKey = `ag5zfmtoYW4tYWNhZGVteX${string}CxIIVXNlckRhdGEi${string}thaWRf${string}${string}${string}`;
type EncryptedFeedbackKey = `kaencrypted_${string}_${string}`;
/**
* @file GraphQL Schema
*
* @summary
* This file contains the GraphQL schema types for the KA API.
*
* @description
* This file exists to reduce code duplication and because GraphQL operates using schemas.
*
* Khan Academy's safelisted GraphQL queries will usually not request any schema entirely so TypeScript's `Pick` and `Omit` utility types may come in handy.
*/
interface UserSchema<AvatarData = AvatarSchema, ProfileData = ProfileSchema, ListProgramsData = ListProgramsSchema> {
__typename: 'User';
actorHasUserScopedPermission: boolean;
authEmails: Array<string> | null;
autocontinueOn: boolean | null;
avatar: AvatarData;
badgeCounts: string;
bio: string;
birthMonthYear: null | unknown;
canAccessDistrictsHomepage: boolean;
canHellban: boolean | null;
canMessageUsers: boolean | null;
canModifyCoaches: boolean | null;
countVideosCompleted: number;
email: string | null;
gaUserId: string | null;
hasAccessToAIGuideDev: boolean | null;
hasAccessToAIGuideCompanionMode: boolean | null;
hasAccessToAIGuideDistrictAdmin: boolean | null;
hasAccessToAIGuideLearner: boolean | null;
hasAccessToAIGuideParent: boolean | null;
hasAccessToAIGuideTeacher: boolean | null;
hasChildren: boolean | null;
hasClasses: boolean | null;
hasCoach: boolean | null;
hasStudents: boolean | null;
hasUnresolvedInvitations: boolean | null;
hideVisual: boolean | null;
homepageUrl: string | null;
/**
* Same as KAID unless the user is anonymous
*/
id: Kaid | null;
includesDistrictOwnedData: boolean;
includesK4dDistrictOwnedData: boolean;
includesKmapDistrictOwnedData: boolean;
isAIGuideEnabled: boolean;
isActor: boolean;
isChild: boolean | null;
isCoachedByActor: boolean;
isCoachingLoggedInUser: boolean;
isCreator: boolean | null;
isCurator: boolean | null;
isDataCollectible: boolean | null;
isDeveloper: boolean | null;
isFormalTeacher: boolean | null;
isK4dStudent: boolean | null;
isKmapStudent: boolean | null;
isMidsignupPhantom: boolean;
isModerator: boolean | null;
isOrphan: boolean | null;
isParent: boolean | null;
isPhantom: boolean;
isPublisher: boolean | null;
isSatStudent: boolean | null;
isSelf: boolean;
isTeacher: boolean | null;
joined: string;
/**
* Will always be a string if requested in the GraphQL query. Defaults to empty string (`''`) for anonymous users.
*/
kaid: Kaid | '';
key: string | null;
lastLoginCountry: string | null;
muteVideos: boolean | null;
newNotificationCount: number | null;
nickname: string | null;
noColorInVideos: boolean | null;
pendingEmailVerifications: PendingEmailVerificationSchema[] | null;
points: number;
preferredKaLocale: LocaleSchema | null;
prefersReducedMotion: boolean | null;
profile: ProfileData;
/**
* Defaults to `null` for anonymous users.
*/
profileRoot: `/profile/${string}/` | null;
programs: ListProgramsData;
/**
* Either Qualaroo ID or KAID
*
* @link https://github.com/kamens/gae_bingo
*
* @deprecated Since 2023-04-24
*/
qualarooId: QualarooID | Kaid | null;
region: null | unknown;
shouldShowAgeCheck: boolean | null;
showCaptions: boolean | null;
signupDataIfUnverified: null | unknown;
soundOn: boolean | null;
tosAccepted: boolean | null;
transferAuthToken: string;
underAgeGate: null | unknown;
/**
* Either Google ID or KAID
*/
userId: GoogleID | Kaid;
userSummaryIsVisibleToActor: boolean;
username: string;
}
interface AvatarSchema {
__typename: 'Avatar';
category: string;
/**
* For example:
* `"/images/avatars/svg/blobby-green.svg"`
*/
imageSrc: AvatarPath;
isDefaultForCategory: boolean;
name: AvatarName;
}
interface PendingEmailVerificationSchema {
__typename: 'PendingEmailVerification';
email: string;
}
interface LocaleSchema {
__typename: 'Locale';
id: string;
kaLocale: Locale;
status: null | unknown;
}
interface ProfileSchema {
__typename: 'Profile';
accessLevel: UserAccessLevel;
programs: Pick<ProgramSchema, '__typename' | 'authorKaid' | 'authorNickname' | 'deleted' | 'displayableSpinoffCount' | 'id' | 'imagePath' | 'key' | 'sumVotesIncremented' | 'translatedTitle' | 'url'>[];
}
interface ListProgramsSchema<ProgramData = unknown> {
__typename: 'ListPrograms';
complete: boolean;
cursor: string;
programs: ProgramData[];
}
interface UserSummarySchema {
__typename: 'UserSummary';
statistics: UserStatisticsSchema;
}
interface UserStatisticsSchema {
__typename: 'UserStatistics';
answers: number;
comments: number;
flags: number;
projectanswers: number;
projectquestions: number;
questions: number;
replies: number;
votes: number;
}
interface ProgramSchema<UserData = unknown> {
__typename: 'Program';
authorKaid: UserSchema['kaid'];
authorNickname: UserSchema['nickname'];
byChild: boolean;
category: null | unknown;
created: string;
creatorProfile: UserData;
deleted: boolean | null;
description: string;
displayableSpinoffCount: number;
docsUrlPath: string;
flaggedBy: null | unknown;
flaggedByUser: boolean;
/**
* Required special permissions.
*/
flags: null | unknown;
height: number;
hideFromHotlist: boolean;
id: `${number}`;
imagePath: string;
isOwner: boolean;
isProjectOrFork: boolean;
kaid: UserSchema['kaid'];
key: ProgramKey;
newUrlPath: string;
originScratchpad: OriginProgramSchema | null;
restrictPosting: boolean;
revision: ProgramRevisionSchema;
slug: string;
spinoffCount: number;
sumVotesIncremented: number;
title: string;
topic: TopicSchema;
translatedTitle: string;
upVoted: boolean;
url: string;
/**
* Besides `PJS`, `WEBPAGE` and `SQL` it can also be an arbitrary string
*/
userAuthoredContentType: string;
width: number;
}
interface OriginProgramSchema {
__typename: 'OriginProgram';
deleted: boolean;
translatedTitle: string;
url: string;
}
interface ProgramRevisionSchema {
__typename: 'ProgramRevision';
code: string;
configVersion: number;
created: string;
editorType: ProgramEditorType;
folds: Array<[number, number]>;
id: string;
}
interface TopicSchema {
__typename: 'Topic';
id: string;
nodeSlug: string;
relativeUrl: string;
slug: string;
translatedTitle: string;
}
interface FeedbackForFocusSchema {
__typename: 'FeedbackForFocus';
cursor: string | null;
feedback: BasicFeedbackSchema[] | QuestionFeedbackSchema[] | AnswerFeedbackSchema[] | null;
isComplete: boolean;
sortedByDate: boolean;
}
interface FeedbackSchemaBase {
__typename: FeedbackTypename;
appearsAsDeleted: boolean;
author: Pick<UserSchema<Pick<AvatarSchema, '__typename' | 'imageSrc' | 'name'>>, '__typename' | 'avatar' | 'id' | 'kaid' | 'nickname'>;
/**
* Always `null`
*/
badges: null | unknown;
content: string;
date: string;
definitelyNotSpam: boolean;
deleted: boolean;
downVoted: boolean;
expandKey: string;
feedbackType: FeedbackType;
/**
* Always `null`
*/
flaggedBy: null | unknown;
flaggedByUser: boolean;
/**
* Always `null`
*/
flags: null | unknown;
focus: FeedbackFocusSchema;
focusUrl: string;
fromVideoAuthor: boolean;
isLocked: boolean;
isPinned: boolean;
/**
* Encrypted ID
*/
key: string;
lowQualityScore: number;
notifyOnAnswer: boolean;
permalink: string;
qualityKind: string;
replyCount: number;
/**
* Expand keys for parent feedback. Always 1-2 elements
*/
replyExpandKeys: Array<FeedbackKey> | FeedbackKey;
/**
* Always `false`? May depend on the user
*/
showLowQualityNotice: boolean;
sumVotesIncremented: number;
upVoted: boolean;
}
interface FeedbackFocusSchema {
__typename: 'FeedbackFocus';
id: string;
kind: FeedbackFocusKind;
relativeUrl: string;
translatedTitle: string;
}
interface BasicFeedbackSchema extends FeedbackSchemaBase {
__typename: FeedbackTypename;
feedbackType: FeedbackType.COMMENT | FeedbackType.REPLY;
}
interface QuestionFeedbackSchema extends FeedbackSchemaBase {
__typename: FeedbackTypename.QuestionFeedback;
answerCount: number;
answers: Pick<AnswerFeedbackSchema, '__typename' | 'appearsAsDeleted' | 'author' | 'content' | 'date' | 'definitelyNotSpam' | 'deleted' | 'downVoted' | 'expandKey' | 'feedbackType' | 'flaggedBy' | 'flags' | 'focus' | 'focusUrl' | 'fromVideoAuthor' | 'isLocked' | 'isPinned' | 'key' | 'lowQualityScore' | 'notifyOnAnswer' | 'permalink' | 'qualityKind' | 'replyCount' | 'replyExpandKeys' | 'showLowQualityNotice' | 'sumVotesIncremented' | 'upVoted'>[] | null;
feedbackType: FeedbackType.QUESTION | FeedbackType.PROJECT_HELP_QUESTION;
/**
* Always `null`
*/
hasAnswered: null | unknown;
isOld: boolean;
}
interface AnswerFeedbackSchema extends FeedbackSchemaBase {
__typename: FeedbackTypename.AnswerFeedback;
feedbackType: FeedbackType.ANSWER;
question: Pick<QuestionFeedbackSchema, '__typename' | 'appearsAsDeleted' | 'author' | 'content' | 'date' | 'definitelyNotSpam' | 'deleted' | 'downVoted' | 'expandKey' | 'feedbackType' | 'flaggedBy' | 'flags' | 'focusUrl' | 'fromVideoAuthor' | 'isLocked' | 'isPinned' | 'key' | 'lowQualityScore' | 'notifyOnAnswer' | 'permalink' | 'qualityKind' | 'replyCount' | 'replyExpandKeys' | 'showLowQualityNotice' | 'sumVotesIncremented' | 'upVoted'>;
}
interface QaExpandKeyInfoSchema {
__typename: 'QaExpandKeyInfo';
feedbackType: FeedbackType;
unencryptedKey: FeedbackKey;
}
interface RepliesSchema {
__typename: 'Replies';
cursor: string | null;
feedback: BasicFeedbackSchema[] | null;
isComplete: boolean;
}
interface TypedResponse<T> extends Response {
json(): Promise<T>;
}
declare function http<Response>(url: string, init?: RequestInit): Promise<TypedResponse<Response>>;
declare function get<Response>(url: string, init?: RequestInit): Promise<TypedResponse<Response>>;
declare function post<Response>(url: string, body: Record<string, unknown>, init?: RequestInit): Promise<TypedResponse<Response>>;
declare function graphql<Variables, Response>(url: string, query: string, variables?: Variables, init?: RequestInit): Promise<TypedResponse<Response>>;
declare namespace AvatarDataForProfile {
const query = "query avatarDataForProfile($kaid: String!) {\n user(kaid: $kaid) {\n id\n avatar {\n name\n imageSrc\n __typename\n }\n __typename\n }\n}";
interface Variables {
kaid: Kaid;
}
type Response = StandardResponse<Data>;
type Data = {
user: Pick<UserSchema<Pick<AvatarSchema, '__typename' | 'imageSrc' | 'name'>>, '__typename' | 'avatar' | 'id' | 'kaid'> | null;
};
}
/**
* Low-level function for making a `avatarDataForProfile` request.
*
* @link {@link https://khan-api.bhavjit.com/reference/view/19553924/2s8YzQUiXU#256c194a-f6d5-4c7a-aaa5-97792cdba1b3 | Reference}
*
* @example
* Simple usage without error handling:
* ```js
* const response = await queries.avatarDataForProfile({
* kaid: 'kaid_326465577260382527912172'
* })
* const json = await response.json()
* const profile = json.data.user
* const avatar = profile.avatar
* ```
*/
declare function avatarDataForProfile(variables: AvatarDataForProfile.Variables, init?: RequestInit): Promise<TypedResponse<AvatarDataForProfile.Response>>;
/**
* @example
* Alternative usage:
* ```js
* const response = await queries.avatarDataForProfile('kaid_326465577260382527912172')
* const json = await response.json()
* const profile = json.data.user
* const avatar = profile.avatar
* ```
*/
declare function avatarDataForProfile(kaid: Kaid, init?: RequestInit): Promise<TypedResponse<AvatarDataForProfile.Response>>;
declare namespace FeedbackQuery {
const query = "query feedbackQuery($topicId: String!, $focusKind: String!, $cursor: String, $limit: Int, $feedbackType: FeedbackType!, $currentSort: Int, $qaExpandKey: String) {\n feedback(\n focusId: $topicId\n cursor: $cursor\n limit: $limit\n feedbackType: $feedbackType\n focusKind: $focusKind\n sort: $currentSort\n qaExpandKey: $qaExpandKey\n answersLimit: 1\n ) {\n feedback {\n isLocked\n isPinned\n replyCount\n appearsAsDeleted\n author {\n id\n kaid\n nickname\n avatar {\n name\n imageSrc\n __typename\n }\n __typename\n }\n badges {\n name\n icons {\n smallUrl\n __typename\n }\n description\n __typename\n }\n content\n date\n definitelyNotSpam\n deleted\n downVoted\n expandKey\n feedbackType\n flaggedBy\n flaggedByUser\n flags\n focusUrl\n focus {\n kind\n id\n translatedTitle\n relativeUrl\n __typename\n }\n fromVideoAuthor\n key\n lowQualityScore\n notifyOnAnswer\n permalink\n qualityKind\n replyCount\n replyExpandKeys\n showLowQualityNotice\n sumVotesIncremented\n upVoted\n ... on QuestionFeedback {\n hasAnswered\n answers {\n isLocked\n isPinned\n replyCount\n appearsAsDeleted\n author {\n id\n kaid\n nickname\n avatar {\n name\n imageSrc\n __typename\n }\n __typename\n }\n badges {\n name\n icons {\n smallUrl\n __typename\n }\n description\n __typename\n }\n content\n date\n definitelyNotSpam\n deleted\n downVoted\n expandKey\n feedbackType\n flaggedBy\n flaggedByUser\n flags\n focusUrl\n focus {\n kind\n id\n translatedTitle\n relativeUrl\n __typename\n }\n fromVideoAuthor\n key\n lowQualityScore\n notifyOnAnswer\n permalink\n qualityKind\n replyCount\n replyExpandKeys\n showLowQualityNotice\n sumVotesIncremented\n upVoted\n __typename\n }\n isOld\n answerCount\n __typename\n }\n ... on AnswerFeedback {\n question {\n isLocked\n isPinned\n replyCount\n appearsAsDeleted\n author {\n id\n kaid\n nickname\n avatar {\n name\n imageSrc\n __typename\n }\n __typename\n }\n badges {\n name\n icons {\n smallUrl\n __typename\n }\n description\n __typename\n }\n content\n date\n definitelyNotSpam\n deleted\n downVoted\n expandKey\n feedbackType\n flaggedBy\n flaggedByUser\n flags\n focusUrl\n focus {\n kind\n id\n translatedTitle\n relativeUrl\n __typename\n }\n fromVideoAuthor\n key\n lowQualityScore\n notifyOnAnswer\n permalink\n qualityKind\n replyCount\n replyExpandKeys\n showLowQualityNotice\n sumVotesIncremented\n upVoted\n __typename\n }\n __typename\n }\n __typename\n }\n cursor\n isComplete\n sortedByDate\n __typename\n }\n}";
interface Variables {
topicId: string;
focusKind: FeedbackFocusKind;
cursor?: string;
limit?: number;
feedbackType: FeedbackType;
currentSort: FeedbackSort | number | null;
qaExpandKey?: string | null;
}
type Response = StandardResponse<Data>;
type Data = {
feedback: FeedbackForFocusSchema;
};
}
/**
* Low-level for making a `feedbackQuery` request.
*
* @link {@link https://khan-api.bhavjit.com/reference/view/19553924/2s8YzQUiXU#e7abb177-fe2b-4e49-a003-5f9be43b90e4 | Reference}
*/
declare function feedbackQuery(variables: FeedbackQuery.Variables, init?: RequestInit): Promise<TypedResponse<FeedbackQuery.Response>>;
declare namespace GetFeedbackReplies {
const query = "query getFeedbackReplies($postKey: String!) {\n feedbackReplies(feedbackKey: $postKey) {\n isLocked\n isPinned\n expandKey\n appearsAsDeleted\n author {\n id\n kaid\n nickname\n avatar {\n name\n imageSrc\n __typename\n }\n __typename\n }\n content\n date\n definitelyNotSpam\n deleted\n downVoted\n expandKey\n feedbackType\n flaggedBy\n flaggedByUser\n flags\n focusUrl\n fromVideoAuthor\n key\n lowQualityScore\n notifyOnAnswer\n permalink\n qualityKind\n replyCount\n replyExpandKeys\n showLowQualityNotice\n sumVotesIncremented\n upVoted\n __typename\n }\n}";
interface Variables {
postKey: FeedbackKey | EncryptedFeedbackKey;
}
type Response = StandardResponse<Data>;
type Data = {
feedbackReplies: Pick<BasicFeedbackSchema, '__typename' | 'appearsAsDeleted' | 'author' | 'content' | 'date' | 'definitelyNotSpam' | 'deleted' | 'downVoted' | 'expandKey' | 'feedbackType' | 'flaggedBy' | 'flaggedByUser' | 'flags' | 'focusUrl' | 'fromVideoAuthor' | 'isLocked' | 'isPinned' | 'key' | 'lowQualityScore' | 'notifyOnAnswer' | 'permalink' | 'qualityKind' | 'replyCount' | 'replyExpandKeys' | 'showLowQualityNotice' | 'sumVotesIncremented' | 'upVoted'>[];
};
}
/**
* Low-level function for making a `getFeedbackReplies` request.
*
* @link {@link https://khan-api.bhavjit.com/reference/view/19553924/2s8YzQUiXU#3d616591-a38f-4bec-9836-367dba32a2ac | Reference}
*
* @example
* Simple usage without error handling:
* ```js
* const response = await queries.getFeedbackReplies({
* postKey: 'ag5zfmtoYW4tYWNhZGVteXJBCxIIVXNlckRhdGEiHmthaWRfNjYzMzc5NDA2ODA0Nzc0MjA1NjU0NTUzNAwLEghGZWVkYmFjaxiAgOPjx8-XCAw'
* })
* const json = await response.json()
* const replies = json.data.feedbackReplies
* ```
*/
declare function getFeedbackReplies(variables: GetFeedbackReplies.Variables, init?: RequestInit): Promise<TypedResponse<GetFeedbackReplies.Response>>;
/**
* @example
* Alternative usage:
* ```js
* const await queries.getFeedbackReplies('ag5zfmtoYW4tYWNhZGVteXJBCxIIVXNlckRhdGEiHmthaWRfNjYzMzc5NDA2ODA0Nzc0MjA1NjU0NTUzNAwLEghGZWVkYmFjaxiAgOPjx8-XCAw')
* const json = await response.json()
* const replies = json.data.feedbackReplies
* ```
*/
declare function getFeedbackReplies(postKey: FeedbackKey | EncryptedFeedbackKey, init?: RequestInit): Promise<TypedResponse<GetFeedbackReplies.Response>>;
declare namespace GetFeedbackRepliesPage {
const query = "query getFeedbackRepliesPage($postKey: String!, $cursor: String, $limit: Int!) {\n feedbackRepliesPaginated(feedbackKey: $postKey, cursor: $cursor, limit: $limit) {\n cursor\n isComplete\n feedback {\n isLocked\n isPinned\n expandKey\n appearsAsDeleted\n author {\n id\n kaid\n nickname\n avatar {\n name\n imageSrc\n __typename\n }\n __typename\n }\n content\n date\n definitelyNotSpam\n deleted\n downVoted\n expandKey\n feedbackType\n flaggedBy\n flaggedByUser\n flags\n focusUrl\n fromVideoAuthor\n key\n lowQualityScore\n notifyOnAnswer\n permalink\n qualityKind\n replyCount\n replyExpandKeys\n showLowQualityNotice\n sumVotesIncremented\n upVoted\n __typename\n }\n __typename\n }\n}";
interface Variables {
postKey: FeedbackKey | EncryptedFeedbackKey;
cursor?: string | null;
limit: number;
}
type Response = StandardResponse<Data>;
type Data = {
feedbackRepliesPaginated: RepliesSchema;
};
}
/**
* Low-level function to fetch a page of replies to a feedback post.
*
* @link {@link https://khan-api.bhavjit.com/reference/view/19553924/2s8YzQUiXU#16b92467-dd37-4dbb-968a-cb700ae0f9cb | Reference}
*/
declare function getFeedbackRepliesPage(variables: GetFeedbackRepliesPage.Variables, init?: RequestInit): Promise<TypedResponse<GetFeedbackRepliesPage.Response>>;
declare namespace GetFullUserProfile {
const query = "query getFullUserProfile($kaid: String, $username: String) {\n user(kaid: $kaid, username: $username) {\n id\n kaid\n key\n userId\n email\n username\n profileRoot\n gaUserId\n isPhantom\n isDeveloper: hasPermission(name: \"can_do_what_only_admins_can_do\")\n isPublisher: hasPermission(name: \"can_publish\", scope: ANY_ON_CURRENT_LOCALE)\n isModerator: hasPermission(name: \"can_moderate_users\", scope: GLOBAL)\n isParent\n isTeacher\n isFormalTeacher\n isK4dStudent\n isKmapStudent\n isDataCollectible\n isChild\n isOrphan\n isCoachingLoggedInUser\n canModifyCoaches\n nickname\n hideVisual\n joined\n points\n countVideosCompleted\n bio\n profile {\n accessLevel\n __typename\n }\n soundOn\n muteVideos\n showCaptions\n prefersReducedMotion\n noColorInVideos\n newNotificationCount\n canHellban: hasPermission(name: \"can_ban_users\", scope: GLOBAL)\n canMessageUsers: hasPermission(\n name: \"can_send_moderator_messages\"\n scope: GLOBAL\n )\n isSelf: isActor\n hasStudents: hasCoachees\n hasClasses\n hasChildren\n hasCoach\n badgeCounts\n homepageUrl\n isMidsignupPhantom\n includesDistrictOwnedData\n includesKmapDistrictOwnedData\n includesK4dDistrictOwnedData\n canAccessDistrictsHomepage\n underAgeGate {\n parentEmail\n daysUntilCutoff\n approvalGivenAt\n __typename\n }\n authEmails\n signupDataIfUnverified {\n email\n emailBounced\n __typename\n }\n pendingEmailVerifications {\n email\n __typename\n }\n hasAccessToAIGuideCompanionMode\n hasAccessToAIGuideLearner\n hasAccessToAIGuideDistrictAdmin\n hasAccessToAIGuideParent\n hasAccessToAIGuideTeacher\n tosAccepted\n shouldShowAgeCheck\n birthMonthYear\n lastLoginCountry\n region\n userDistrictInfos {\n id\n isKAD\n district {\n id\n region\n __typename\n }\n __typename\n }\n schoolAffiliation {\n id\n location\n __typename\n }\n __typename\n }\n actorIsImpersonatingUser\n isAIGuideEnabled\n hasAccessToAIGuideDev\n}";
interface Variables {
kaid?: Kaid | null;
username?: string | null;
}
type Response = StandardResponse<Data>;
type Data = {
actorIsImpersonatingUser: boolean;
user: Pick<UserSchema<unknown, Pick<ProfileSchema, '__typename' | 'accessLevel'>>, '__typename' | 'authEmails' | 'badgeCounts' | 'birthMonthYear' | 'bio' | 'canAccessDistrictsHomepage' | 'canHellban' | 'canMessageUsers' | 'canModifyCoaches' | 'countVideosCompleted' | 'email' | 'gaUserId' | 'hasAccessToAIGuideDev' | 'hasAccessToAIGuideCompanionMode' | 'hasAccessToAIGuideDistrictAdmin' | 'hasAccessToAIGuideLearner' | 'hasAccessToAIGuideParent' | 'hasAccessToAIGuideTeacher' | 'hasChildren' | 'hasClasses' | 'hasCoach' | 'hasStudents' | 'hideVisual' | 'homepageUrl' | 'id' | 'includesDistrictOwnedData' | 'includesK4dDistrictOwnedData' | 'includesKmapDistrictOwnedData' | 'isAIGuideEnabled' | 'isChild' | 'isCoachingLoggedInUser' | 'isCreator' | 'isCurator' | 'isDataCollectible' | 'isDeveloper' | 'isFormalTeacher' | 'isK4dStudent' | 'isKmapStudent' | 'isMidsignupPhantom' | 'isModerator' | 'isOrphan' | 'isParent' | 'isPhantom' | 'isPublisher' | 'isSelf' | 'isTeacher' | 'joined' | 'kaid' | 'key' | 'lastLoginCountry' | 'muteVideos' | 'newNotificationCount' | 'nickname' | 'noColorInVideos' | 'pendingEmailVerifications' | 'points' | 'prefersReducedMotion' | 'profile' | 'profileRoot' | 'region' | 'shouldShowAgeCheck' | 'showCaptions' | 'signupDataIfUnverified' | 'soundOn' | 'tosAccepted' | 'underAgeGate' | 'userId' | 'username'> | null;
};
}
/**
* Low-level function for making a `getFullUserProfile` request.
*
* @remarks
* This request does not require authentication but some fields will be returned
* as `null`.
*
* If, for some reason, both `kaid` and `username` are provided, Khan Academy
* will use `kaid` and ignore `username`.
*
* @param variables Fetches profile associated with any cookies if not provided
*
* @link {@link https://khan-api.bhavjit.com/reference/view/19553924/2s8YzQUiXU#9ae4c690-be8a-4b57-acfc-07a4870a5ee3 | Reference}
*
* @see {@link Client.getUser}
*
* @example
* Get profile by KAID, without error handling:
* ```js
* const response = await queries.getFullUserProfile({ kaid: 'kaid_326465577260382527912172' })
* const json = await response.json()
* const profile = json.data.user
* ```
*
* @example
* Similarly, get profile by username:
* ```js
* const response = await queries.getFullUserProfile({ username: 'sal' })
* const json = await response.json()
* const profile = json.data.user
* ```
*
* @example
* If no variables are provided or an empty object is passed in, Khan Academy
* will use any cookies included with the request to fetch the profile
* associated with them:
* ```js
* const response = await queries.getFullUserProfile(null, {
* headers: { cookie: 'KAAS=...' }
* })
* const json = await response.json()
* const profile = json.data.user
* ```
*/
declare function getFullUserProfile(variables?: GetFullUserProfile.Variables, init?: RequestInit): Promise<TypedResponse<GetFullUserProfile.Response>>;
/**
* @example
* Alternative usage by KAID:
* ```js
* const response = await queries.getFullUserProfile('kaid_326465577260382527912172')
* const json = await response.json()
* const profile = json.data.user
* ```
*/
declare function getFullUserProfile(kaid?: Kaid, init?: RequestInit): Promise<TypedResponse<GetFullUserProfile.Response>>;
/**
* @example
* Similarly, by username:
* ```js
* const response = await queries.getFullUserProfile('sal')
* const json = await response.json()
* const profile = json.data.user
* ```
*/
declare function getFullUserProfile(username?: string, init?: RequestInit): Promise<TypedResponse<GetFullUserProfile.Response>>;
declare namespace GetProfileWidgets {
const query = "query getProfileWidgets($kaid: String!) {\n user(kaid: $kaid) {\n id\n kaid\n badgeCounts\n isChild\n profile {\n programs {\n id\n authorKaid\n authorNickname\n deleted\n displayableSpinoffCount\n imagePath\n key\n sumVotesIncremented\n translatedTitle: title\n url\n __typename\n }\n __typename\n }\n programs(sort: TOP, pageInfo: {itemsPerPage: 2}) {\n programs {\n id\n authorKaid\n authorNickname\n deleted\n displayableSpinoffCount\n imagePath\n key\n sumVotesIncremented\n translatedTitle: title\n url\n __typename\n }\n __typename\n }\n __typename\n }\n userSummary(kaid: $kaid) {\n statistics {\n answers\n comments\n flags\n projectanswers\n projectquestions\n questions\n replies\n votes\n __typename\n }\n __typename\n }\n}";
interface Variables {
kaid: Kaid;
}
type Response = StandardResponse<Data>;
type Data = {
user: Pick<UserSchema<unknown, Pick<ProfileSchema, '__typename' | 'programs'>, ListProgramsSchema<Pick<ProgramSchema, '__typename' | 'authorKaid' | 'authorNickname' | 'deleted' | 'displayableSpinoffCount' | 'id' | 'imagePath' | 'key' | 'sumVotesIncremented' | 'url'> & {
translatedTitle: ProgramSchema['title'];
}>>, '__typename' | 'badgeCounts' | 'id' | 'isChild' | 'kaid' | 'profile' | 'programs'>;
/**
* Will still be defined even if the user doesn't exist, but all values will be 0
*/
userSummary: UserSummarySchema;
};
}
/**
* @link {@link https://khan-api.bhavjit.com/reference/view/19553924/2s8YzQUiXU#d88fe317-8705-43d7-a811-5d93316dd4a2 | Reference}
*/
declare function getProfileWidgets(variables: GetProfileWidgets.Variables, init?: RequestInit): Promise<TypedResponse<GetProfileWidgets.Response>>;
declare function getProfileWidgets(kaid: Kaid, init?: RequestInit): Promise<TypedResponse<GetProfileWidgets.Response>>;
declare namespace GetUserByUsernameOrEmail {
const query = "query getUserByUsernameOrEmail($username: String, $email: String) {\n user(username: $username, email: $email) {\n id\n kaid\n __typename\n }\n}";
interface Variables {
username?: string;
email?: string;
}
type Response = StandardResponse<Data>;
type Data = {
user: Pick<UserSchema, '__typename' | 'id' | 'kaid'> | null;
};
}
/**
* Get KAID by username or email.
*
* @link {@link https://khan-api.bhavjit.com/reference/view/19553924/2s8YzQUiXU#46e24c10-e98e-4900-bd53-b02d93f8e3c9 | Reference}
*
* @example
* Simple usage without error handling:
* ```js
* const response = await queries.getUserByUsernameOrEmail({
* username: 'sal'
* })
* const json = await response.json()
* const kaid = json.data.user?.kaid
* ```
*
* @example
* Similarly, get KAID by email:
* ```js
* const response = await queries.getUserByUsernameOrEmail({
* email: 'sal@khanacademy.org'
* })
* const json = await response.json()
* const kaid = json.data.user?.kaid
* ```
*/
declare function getUserByUsernameOrEmail(variables: GetUserByUsernameOrEmail.Variables, init?: RequestInit): Promise<TypedResponse<GetUserByUsernameOrEmail.Response>>;
/**
* @example
* Alternative usage by username:
* ```js
* const response = await queries.getUserByUsernameOrEmail('sal')
* const json = await response.json()
* const kaid = json.data.user?.kaid
* ```
*/
declare function getUserByUsernameOrEmail(username: string, init?: RequestInit): Promise<TypedResponse<GetUserByUsernameOrEmail.Response>>;
/**
* @example
* Similarly, by email:
* ```js
* const response = await queries.getUserByUsernameOrEmail('sal@khanacademy.org')
* const json = await response.json()
* const kaid = json.data.user?.kaid
* ```
*/
declare function getUserByUsernameOrEmail(email: Email, init?: RequestInit): Promise<TypedResponse<GetUserByUsernameOrEmail.Response>>;
declare namespace GetUserHoverCardProfile {
const query = "query getUserHoverCardProfile($kaid: String!) {\n user(kaid: $kaid) {\n id\n nickname\n username\n bio\n avatar {\n name\n imageSrc\n __typename\n }\n points\n isPhantom\n isActor\n isCoachedByActor\n userSummaryIsVisibleToActor\n actorHasUserScopedPermission(capability: CAN_VIEW_USER_IDENTITY)\n __typename\n }\n}";
interface Variables {
kaid: Kaid;
}
type Response = StandardResponse<Data>;
type Data = {
user: Pick<UserSchema<Pick<AvatarSchema, '__typename' | 'imageSrc' | 'name'>>, '__typename' | 'actorHasUserScopedPermission' | 'avatar' | 'bio' | 'id' | 'isActor' | 'isCoachedByActor' | 'isPhantom' | 'kaid' | 'nickname' | 'points' | 'userSummaryIsVisibleToActor' | 'username'> | null;
};
}
/**
* Low-level function for making a `getUserHoverCardProfile` request.
*
* @link {@link https://khan-api.bhavjit.com/reference/view/19553924/2s8YzQUiXU#6de1d62b-d8b4-425e-b0f2-305be6279718 | Reference}
*
* @example
* Simple usage without error handling:
* ```js
* const response = await queries.getUserHoverCardProfile({
* kaid: 'kaid_326465577260382527912172'
* })
* const json = await response.json()
* const profile = json.data.user
* ```
*/
declare function getUserHoverCardProfile(variables: GetUserHoverCardProfile.Variables, init?: RequestInit): Promise<TypedResponse<GetUserHoverCardProfile.Response>>;
/**
* @example
* Alternative usage:
* ```js
* const response = await queries.getUserHoverCardProfile('kaid_326465577260382527912172')
* const json = await response.json()
* const profile = json.data.user
* ```
*/
declare function get