Skip to content

API Documentation

Kostikas Visnia edited this page Dec 5, 2019 · 16 revisions

Contents

Notes

Parameter types

Some GET methods support pagination, filtering, sorting, and selecting. To achieve using these features you can look at these examples below.

Permissions

Student has the lowest permission. Staff has the second lowest permission. Above permissions is granted to specific users of the system.

Contribute

If you find any error or any malfunction on the system please report it, or make a pull request to fix it.

Method responses

Methods except GET returns status codes:

  • 200 on success
  • 404 on not found error
  • 401 on authentication error
  • 400 on token error
  • 500 on method error

Methods

Announcements

Fetching an Announcement:

Auth required : If the announcement is not public it requires authentication otherwise Student permission is required.
Supports: Selecting

Scope required: announcements

GET /announcements/:id

Returns an Announcement.

Example:

curl -X GET \
	 -H "Content-Type:application/json" \
	 api.it.teithe.gr/announcements/ID

Fetching all Announcements:

Auth required : Yes
Permission required : Student member or above.
Supports: Pagination, Filtering, Sorting, Selecting

Scope required: announcements

GET /announcements

Returns an array of all the Announcements.

Example:

curl -X GET \
	 -H "x-access-token: ACCESS_TOKEN" \
	 -H "Content-Type:application/json" \
	 api.it.teithe.gr/announcements

Fetching public announcements for rss:

Auth required : Yes for privte announcments
Permission required : Student member or above

Scope required: announcements

GET /announcements/feed/:type/:categoryIDs
Field Description Required
type The format of the response.Valid values: json,rss,atom yes
categoryIDs The categories of the announcements,separated by comma no

Example:

curl -X GET \
	 -H "Content-Type:application/json" \
	 api.it.teithe.gr/announcements/feed/atom

Fetching public announcements:

Auth required : No
Supports: Pagination, Filtering, Sorting, Selecting
GET /announcements/public

Returns an array of all public Announcements.

Example:

curl -X GET \
	 -H "Content-Type:application/json" \
	 api.it.teithe.gr/announcements/public

Insert new announcement:

Auth required : Yes
Permission required : Staff member or above

Scope required: edit_announcements

POST /announcements

Form data:

Field Description Required
title The title of the announcement in Greek yes
titleEn The title of the announcement in English yes
text The content of the announcement in Greek yes
textEn The content of the announcement in English yes
about The id of the category that belongs yes
publisher The info of the publisher no
uploads The files uploaded to the announcement no

Note: Only professors can access this.

Example:

curl -X POST \
	 -H "x-access-token: ACCESS_TOKEN" \
	 -H "Content-Type:application/json" \
	 -d '{"title":"Test", "titleEn": "Test", "text":"This is the text.", "textEn": "This is the english text.", "about":"CATEGORY ID"}' \
	 api.it.teithe.gr/announcements/	

Update an announcement:

Auth required : Yes
Permission required : Staff member or above.

Scope required: edit_announcements

PATCH /announcements/:id

Form data:

Field Description Required
title The title of the announcement in Greek yes
titleEn The title of the announcement in English no
text The content of the announcement in Greek no
textEn The content of the announcement in English no
about The id of the category that belongs no
publisher The info of the publisher no
uploadsEdit The files uploaded to the announcement no

Note: Only the creator of the announcement can edit the announcement.

Example:

curl -X PATCH \
	 -H "x-access-token: ACCESS_TOKEN" \
	 -H "Content-Type:application/json" \
	 -d '{"title":"Test 222222222222 EDIT"}' \
	 api.it.teithe.gr/announcements/ANNOUNCEMENT_ID

Delete an announcement:

Auth required : Yes
Permission required : Staff member or above.

Scope required: edit_announcements

DELETE /announcements/:id

Note: Only the creator of the announcement can delete the announcement.

Example:

curl -X DELETE \
	 -H "x-access-token: ACCESS_TOKEN" \
	 -H "Content-Type:application/json" \
	 api.it.teithe.gr/announcements/ANNOUNCEMENT_ID

Categories

Fetching all categories:

Auth required : Yes
Permission required : Student member or above.
Supports: Pagination, Filtering, Sorting, Selecting

Scope required: announcements

GET /categories/

Returns an array of all Categories.

Example:

curl -X GET \
	 -H "x-access-token: ACCESS_TOKEN" \
	 -H "Content-Type:application/json" \
	 api.it.teithe.gr/categories/

Fetching all public categories:

Auth required : No
Supports: Pagination, Filtering, Sorting, Selecting
GET /categories/public

Returns an array of all public Categories.

Example:

curl -X GET \
	 -H "Content-Type:application/json" \
	 api.it.teithe.gr/categories/public

Fetching all categories registration info:

