{"id":18544654,"url":"https://github.com/instructure/canvas-studio-api-examples","last_synced_at":"2025-04-09T19:30:59.018Z","repository":{"id":37976536,"uuid":"490580113","full_name":"instructure/canvas-studio-api-examples","owner":"instructure","description":" useful example scripts for the Studio team and account administrators to access the public API of Canvas Studio","archived":false,"fork":false,"pushed_at":"2022-09-08T14:03:22.000Z","size":32,"stargazers_count":4,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-14T20:25:51.034Z","etag":null,"topics":["api","canvas","openapi","studio"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/instructure.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-10T07:04:06.000Z","updated_at":"2023-06-28T02:16:41.000Z","dependencies_parsed_at":"2022-08-08T22:45:21.483Z","dependency_job_id":null,"html_url":"https://github.com/instructure/canvas-studio-api-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instructure%2Fcanvas-studio-api-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instructure%2Fcanvas-studio-api-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instructure%2Fcanvas-studio-api-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/instructure%2Fcanvas-studio-api-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/instructure","download_url":"https://codeload.github.com/instructure/canvas-studio-api-examples/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223407794,"owners_count":17140563,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["api","canvas","openapi","studio"],"created_at":"2024-11-06T20:17:13.060Z","updated_at":"2024-11-06T20:17:13.642Z","avatar_url":"https://github.com/instructure.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Canvas Studio API examples\n\nIn this repository, we collect example scripts that can be useful for the team and Studio account administrators to access the public API of Canvas Studio (documentation can be found at https://tw.instructuremedia.com/api/public/docs/)\n\n## Prerequisites\n\nTo run python scripts inside `examples` directory you should first run the installer script:\n\n```bash\nbin/install\n```\n\nThis will handle installing the required packages into virtualenv and create template for the configuration file.\n\n### Authorization\n\nIn order to authorize the requests, please add your credentials and subdomain in `JSON` format into the `config.json` file created by install script.\n\nYou can generate the necessary credentials as described [here](https://community.canvaslms.com/t5/The-Product-Blog/Connecting-Studio-OAuth-via-Postman/ba-p/259739)\n\nOnce you have them in config.json, you won't have to deal with them anymore: the example scripts automatically handle renewing expired tokens.\n\nNote: if you access Studio under `yourschoolname.instructuremedia.com`, then subdomain in config.json should be `yourschoolname`.\n\n### Testing\n\nIn order to confirm your credentials, please run:\n\n```bash\nbin/run examples/test/main.py\n```\n\n## Usage\n\nAfter the installation, you can run the scripts using `bin/run` script:\n\n```bash\nbin/run \u003cpath_to_script_file\u003e \u003carguments\u003e\n```\n\n# Advanced topics\n## Multiple schools, multiple config files\n\nIf you want to use these scripts for multiple schools, you can have multiple config files. All of them should start with `config` and end with `.json`, e.g. `config-otherschool.json`. When you run a script that should use this other config, don't forget to specify it:\n\n```bash\nbin/run examples/test/main.py --config config-otherschool.json\n```\n\n## Overriding domain and scheme\n\nIf you want to use these scripts in other (development) environments, you can also change the domain and the url scheme in the config file. For local development, it would look like this:\n\n```json\n{\n    \"subdomain\": \"tw\",\n    \"domain\": \"studio.localhost\",\n    \"scheme\": \"http\",\n    ...\n}\n```\n\n## Studio public API client\n\nWith `bin/cli` you can discover what capabilities the public API has and prototype the workflows based on the API from UNIX commandline: it downloads the API schema, maps endpoints/methods to commands, for example GET `/media/{media_id}` to `show_media --media_id`.\nThe script currently does not support commands with parameters in the body of the HTTP request - such as `transfer_media`.\n\n### API discovery\n\nIf you run the script in itself, it will list all supported commands with a brief description.\nNote that the script supports the `--config` parameter described above.\n\nIf you run the script with a command with `--help` it will return with a help about the commands parameters.\n\n```\n❯ bin/cli show_media  --help\nusage: cli.py show_media [-h] --media_id MEDIA_ID\n\noptional arguments:\n  -h, --help           show this help message and exit\n  --media_id MEDIA_ID  The ID of the media.\n```\n\n### Running a command\n\nIf you run a command with all necessary parameters then it will return with payload (can be JSON/CSV output).\n\n```\n❯ bin/cli show_media --media_id 2\n{\n  \"media\": {\n    \"id\": 2,\n    \"title\": \"iphone_front_camera\",\n    \"description\": null,\n    \"duration\": 3.042,\n    \"created_at\": \"2020-09-18T14:27:40Z\",\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finstructure%2Fcanvas-studio-api-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finstructure%2Fcanvas-studio-api-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finstructure%2Fcanvas-studio-api-examples/lists"}