Skip to content

Commit 413fff1

Browse files
committed
removed all references to the public key
1 parent ad51a8f commit 413fff1

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

traits/02-betydb-api-access.Rmd

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,17 @@ The first step toward reproducible pipelines is to automate the process of searc
2626
### Using Your API key to Connect
2727

2828
An API key is like a password. It allows you to access data, and should be kept private.
29-
Therefore, we are not going to put it in code that we share. The one exception is the key 9999999999999999999999999999999999999999 that will allow you to access metadata tables (all tables except _traits_ and _yields_). It will also allow you to access all of the simulated data in the https://terraref.ncsa.illinois.edu/bety-test database.
29+
Therefore, we are not going to put it in code that we share.
3030

31-
A common way of handling private API keys is to place it in a text file in your current directory.
32-
Don't put it in a project directory where it might be inadvertently shared.
31+
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.
3332

3433
Here is how to find and save your API key:
3534

3635
* click file --> new --> text file
3736
* copy the api key that was sent when you registered into the file
3837
* file --> save as '.betykey'
3938

40-
For the public key, you can call this file `.betykey_public`.
39+
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.
4140

4241

4342
## Accessing data using a URL query
@@ -49,7 +48,7 @@ For the public key, you can call this file `.betykey_public`.
4948
* path to the api: `/api/v1`
5049
* api endpoint: `/search` or `traits` or `sites`. For BETYdb, these are the names of database tables.
5150
* Query parameters: `genus=Sorghum`
52-
* Authentication: `key=9999999999999999999999999999999999999999` is the public key for the TERRA REF traits database.
51+
* 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.
5352

5453
### Constructing a URL query
5554

@@ -62,17 +61,16 @@ First, lets construct a query by putting together a URL.
6261
3. Add the name of the table you want to query. Lets start with `variables`
6362
* terraref.ncsa.illinois.edu/bety/api/v1/variables
6463
4. add query terms by appending a `?` and combining with `&`, for example:
65-
* `key=9999999999999999999999999999999999999999`
6664
* `type=trait` where the variable type is 'trait'
6765
* `name=~height` where the variable name contains 'height'
6866
5. This is your complete query:
69-
* `terraref.ncsa.illinois.edu/bety/api/v1/variables?type=trait&name=~height&key=9999999999999999999999999999999999999999`
67+
* `terraref.ncsa.illinois.edu/bety/api/v1/variables?type=trait&name=~height`
7068
* it will query all variables that are type trait and have 'height' in the name
7169
* Does it return the expected values?
7270

7371
## Your Turn
7472

75-
> What will the URL https://terraref.ncsa.illinois.edu/bety/api/v1/species?genus=Sorghum&key=9999999999999999999999999999999999999999 return?
73+
> What will the URL https://terraref.ncsa.illinois.edu/bety/api/v1/species?genus=Sorghum return?
7674
7775
> Write a URL that will query the database for sites with "Field Scanner" in the name field. Hint: combine two terms with a `+` as in `Field+Scanner`
7876
@@ -84,14 +82,14 @@ Type the following command into a bash shell (the `-o` option names the output f
8482

8583
```sh
8684
curl -o sorghum.json \
87-
"https://terraref.ncsa.illinois.edu/bety/api/v1/species?genus=Sorghum&key=9999999999999999999999999999999999999999"
85+
"https://terraref.ncsa.illinois.edu/bety/api/v1/species?genus=Sorghum"
8886
```
8987

9088
If you want to write the query without exposing the key in plain text, you can construct it like this:
9189

9290
```sh
9391
curl -o sorghum.json \
94-
"https://terraref.ncsa.illinois.edu/bety/api/v1/species?genus=Sorghum&key=`cat .betykey_public`"
92+
"https://terraref.ncsa.illinois.edu/bety/api/v1/species?genus=Sorghum"
9593
```
9694

9795
## Using the R jsonlite package to access the API with a URL query

0 commit comments

Comments
 (0)