...
- 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).
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 language js title CURL Registering for an API key example collapse true 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 language c# title C# RestClient registering for an API key example collapse true 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 language js title JavaScript XMLHttpRequest registering for an API key example collapse true 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);
An email will arrive shortly to the email address you provided with your API key, and a Confirmation code.
POST to the Confirm method (v1/Account/Confirm) your email and Confirmation code to activate your API key.
Code Block language js title CURL Confirmation of account example collapse true 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 language c# title C# RestClient Confirmation of account example collapse true 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 language js title JavaScript XMLHttpRequest Confirmation of account example collapse true 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);
- 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
- Get using!
...