Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: - Change to encoded query string examples

...

  1. You'll need to get an API key to use for all your interactions with the Open Data API. You can get a key by using the Account endpoint (/v3/account).

  2. POST your valid email address, project name and description, and project URL (such as to the website, app store, etc.) to the Register method (/v3/account/register). If successful you'll get a HTTP Status Code 200 response with your email in the body.

    Code Block
    languagejs
    titleCURL Registering for an API key example
    collapsetrue
    curl --request POST \
      --url https://openapi.data.uwaterloo.ca/v3/account/register \
      --header 'content-type: multipartapplication/form-data; boundary=---011000010111000001101001x-www-form-urlencoded' \
      --formdata 'email=example@email.com \
      --form 'project=1000th Best Project' \
      --form uri=https://example&project=example%20project&uri=https%3A%2F%2Fexample.project.com'
    Code Block
    languagec#
    titleC# RestClient registering for an API key example
    collapsetrue
    var client = new RestClient("https://openapi.data.uwaterloo.ca/v3/account/register");
    var request = new RestRequest(Method.POST);
    request.AddHeader("content-type", "multipartapplication/form-data; boundary=---011000010111000001101001x-www-form-urlencoded");
    request.AddParameter("multipartapplication/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\nexample@emailx-www-form-urlencoded", "email=example%40email.com&project=Example%20Project&uri=https%3A%2F%2Fexample.project.com", ParameterType.RequestBody);
    IRestResponse response = client.Execute(request);
    Code Block
    languagejs
    titleJavaScript XMLHttpRequest registering for an API key example
    collapsetrue
    var data = new FormData(); data.append("email", "example@email.com");
    data.append("project", "1000th Best Project");
    data.append("uri", "https://example=example%40email.com&project=Example%20Project&uri=https%3A%2F%2Fexample.project.com");
    
    var xhr = new XMLHttpRequest();
    xhr.withCredentials = true;
    
    xhr.addEventListener("readystatechange", function () {
      if (this.readyState === this.DONE) {
        console.log(this.responseText);
      }
    });
    
    xhr.open("POST", "https://openapi.data.uwaterloo.ca/v3/account/register");
    xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
    
    xhr.send(data);
  3. An email will arrive shortly to the email address you provided with your API key, and a Confirmation code.

  4. POST to the Confirm method (v1/Account/Confirm) your email and Confirmation code to activate your API key.

    Code Block
    languagejs
    titleCURL Confirmation of account example
    collapsetrue
    curl --request POST \
      --url https://openapi.data.uwaterloo.ca/v3/account/confirm \
      --header 'content-type: multipartapplication/form-data; boundary=---011000010111000001101001x-www-form-urlencoded' \
      --formdata 'email=example@emailexample%40email.com \
      --form &code=your_confirmation_code_from_email'
    Code Block
    languagec#
    titleC# RestClient Confirmation of account example
    collapsetrue
    var client = new RestClient("https://openapi.data.uwaterloo.ca/v3/account/confirm");
    var request = new RestRequest(Method.POST);
    request.AddHeader("content-type", "multipartapplication/form-data; boundary=---011000010111000001101001x-www-form-urlencoded");
    request.AddParameter("multipartapplication/form-data; boundary=---011000010111000001101001x-www-form-urlencoded", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\nexample@email.comemail=example%40email.com&code=%7Byour-confirmation-key%7D", ParameterType.RequestBody);
    IRestResponse response = client.Execute(request);
    Code Block
    languagejs
    titleJavaScript XMLHttpRequest Confirmation of account example
    collapsetrue
    var data = new FormData(); data.append("email", "example@email.com");
    data.append("code", "your_confirmation_code_from_email")=example%40email.com&code=%7Byour-confirmation-key%7D";
    
    var xhr = new XMLHttpRequest();
    xhr.withCredentials = true;
    
    xhr.addEventListener("readystatechange", function () {
      if (this.readyState === this.DONE) {
        console.log(this.responseText);
      }
    });
    
    xhr.open("POST", "https://openapi.data.uwaterloo.ca/v3/account/confirm");
    xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
    
    xhr.send(data);
  5. On success you'll get back a HTTP status code 200 response, or a 400 Bad Request in case of any failures. On success your account API key is confirmed and activated
  6. Get using!

...