1/8/2024 0 Comments Aqua data studio tutorial pdf![]() # $ node_id "MDY6Q29tbWl0MTM3NjkyMTE1OjRlNzllYWQ3ZGI5ZDRiYjBm. Let’s consider a similar example to our git commits query, this time looking at a repository with multiple committers. API requests, like the ones outlined above, will still work fine without additional parameters, but sometimes the default requests won’t be ideal (e.g. only return the first several results and not all results). Like functions in R, you can use parameters (hopefully outlined in the API’s documentation) to narrow or broaden your request. ![]() That being said, it’s important to understand the underlying structure of API responses as outlined above.Įarlier, when discussing API requests, I skimmed over a useful aspect of constructing your query. Thus, if you know you’re going to be working with JSON responses, the jsonlite package will make your life much easier. Voila! We now have a commits_df data frame (with list columns!) that we can easily explore (and discover that I’m lonely in my sfg-aqua repo…). # $ committer c("tclavelle", "tclavelle", "tclavelle", ". # $ author c("tclavelle", "tclavelle", "tclavelle", ". # $ commit c("Tyler Clavelle", "Tyler Clavelle", "Tyl. # $ node_id "MDY6Q29tbWl0NjU5MjQxNDg6M2NiYTM5NzkyNGZjNmI1MGQx. Here’s an example using the git_commits_url for my sfg_aqua repo: # Repo URL Say I want to get data on all my git commits I can do so by extracting the git_commits_url element for each repo (which I did previously) and then making new API requests. A majority of these list elements are actually addtional API endpoint urls, meaning they tell us where we can request additional data on a given repo. I previously mentioned that there were 69 elements For each repo in the list. However, the repo_content list also contains a lot of useful information for obtaining more data about any given repo. ![]() Repo_content % bind_rows() Table 1: My (first 10) public repositories and web addresses repo There’s clearly a lot of information there (98,539 raw values), but we’ll need to use the httr::content() function to make sense of it. A glance at the content element in the list doesn’t tell us much in its current form. Looks like our request worked! Moving on, we’re going to skip the other elements for now and jump to content, the list element containing the information we’re really after. Let’s check the status_code for our request: status_code(repos) # 200 If you still can’t figure out the issue causing your 4XX error message, go get a beer and blame it on the man. If your request returns a status_code other than 200, first double check your code for spelling/syntax errors and then make sure the API endpoint you’re querying is also correct. 4XX - Server Error (something’s not right on their end).3XX - Client Error (something’s not right on your end).It’s not important to know what every status code means, but the following is a useful reference: If you’ve ever entered an incorrect web address, such as, you’ve seen a 404 status code indicating that things, uh, did not work properly. The first step is to examine the status_code, which, if everything worked properly, should read 200. Now, although some of this might look familiar, such as cookies, it doesn’t (yet) really look like what we probably expected (e.g. a list of GitHub repositories). # "content" "date" "times" "request" "handle" Names(repos) # "url" "status_code" "headers" "all_headers" "cookies" The above GET() request should result in a list object of class(repos)="response" with 10 elements, which we can explore with names(repos) # Examine response components
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |