{"id":15017618,"url":"https://github.com/dementiy/vkr","last_synced_at":"2025-08-20T09:30:41.435Z","repository":{"id":29603095,"uuid":"33143232","full_name":"Dementiy/vkR","owner":"Dementiy","description":"Access to VK (Vkontakte) API via R","archived":false,"fork":false,"pushed_at":"2020-09-25T17:50:21.000Z","size":7991,"stargazers_count":56,"open_issues_count":22,"forks_count":18,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-12-19T09:08:11.031Z","etag":null,"topics":["api","r","vkontakte"],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dementiy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-30T19:26:04.000Z","updated_at":"2024-01-29T11:29:08.000Z","dependencies_parsed_at":"2022-08-21T01:10:17.935Z","dependency_job_id":null,"html_url":"https://github.com/Dementiy/vkR","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dementiy%2FvkR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dementiy%2FvkR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dementiy%2FvkR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dementiy%2FvkR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dementiy","download_url":"https://codeload.github.com/Dementiy/vkR/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230408171,"owners_count":18220974,"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","r","vkontakte"],"created_at":"2024-09-24T19:50:45.816Z","updated_at":"2024-12-19T09:08:19.258Z","avatar_url":"https://github.com/Dementiy.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Travis-CI Build Status](https://travis-ci.org/Dementiy/vkR.svg?branch=master)](https://travis-ci.org/Dementiy/vkR)\n[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/vkR)](https://cran.rstudio.com/web/packages/vkR/)\n\n`vkR` is an R package which provides access to the [VKontakte](https://vk.com/) (VK) API.\n\n## Installation\n\nTo get the current released version from CRAN:\n```r\ninstall.packages(\"vkR\")\n```\n\nTo get the current development version from github:\n``` r\ninstall.packages(\"devtools\")\ndevtools::install_github(\"Dementiy/vkR\")\nlibrary(\"vkR\")\n```\n\n## Authorization\n\nMost API requests require the use of an access token. VK has several types of authorization mechanisms. Check out the [documentation](https://vk.com/dev/authentication) for more details.\n\n``` r\nvkOAuth(CLIENT_ID, 'SCOPE', 'EMAIL', 'PASSWORD')\n```\n\nwhere:\n* `CLIENT_ID` - is an application ID. You have to create new [Standalone-app](https://vk.com/dev/standalone) in VK to get ID (or use the already existing).\n* `SCOPE` - the list of comma separated access rights, e.g. `'friends,groups'`- provide the access to user friends and groups. List of all rights can be found [here](https://vk.com/dev/permissions).\n* `EMAIL` and `PASSWORD` - username and password.\n\nIf the `EMAIL` and `PASSWORD` have been omitted, a browser window will be opened. In the address bar an access token will be shown. Access token must be copied and passed as an argument into the following function:\n\n``` r\nsetAccessToken(access_token = 'YOUR ACCESS TOKEN')\n```\n\n## Example of use\n\nAt your own risk you can use mongodb and [mongolite](https://github.com/jeroen/mongolite) package for storing data:\n\n```r\n\u003e db_init()\n\u003e wall \u003c- getWallExecute(domain=\"data_mining_in_action\", count=0, use_db=TRUE, progress_bar=TRUE)\n|======================...======================| 100%\n\u003e show_collections()\n    db            collection       suffix count\n1 temp data_mining_in_action         wall   232\n```\n\nIf connection was aborted by some reasons we don't lose our data:\n```r\n\u003e wall \u003c- getWallExecute(domain='privivkanet', count=0, use_db = T, progress_bar = T)\n|=================                              |  25%\nShow Traceback\n \n Rerun with Debug\n Error in curl::curl_fetch_memory(url, handle = handle) : \n  Operation was aborted by an application callback ...\n\u003e show_collections()\n    db            collection       suffix count\n1 temp data_mining_in_action         wall   232\n2 temp           privivkanet         wall   916\n\u003e wall \u003c- getWallExecute(domain='privivkanet', count=0, offset=916, use_db = T, progress_bar = T)\n|======================...======================| 100%\n\u003e show_collections()\n    db            collection       suffix count\n1 temp data_mining_in_action         wall   232\n2 temp           privivkanet         wall  3664\n```\n\nYou can specify the collection name:\n```r\n\u003e wall \u003c- getWallExecute(domain=\"data_mining_in_action\", count=0, \n        use_db=TRUE, db_params=list('collection'='dm', 'suffix'='posts'), progress_bar=TRUE)\n|======================...======================| 100%\n\u003e show_collections()\n    db            collection       suffix count\n1 temp data_mining_in_action         wall   232\n2 temp           privivkanet         wall  3664\n3 temp                    dm        posts   232\n\n\u003e friends \u003c- getFriends()\n\u003e users \u003c- getUsersExecute(friends$items, use_db = TRUE, db_params=list('collection'='my_friends'), progress_bar = TRUE)\n\u003e show_collections()\n    db            collection       suffix count\n1 temp data_mining_in_action         wall   232\n2 temp           privivkanet         wall  3664\n3 temp                    dm        posts   232\n4 temp            my_friends                141\n```\n\nFor load collection into a namespace you can use `db_load_collection` function:\n```r\n\u003e db_load_collection('data_mining_in_action', 'wall')\n Imported 232 records. Simplifying into dataframe...\n\u003e ls()\n[1] \"temp.data_mining_in_action.wall\"\n\u003e nrow(temp.data_mining_in_action.wall)\n[1] 232\n```\n\nBuilding a Friend Graph:\n\n``` r\nmy_friends \u003c- getFriends(fields = 'sex')\nmy_friends \u003c- filter(my_friends$items, is.na(deactivated))\nnetwork \u003c- getNetwork(my_friends$id)\n\nlibrary(\"igraph\")\ng \u003c- graph.adjacency(as.matrix(network), weighted = T, mode = \"undirected\")\nlayout \u003c- layout.fruchterman.reingold(g)\nplot(g, layout = layout)\n```\n\nAnalyzing community activity:\n``` r\ndomain \u003c- 'nipponkoku'\nwall \u003c- getWallExecute(domain = domain, count = 0, progress_bar = TRUE)\nmetrics \u003c- jsonlite::flatten(wall$posts[c(\"date\", \"likes\", \"comments\", \"reposts\")])\nmetrics$date \u003c- as.POSIXct(metrics$date, origin=\"1970-01-01\", tz='Europe/Moscow')\n\nlibrary(dplyr)\ndf \u003c- metrics %\u003e% \n  mutate(period = as.Date(cut(date, breaks='month'))) %\u003e% \n  group_by(period) %\u003e%\n  summarise(likes = sum(likes.count), comments = sum(comments.count), reposts = sum(reposts.count), n = n())\n\nlibrary(ggplot2)\nlibrary(tidyr)\nggplot(data=gather(df, 'type', 'count', 2:5), aes(period, count)) + geom_line(aes(colour=type)) +\n  labs(x='Date', y='Count')\n```\n\n\u003ccenter\u003e\u003cimg src=\"images/community_activity.png\" alt=\"Coomunity activity\" style=\"width: 640px;\"/\u003e\u003c/center\u003e\n\nYou can find more examples in `examples` directory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdementiy%2Fvkr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdementiy%2Fvkr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdementiy%2Fvkr/lists"}