{"id":17790536,"url":"https://github.com/cwickham/cnvs","last_synced_at":"2026-01-20T21:33:46.534Z","repository":{"id":66634252,"uuid":"211907299","full_name":"cwickham/cnvs","owner":"cwickham","description":"Experimental R package to access Canvas LMS API based on gh ","archived":false,"fork":false,"pushed_at":"2020-10-16T20:14:13.000Z","size":622,"stargazers_count":2,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T12:50:10.201Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://cwickham.github.io/cnvs/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cwickham.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-30T16:42:34.000Z","updated_at":"2022-02-01T10:19:55.000Z","dependencies_parsed_at":"2023-03-09T05:15:52.433Z","dependency_job_id":null,"html_url":"https://github.com/cwickham/cnvs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cwickham/cnvs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwickham%2Fcnvs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwickham%2Fcnvs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwickham%2Fcnvs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwickham%2Fcnvs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cwickham","download_url":"https://codeload.github.com/cwickham/cnvs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwickham%2Fcnvs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28614617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T18:56:40.769Z","status":"ssl_error","status_checked_at":"2026-01-20T18:54:26.653Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-27T10:44:11.157Z","updated_at":"2026-01-20T21:33:46.520Z","avatar_url":"https://github.com/cwickham.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# cnvs\n\n\u003c!-- badges: start --\u003e\n  [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)\n  [![{Travis build status}](https://travis-ci.org/cwickham/cnvs.svg?branch=master)](https://travis-ci.org/cwickham/cnvs)\n  \u003c!-- badges: end --\u003e\n\nMinimalistic client to access the\n[Canvas LMS API](https://canvas.instructure.com/doc/api/index.html).  Heavily borrowing from the infrastructure of [gh](https://github.com/r-lib/gh) \n\n## Philospophy\n\ncnvs is intentionally minimalist.  To use it, you will need to become familiar with the [Canvas API documentation](https://canvas.instructure.com/doc/api/index.html).  cnvs does no checking on the endpoints you provide, nor the objects you pass.  This has the advantage that cnvs is not dependent on the specifics of the Canvas API.  cnvs also does no parsing of response content, you will need to extract the desired information from the returned lists yourself.\n\nWhile cnvs does facilite the automation of repetitive tasks in Canvas from R,  it still requires a fair bit of expertise from the user.  The hope is to use it as a foundation for a higher level api package, that is more user-friendly.\n\n## Installation\n\nInstall the package from GitHub:\n\n```{r eval = FALSE}\n# install.packages(\"remotes\")\nremotes::install_github(\"cwickham/cnvs\")\n```\n\n## Usage\n\n```{r}\nlibrary(cnvs)\n```\n\nUse the `cnvs()` function to access all API endpoints. The endpoints are\nlisted in the [documentation](https://canvas.instructure.com/doc/api/index.html).\n\nThe first argument of `cnvs()` is the endpoint. Note that the leading `/api/v1/` must be included as well, but this facilitates copy and pasting directly from the documentation. Parameters can be passed as extra arguments. E.g.\n\n```{r}\nmy_courses \u003c- cnvs(\"/api/v1/courses\", enrollment_type = \"teacher\")\nvapply(my_courses, \"[[\", \"\", \"name\")\n```\n\nThe JSON result sent by the API is converted to an R object.\n\nIf the end point itself has parameters, these can also be passed\nas extra arguments:\n\n```{r}\ntest_modules \u003c- cnvs(\"/api/v1/courses/:course_id/modules\", \n  course_id = 1732420)\nvapply(test_modules, \"[[\", \"\", \"name\")\n```\n\n\n### POST, PATCH, PUT and DELETE requests\n\nPOST, PUT, and DELETE requests can be sent by including the\nHTTP verb before the endpoint, in the first argument. For example, to\ncreate a module:\n```{r}\nnew_module \u003c- cnvs(\"POST /api/v1/courses/:course_id/modules\",\n  course_id = 1732420,  # set a parameter in the endpoint `:course_id`\n  module = list(        # a parameter sent in the body\n    name = \"First module\",\n    position = 1\n  )\n)\n```\n\n```{r}\ntest_modules \u003c- cnvs(\"/api/v1/courses/:course_id/modules\", \n  course_id = 1732420)\nvapply(test_modules, \"[[\", \"\", \"name\")\n```\n\nThen update the name of the module:\n```{r}\nupdate_module \u003c- cnvs(\"PUT /api/v1/courses/:course_id/modules/:id\",\n  course_id = 1732420,\n  id = new_module$id,\n  module = list(\n    name = \"Module 1\"\n  )\n)\n```\n\n```{r}\ntest_modules \u003c- cnvs(\"/api/v1/courses/:course_id/modules\", \n  course_id = 1732420)\nvapply(test_modules, \"[[\", \"\", \"name\")\n```\n\nThen, finally, delete the module:\n```{r}\ncnvs(\"DELETE /api/v1/courses/:course_id/modules/:id\",\n  course_id = 1732420,\n  id = new_module$id\n)\n```\n\n```{r}\ntest_modules \u003c- cnvs(\"/api/v1/courses/:course_id/modules\", \n  course_id = 1732420)\nvapply(test_modules, \"[[\", \"\", \"name\")\n```\n### Uploading files\n\nTo upload files use the `cnvs_upload()` function.  You need to locate the endpoint for the required context of the file.  E.g. To [upload a course file](https://canvas.instructure.com/doc/api/courses.html#method.courses.create_file) the endpoint is:\n```\nPOST /api/v1/courses/:course_id/files \n```\nWhereas to [upload a file as an submission](https://canvas.instructure.com/doc/api/submissions.html#method.submissions_api.create_file) the endpoint is:\n```\nPOST /api/v1/courses/:course_id/assignments/:assignment_id/submissions/:user_id/files\n```\n\nPass this endpoint to `cnvs_upload()` along with path to the file you wish to upload:\n```{r, eval = FALSE}\ncnvs_upload(\"/api/v1/courses/:course_id/files\",\n  path = \"notes.pdf\", course_id = \"1732420\", parent_folder_path = \"handouts/\")\n```\n\nLike `cnvs()` you can specify parameters in the endpoint, like `course_id`, or parameters in the body of the request like `parent_folder_path` as additional arguments.\n \n### Pagination\n\nSupply the `page` parameter to get subsequent pages:\n\n```{r eval = FALSE}\nmy_courses2 \u003c- cnvs(\"/api/v1/courses\", enrollment_type = \"teacher\",\n  page = 2)\nvapply(my_courses2, \"[[\", \"\", \"name\")\n```\n\n## License\n\ncnvs: MIT © Charlotte Wickham\n\nThe code is mostly minor edits to the [gh](https://github.com/r-lib/gh) package:\n\ngh: MIT © Gábor Csárdi, Jennifer Bryan, Hadley Wickham\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcwickham%2Fcnvs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcwickham%2Fcnvs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcwickham%2Fcnvs/lists"}