Skip to content

Commit b3d0a6a

Browse files
authored
Update 02-betydb-api-access.Rmd (#42) (#98)
1 parent 42729ad commit b3d0a6a

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

traits/02-betydb-api-access.Rmd

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,23 @@ Therefore, we are not going to put it in code that we share.
3131

3232
A common way of handling private API keys is to place it in a text file in your current directory. Don't put it in a project directory where it might be inadvertently shared.
3333

34-
Here is how to find and save your API key:
34+
Here is how to find and save your API key to a hidden file:
3535

3636
* click file --> new --> text file
3737
* copy the api key that was sent when you registered into the file
38-
* file --> save as '.betykey'
39-
40-
An API key is not needed to access public data. This includes metadata tables and simulated data in the https://terraref.ncsa.illinois.edu/bety-test database.
41-
38+
* file --> save as '.betykey' (don't use apostrophes).
39+
* you won't be able to see this file in the file browser in R Studio, as this build doesn't allow display of hidden files in this window. To see your hidden file, open the terminal window in that folder and type 'ls -a'
4240

41+
An API key is not needed to access public data includes sample datasets and metadata.
4342

4443
## Accessing data using a URL query
4544

4645

4746
### Components of a URL query
4847

49-
* base url: `terraref.ncsa.illinois.edu/bety`
50-
* path to the api: `/api/v1`
51-
* api endpoint: `/search` or `traits` or `sites`. For BETYdb, these are the names of database tables.
48+
* Base url: `terraref.ncsa.illinois.edu/bety`
49+
* Path to the api: `/api/v1`
50+
* API endpoint: `/search` or `traits` or `sites`. For BETYdb, these are the names of database tables.
5251
* Query parameters: `genus=Sorghum`
5352

5453
* Authentication: `key=api_key` is your assigned API key. This will only be needed when querying trait data. No key is needed to access the public metadata tables.
@@ -61,16 +60,16 @@ First, lets construct a query by putting together a URL.
6160
1. start with the database url: `terraref.ncsa.illinois.edu/bety`
6261
* this url brings you to the home page
6362
2. Add the path to the API, `/api/v1`
64-
* now we have terraref.ncsa.illinois.edu/bety/api/v1, which points to the API documentation
63+
* now we have terraref.ncsa.illinois.edu/bety/api/v1, which points to the API documentation for additional detail on available options
6564
3. Add the name of the table you want to query. Lets start with `variables`
6665
* terraref.ncsa.illinois.edu/bety/api/v1/variables
67-
4. add query terms by appending a `?` and combining with `&`, for example:
66+
4. Add query terms by appending a `?` and combining with `&`. These can be done in any order. For example:
6867
* `type=trait` where the variable type is 'trait'
6968
* `name=~height` where the variable name contains 'height'
70-
5. This is your complete query:
69+
5. Assembling all of this, you have a complete query:
7170
* `terraref.ncsa.illinois.edu/bety/api/v1/variables?type=trait&name=~height`
72-
* it will query all variables that are type trait and have 'height' in the name
73-
* Does it return the expected values?
71+
* This will query all trait variables that have 'height' in their name.
72+
* Does it return the expected values? There should be two.
7473

7574
## Your Turn
7675

0 commit comments

Comments
 (0)