@kyso/api
Kyso API client javascript library
Installation
yarn add @kyso/api
or
npm install @kyso/api
Usage
const kyso = require('@kyso/api')
// example
const studies = await kyso.getStudies({ token: user.sessionToken })
Set the auth token for each call using token: user.sessionToken
Auth & Profile
-
login
Returns a response object!const response = await kyso.login({ email, password, apiUrl })
-
getMe
Returns a response object!const response = await kyso.getMe({ token, apiUrl })
-
signup
Returns a response object!const response = await kyso.signup({ userData, apiUrl })
userData
must include email, username and password -
checkNameUniqueness
Checks if a nickname is already takenconst { exists } = await kyso.checkNameUniqueness({ name, apiUrl })
Exists will be true or false
-
getAuth0User
- not in use anymore -
linkAuth0Accounts
- not in use anymore -
setNickname
await kyso.setNickname({ token, nickname, apiUrl })
Sets the nickname of a user
-
uploadProfilePicture
!!! needs testing and exampleawait kyso.uploadProfilePicture({ token, data, apiUrl })
data must be the buffer or base64 content of the image file.
Studies
-
createVersion
Use the library @kyso/publish to create a version -
createStudy
Use the library @kyso/publish to create a study -
addTags
await kyso.addTags({ token, studyId, tags, apiUrl })
-
getTagSuggestions
await kyso.getTagSuggestions({ apiUrl })
-
checkVersionExists
const { exists } = await kyso.checkVersionExists({ token, name, versionSha, apiUrl })
-
deleteStudy
await kyso.deleteStudy({ token, studyId, apiUrl })
-
getExploreStudies
const studies = await kyso.getExploreStudies({ page, limit, apiUrl })
Returns a list of featured explore studies, limit the amount of studies with limit (default 12), and set the page for which page of studies
-
getRecentStudies
const studies = await kyso.getRecentStudies({ tags, page, limit, apiUrl })
Returns a list of recent studies, limit the amount of studies with limit (default 12), and set the page for which page of studies, and filter by tags by setting the tags array (eg: tags=["machine-learning"])
-
getMainFile
const content = await kyso.getMainFile({ versionId, token (optional), apiUrl })
-
getStudies
const studies = await kyso.getStudies({ token, apiUrl })
-
getStudiesByAuthor
const studies = await kyso.getStudiesByAuthor({ author, apiUrl })
-
getStudy
const study = await kyso.getStudy({ token, author, name, limit, sha, apiUrl })
Author is the author nickname, and name is the studyname. Limit and sha are optional.
-
getVersion
const version = await kyso.getVersion({ token, versionId, apiUrl })
-
incrementViews
await incrementViews({ studyId, apiUrl })
-
togglePrivate
const study = await togglePrivate({ token, studyId, privacy, apiUrl })
-
toggleStar
const study = await toggleStar({ token, studyId, privacy, apiUrl })
Comments
-
createComment
const comment = await createComment({ token, text, studyId, parentId, apiUrl })
-
getComments
const comments = await getComments({ studyId, parentId, apiUrl })
-
editComment
const comment = await editComment({ token, text, commentId, apiUrl })
-
deleteComment
const comment = await deleteComment({ token, commentId, apiUrl })
This simply removes the comment author from the comment, it still exists.
Containers
-
getContainer
const container = await kyso.getContainer({ token, proxyUrl, containerId, apiUrl })
Returns container object
-
getContainers
const containers = await kyso.getContainers({ token, apiUrl })
Returns list of container objects
-
getRunningContainers
const runningContainers = await kyso.getRunningContainers({ token, apiUrl })
Returns list of container objects
-
updateContainerActivity
await kyso.updateContainerActivity({ token, proxyUrl, lastActivity, apiUrl })
-
feedback
await kyso.feedback({ token, text, apiUrl })
Github
-
getGithubRepositories
const repos = await kyso.getGithubRepositories({ token, apiUrl })
Returns list of repo objects
-
importGithubRepository
await kyso.importRepo({ repo, branch, main, token, apiUrl })