Skip to content

Start here

What is a RESTful API?

To call a Web API RESTful, or REST, means that it meets a set of communication standards.

First of all, REST is an an acronym: REpresentational State Transfer. But that doesn't really help understanding it

There's a lot that REST APIs are used for, but I'll explain it more in the scope of what you can do with PeterPortal API.

  • A REST API is Stateless. This means that it does not rely on nor take into account previous messages that you sent to it. That means for each request you send to it, you need to send all the information that the REST API needs to understand your request.
  • Our REST API returns and accepts JSON. REST APIs are not restricted to JSON; however, that is the standard you will see for almost every public Web API. JSON syntax is similar to a Python dictionary.

The API

Error Messages

Error messages will look like this:

{
    "timestamp": "Thu, 31 Dec 2020 00:00:00 GMT",
    "status": 404,
    "error": "Error",
    "message": "Error message"
}

If you are gettnig error messages, each endpoints respective documentation will give more details and possible reasons for why they may occur.

API Reference

Here are some of the endpoints you might want to use in your project.

$ curl https://api.peterportal.org/rest/v0/courses/all

[
...
{
    "department": "I&C SCI",
    "number": "51",
    "title": "Introductory Computer Organization",
    "description": "Multilevel view of system hardware and software..."
},
...
]
$ python -m pip install requests
---> 100%
$ python
Python 3.8.5
# >>>$ import requests
# >>>$ response = requests.get("https://api.peterportal.org/rest/v0/courses/all", headers=headers)
# >>>$ response.json()

[
...
{
    "department": "I&C SCI",
    "number": "51",
    "title": "Introductory Computer Organization",
    "description": "Multilevel view of system hardware and software..."
},
...
]