Auth required : Yes
Permission required : Student member or above.
Supports: Pagination, Sorting

Scope required: announcements

GET /categories/isRegistered

Returns all the categories`id with a boolean attribute that represents if registered.

Note: Only authenticated users can access this

Update registration to categories:

Auth required : Yes
Permission required : Student member or above.

Scope required: announcements

PUT /categories/register

Form data:

Field Description Required
addCat An array of categories`id that are registered yes
removeCat An array of categories`id that are not registered yes

Note: Both arrays need to be sent as strings converted with JSON.stringify()

Insert new category:

Auth required : Yes
Permission required : Staff member or above.

Scope required: edit_announcements

POST /categories

Form data:

Field Description Required
categoryTitle The title of the category yes
publicCategory A boolean that represents if a category is public yes
wid The content of the announcement in Greek no

Update a category:

Auth required : Yes
Permission required : Staff member or above.

Scope required: edit_announcements

POST /categories/:id

Form data:

Field Description Required
CategoryTitle The title of the category yes
publicCategory A boolean that represents if category is public yes
wid The content of the announcement in Greek no

Note: Only the creator of the category can update the category.

Delete a category:

Auth required : Yes
Permission required : Staff member or above.

Scope required: edit_announcements

DELETE /categories/:id

Note: Only the creator of the category can delete the category.

Files

Note: Files that are not public needs authentication

Download a file:

Auth required: If the file is public then it requires no authentication otherwise Student permission is required.

Scope required: announcements

GET /files/:fileId

Returns the File data.

Download all files attached to announcement:

Auth required: If the files are public then it requires no authentication otherwise Student permission is required.

Scope required: announcements

GET /files/:announcementId/downloadAll

Returns a zip of Files.

View a file:

Auth required: If the files are public then it requires no authentication otherwise Student permission is required.

Scope required: announcements

GET /files/:fileId/view

Returns the File data.

Delete a file:

Auth required : Yes
Permission required : Staff member or above.

Scope required: edit_announcements

DELETE /files/:fileId

Note: Only the owner of the announcement can delete the file.

Profile

Fetching the Profile:

Auth required : Yes
Permission required : Student member or above

Scope required: profile

GET /profile

Returns the data of the Profile.

Update the profile:

Auth required : Yes
Permission required : Student member or above

Scope required: edit_profile

PATCH /profile

Form data:

Field Description Required
displayName;lang-el The name displayed to others no
labeledURI The website of the user no
telephoneNumber The phone number of the user no
secondarymail The secondary mail of the user no
description;lang-el The description of the user in Greek no
description The description of the user in English no
scientificField The fields that the user is interested no
facebook The url of the user`s facebook no
twitter The url of the user`s twitter no
github The url of the user`s github no
googlePlus The url of the user`s googlePlus no
linkedIn The url of the user`s linkedIn no
socialMediaExtra An array of elements with two values that represent the name of the social media and a url no

Delete the profile photo:

Auth required : Yes
Permission required : Student member or above

Scope required: edit_profile

DELETE /profile/photo

Users

Change password:

Auth required : Yes
Permission required : Student member or above

Scope required: edit_password

POST /user/chpw

Form data:

Field Description Required
oldPassword The old password yes
newPassword The new password yes

Change mail:

Auth required : Yes
Permission required : Student member or above

Scope required: edit_mail

POST /user/chmail

Form data:

Field Description Required
newMail The new mail yes

Send a token in mail for resetting password:

Auth required : No
POST /user/reset

Form data:

Field Description Required
mail The mail of the user yes
username The username of the user yes

Reset password with token:

Auth required : No
POST /user/reset/token

Form data:

Field Description Required
token The token retrieved by email yes
newPassword The new password yes
newPasswordVerify The new password (for verification reason) yes

Fetching a vCard of the User:

Auth required : Yes
Permission required : Student member or above
GET /user/vcard/:uid

Param data:

Field Description Required
uid The uid of the user yes

Returns a vCard of the user

Fetching users public info:

Auth required : NO
Supports: Filtering, Sorting, Selecting
GET /user

Returns an array of all Users public info (By default it only returns staff members)

Groups

Fetching all Groups:

Auth required : Yes
Permission required : Student member or above
GET /groups/:id

Param data:

Field Description Required
id The id of the group no

Returns an Group.

Auth required : Yes
Permission required : Staff member or above

Instert a new Group:

POST /groups

Form data:

Field Description Required
cn The name of the group yes

Delete a Group:

Auth required : Yes
Permission required : Staff member or above
DELETE /groups

Form data:

Field Description Required
dn The path of the group yes

Notifications

Fetching all notifications:

Auth required : Yes
Permission required : Student member or above.

Scope required: notifications

