I want to access data provided by an API. How do I make a call to the API to get the data?

In order to access the data provided by an API, follow the steps below.

Get the Consumer Key and Secret

  1. Browse the documentation of the available APIs to help you select one
  2. Register your application
  3. Depending on the API you request access to, the approval may take a couple of days or be automatic
  4. Go to My Apps and click on the application you just registered
  5. Copy the "Consumer Key" and "Consumer Secret" for use in the section below (as client id and client secret respectively)

Make the API call

  1. HTTP request to get an access token:

    curl -X POST --header "Content-Type: application/x-www-form-urlencoded;charset=utf-8" -d "grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET" "https://api.oregonstate.edu/oauth2/token"

  2. HTTP to make a request to the API using the access token:

    curl -X GET --header "Content-Type: application/x-www-form-urlencoded;charset=utf-8" --header "Authorization: Bearer ACCESS_TOKEN" "https://api.oregonstate.edu/<API-ENDPOINT>"