Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A successful service request returns the value in a defined format. 

Testing an API with Public Data

...

Refreshing the Token

The time it takes tokens to expire is configurable but is currently two hours.

Code Block
titleNBIA REST API Call for Testing an API without a TokenSample Request for Refreshing the Token
# Request for refreshing the token  

$ curl -X -v -d "refresh_token=7c2414a1-1f2f-4c9e-82a0-69fcb9fd18ed&client_id=nbiaRestAPIClient&client_secret=ItsBetweenUAndMecurl -d "username=nbia_guest&password=&client_id=NBIA&grant_type=passwordrefresh_token" -X POST -k https://services.cancerimagingarchive.net/nbia-api/oauth/token

Refreshing the Token


        
/nbia-api/oauth/token"

In the following result, 119 is the seconds before the token expiresThe time it takes tokens to expire is configurable but is currently two hours.

Code Block
titleSample Request for Refreshing the Token
# Request for refreshing the token  

$ curl -X -v -d "refresh_token=7c2414a1-1f2f-4c9e-82a0-69fcb9fd18ed&client_id=nbiaRestAPIClient&client_secret=ItsBetweenUAndMe&grant_type=refresh_token" -X POST -k https://services.cancerimagingarchive.net/nbia-api/oauth/token
        
/nbia-api/oauth/token"

In the following result, 119 is the seconds before the token expires.

Return Value
{"access_token":"bbe4aa2c-7235-41ad-9770-31619d3dbd15","token_type":"bearer","refresh_token":"671bb72b-f929-4ef5-a4d7-b52341a6007a","expires_
Code Block
titleSample Return Value
{"access_token":"bbe4aa2c-7235-41ad-9770-31619d3dbd15","token_type":"bearer","refresh_token":"671bb72b-f929-4ef5-a4d7-b52341a6007a","expires_in":119}

Logging Out

The following is an example request to log out.

Code Block
titleSample Request to Log Out
# Request for logout   
      
$ curl -H "Authorization:Bearer caa278aa-e7a9-45b8-a7ec-2c83d4b03cc0" -k "H "Authorization:Bearer caa278aa-e7a9-45b8-a7ec-2c83d4b03cc0" -k "https://services.cancerimagingarchive.net/nbia-api/logout"

If successful, the request returns the following text.

Code Block
titleSample Return Value
 You Have Logged Out successfully.

Excerpt Include
NBIA Search REST API Guide
NBIA Search REST API Guide
nopaneltrue

Testing an API with Public Data

If you don't have a TCIA account and want to test an API, you can access public data using the NBIA guest account with no password, as follows.

Code Block
titleNBIA REST API Call for Testing an API without a Token
curl -d "username=nbia_guest&password=&client_id=NBIA&grant_type=password" -X POST -k https://services.cancerimagingarchive.net/nbia-api/logout"

If successful, the request returns the following text.

Code Block
titleSample Return Value
 You Have Logged Out successfully.

...

/oauth/token

Return Values

This section lists and explains the return values of the APIs included in both tables above.

...