GET /notifications/

Returns an array of all Notifications.

Param data:

Field Description Required
limit The number of the notifications you need to retrieve no

Example:

curl -X GET \
	 -H "x-access-token: ACCESS_TOKEN" \
	 -H "Content-Type:application/json" \
	 api.it.teithe.gr/notifications/

Reading all notifications:

Auth required : Yes
Permission required : Student member or above.

Scope required: edit_notifications

POST /notifications/

Returns a 200 status code.

Example:

curl -X POST \
	 -H "x-access-token: ACCESS_TOKEN" \
	 -H "Content-Type:application/json" \
	 -d '' \
	 api.it.teithe.gr/notifications/	

Entities

Announcement

Attribute Description
_id The ID of the announcement
_about The id of the category that belongs
titleEn The title of the announcement in English
title The title of the announcement in Greek
textEn The content of the announcement in English
publisher The info of the publisher
date The date that the announcement has been created
attachments An array of Files`id attatched to the announcement

Category

Attribute Description
_id The ID of the category
name The name of the category in Greek
nameEn The name of the category in English
public Represents if the category is public

File

Attribute Description
_id The ID of the file
name The name of file
contentType The mimetype of the file
data The content of the file
_announcement The id of the announcement that the file is attatched to

User

Attribute Description
am The am of the user
cn The fullname in english
cn;lang-el The fullname in Greek
description The description of the user in English
description;lang-el The description of the user in Greek
displayName The name that is shown to others in English
displayName;lang-el The name that is shown to others in Greek
eduPersonAffiliation The type of the user, 'staff' or 'student'
eduPersonScopedAffiliation Users permissions. 1-> Student, 2-> Professor, 3-> Secretary, 5-> Users Admin, 9-> Admin
eduPersonEntitlement The users field of interest
eduPersonPrimaryAffiliation The category that the user belongs. If eduPersonAffiliation = staff then this field can take the following values: 'prof' -> Professor, 'associate' -> Associate Professor, 'assistant' -> Assistant Professor, 'lecturer' -> Laboratory Professor, 'tech_staff' -> Laboratory Associate, 'ept' -> ΕΤΠ, 'admin' -> Secretary, 'scientific_staff' -> Adjunct Professor, 'edip_staff' -> Laboratory Teaching Staff, 'ΠΔ407' -> PD407, 'former-faculty' -> Former Faculty/Emeritus, 'lect-espa' -> Lecturer by PA, 'acad-fellow' -> Academic Fellow. If eduPersonAffiliation = student then this field can take the following values: 'it' -> Undergraduate Student, 'ait' -> Postgraduate Student.
fathersname The name of the father in English
fathersname;lang-el The name of the father in Greek
givenName The name of the user in English
givenName;lang-el The name of the user in Greek
labeledURI The website of the user
mail The mail of the user
pwdChangedTime The date of the last password change (Format: OpenLdap Date Format)
regsem The semester of the user that has been registered
regyear The year that the user has been registered
secondarymail The secondary email of the user
sem The current semester of the user
sn The surname of the user in English
sn;lang-el The surname of the user in Greek
telephoneNumber The telephone number of the user
title The title of the user in English
title;lang-el The title of the user in Greek
profilePhoto The profile photo of the user
socialMedia The social media of the user

Group

Attribute Description
cn The name of the group
dn The path of the group
gidNumber The group Id
objectClass The object classes that the group belongs

Notification

Attribute Description
notySub Ignore this, it will be removed.
_id The ID of the notification
seen Indicates if the user seen the notification
nameEl The name in English of the publisher that triggered the notification
nameEn The name in Greek of the publisher that triggered the notification
date The date that this notification was created
related The related id of the announcement

Examples

Filtering

Lets say you want to filter the results by searching the text that contains the string "123".

GET /example?q={"text":"123"}

Lets say you want to filter the results by searching the text that contains the string "123" and the title that contains the string "hello"

GET /example?q={"text":"123","title":"hello"}

Sorting

Let's say you want to order the results by ordering the title descending.

GET /example?sort=-title

Let's say you want to order the results by ordering the title ascending.

GET /example?sort=title

Pagination

Let's say you want to limit the results by 5 entries.

GET /example?pageSize=5

Let's say you want the next page of the results after limiting it by 5 entries.

GET /example?pageSize=5&page=2

Selecting

Here you retrieve specifically only the title and the text of the results' objects

GET /example?fields=title,text

All together

Here you retrieve only the objects that have the string "123" in the text field. For those objects, only the fields "title" and "text" is returned sorted by title descending. The results are limited by 5 entries and you only retrieve the second page.

GET /example?fields=title,text&q={"text":"123"}&pageSize=5&page=2&sort=title
Clone this wiki locally