Title: | R Interface to Access CalPASS API |
---|---|
Description: | Implements methods for querying data from CalPASS using its API. CalPASS Plus. MMAP API V1. <https://mmap.calpassplus.org/docs/index.html>. |
Authors: | Vinh Nguyen [aut, cre] |
Maintainer: | Vinh Nguyen <[email protected]> |
License: | GPL-3 |
Version: | 0.0.3 |
Built: | 2024-11-20 03:04:02 UTC |
Source: | https://github.com/vinhdizzo/calpassapi |
Create interSegmentKey's from students' first names, last names, genders, and birthdates
calpass_create_isk(first_name, last_name, gender, birthdate)
calpass_create_isk(first_name, last_name, gender, birthdate)
first_name |
a character vector of students' first names. |
last_name |
a character vector of students' last names. |
gender |
a character vector of students' genders. The first character will be used (uppercase'd automatically), and should take on values |
birthdate |
a character or numeric vector of birthdates of the form |
a vector of interSegmentKey's
Vinh Nguyen
## single calpass_create_isk(first_name='Jane', last_name='Doe' , gender='F', birthdate=20001231) ## data frame ## Not run: firstname <- c('Tom', 'Jane', 'Jo') lastname <- c('Ng', 'Doe', 'Smith') gender <- c('Male', 'Female', 'X') birthdate <- c(2001231, 19990101, 19981111) df <- data.frame(firstname, lastname , gender, birthdate, stringsAsFactors=FALSE) library(dplyr) df %>% mutate(isk=calpass_create_isk(first_name=firstname , last_name=lastname , gender=gender , birthdate )) ## End(Not run)
## single calpass_create_isk(first_name='Jane', last_name='Doe' , gender='F', birthdate=20001231) ## data frame ## Not run: firstname <- c('Tom', 'Jane', 'Jo') lastname <- c('Ng', 'Doe', 'Smith') gender <- c('Male', 'Female', 'X') birthdate <- c(2001231, 19990101, 19981111) df <- data.frame(firstname, lastname , gender, birthdate, stringsAsFactors=FALSE) library(dplyr) df %>% mutate(isk=calpass_create_isk(first_name=firstname , last_name=lastname , gender=gender , birthdate )) ## End(Not run)
Obtain a token from CalPASS using your API credentials, which should allow access for 60 minutes.
calpass_get_token( username = Sys.getenv("cp_api_uid"), password = Sys.getenv("cp_api_pwd"), client_id, scope, auth_endpoint = "https://oauth.calpassplus.org/connect/token", verbose = FALSE )
calpass_get_token( username = Sys.getenv("cp_api_uid"), password = Sys.getenv("cp_api_pwd"), client_id, scope, auth_endpoint = "https://oauth.calpassplus.org/connect/token", verbose = FALSE )
username |
API username. For security reasons, the user could specify |
password |
API password. The user could specify |
client_id |
parameter needed in the http body in order to obtain a token (unique to |
scope |
parameter needed in the http body in order to obtain a token (unique to |
auth_endpoint |
Authentication endpoint/url, defaults to |
verbose |
If |
CalPASS token string
Vinh Nguyen
## Not run: cp_token <- calpass_get_token(username='my_cp_api_uid', password='my_cp_api_pwd' , client_id='my_client_id' , scope='my_scope' ) ## End(Not run)
## Not run: cp_token <- calpass_get_token(username='my_cp_api_uid', password='my_cp_api_pwd' , client_id='my_client_id' , scope='my_scope' ) ## End(Not run)
Query data from CalPASS API endpoints for a single interSegmentKey
calpass_query( interSegmentKey, token, api_url = "https://mmap.calpassplus.org/api", endpoint = c("transcript", "placement"), verbose = FALSE ) calpass_query_many( interSegmentKey, token, api_url = "https://mmap.calpassplus.org/api", endpoint = c("transcript", "placement"), verbose = FALSE, api_call_limit = 3200, limit_per_n_sec = 3600, wait = FALSE, token_username, token_password, token_client_id, token_scope )
calpass_query( interSegmentKey, token, api_url = "https://mmap.calpassplus.org/api", endpoint = c("transcript", "placement"), verbose = FALSE ) calpass_query_many( interSegmentKey, token, api_url = "https://mmap.calpassplus.org/api", endpoint = c("transcript", "placement"), verbose = FALSE, api_call_limit = 3200, limit_per_n_sec = 3600, wait = FALSE, token_username, token_password, token_client_id, token_scope )
interSegmentKey |
for |
token |
(optional) a token object created from calpass_get_token. If this is not specified, then |
api_url |
defaults to |
endpoint |
the api endpoint to use; defaults to |
verbose |
If |
api_call_limit |
the number of api calls allowed per |
limit_per_n_sec |
time frame where |
wait |
indicates whether the user is willing to wait |
token_username |
(optional, required if |
token_password |
(optional, required if |
token_client_id |
(optional, required if |
token_scope |
(optional, required if |
a data frame with columns interSegmentKey
, status_code
(the http response code: 200 means student was found, 204 means student was not found, 429 means the api limit was reached and student was not processed, and anything else in the 400's correspond to http errors.)
calpass_query_many
: Query data from CalPASS API endpoints with a vector of interSegmentKey's. The number of rows returned corresponds to the number of unique interSegmentKey's.
Vinh Nguyen
## Not run: ## get access token cp_token <- calpass_get_token(username='my_cp_api_uid', password='my_cp_api_pwd') ## single run isk <- calpass_create_isk(first_name='Jane', last_name='Doe' , gender='F', birthdate=20001231) calpass_query(interSegmentKey=isk , token=cp_token, endpoint='transcript') calpass_query(interSegmentKey=isk , token=cp_token, endpoint='placement') ## multiple firstname <- c('Tom', 'Jane', 'Jo') lastname <- c('Ng', 'Doe', 'Smith') gender <- c('Male', 'Female', 'X') birthdate <- c(20001231, 19990101, 19981111) df <- data.frame(firstname, lastname , gender, birthdate, stringsAsFactors=FALSE) library(dplyr) df %>% mutate(isk=calpass_create_isk(first_name=firstname , last_name=lastname , gender=gender , birthdate )) dfResults <- calpass_query_many(interSegmentKey=df$isk , token=cp_token , endpoint='transcript' ) ## End(Not run)
## Not run: ## get access token cp_token <- calpass_get_token(username='my_cp_api_uid', password='my_cp_api_pwd') ## single run isk <- calpass_create_isk(first_name='Jane', last_name='Doe' , gender='F', birthdate=20001231) calpass_query(interSegmentKey=isk , token=cp_token, endpoint='transcript') calpass_query(interSegmentKey=isk , token=cp_token, endpoint='placement') ## multiple firstname <- c('Tom', 'Jane', 'Jo') lastname <- c('Ng', 'Doe', 'Smith') gender <- c('Male', 'Female', 'X') birthdate <- c(20001231, 19990101, 19981111) df <- data.frame(firstname, lastname , gender, birthdate, stringsAsFactors=FALSE) library(dplyr) df %>% mutate(isk=calpass_create_isk(first_name=firstname , last_name=lastname , gender=gender , birthdate )) dfResults <- calpass_query_many(interSegmentKey=df$isk , token=cp_token , endpoint='transcript' ) ## End(Not run)