Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
macrini committed Nov 7, 2024
1 parent 8d614a9 commit 9293189
Show file tree
Hide file tree
Showing 2 changed files with 191 additions and 69 deletions.
135 changes: 129 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,60 @@ The UNIWeb API allows institutions to seamlessly integrate UNIWeb with their exi
- **Flexible Filtering**: Query specific data subsets to optimize response times
- **Reference Implementation**: PHP client library with example use cases

## Quick Start
## Implementation Options

### Installation Options
### 1. Simple Integration

Before implementing the API, consider if you just need to embed UNIWeb content. You can use the embed parameter:

```html
<iframe
src="https://your-uniweb-instance.com/embed/profile/members/[MEMBER_ID]"
frameborder="0"
width="80%"
height="600px"
></iframe>
```

### 2. Using Postman or Direct HTTP Requests

The simplest way to test and use the API is through direct HTTP requests. Here are some common examples:

```bash
# Get user profile information
GET {{BASE_API_URL}}/resource.php?action=read
&resources[]=profile/affiliations
&resources[]=profile/membership_information
&id=833

# Get members by unit and title
GET {{BASE_API_URL}}/resource.php?action=read
&resources[]=profile/affiliations
&resources[]=profile/membership_information
&filter[unit]=University of XYZ
&filter[title]=Professor

# Get all members
GET {{BASE_API_URL}}/resource.php?action=getMembers&onlyPublic=0

# Get profile picture
GET {{BASE_API_URL}}/picture.php?action=display
&contentType=members
&id=833
&quality=large
```

### 3. Using the PHP Client

Begin by installing [PHP Composer](https://getcomposer.org/download/) if you don't already have it.

#### Option 1: Create a New Project (Recommended for Testing)

```bash
# Creates a new project with example code and CLI testing tools
composer create-project proximify/uniweb-api

# Optional: specify custom installation path
# Optional: specify custom installation name or path
composer create-project proximify/uniweb-api my-test
```

Expand All @@ -47,15 +90,18 @@ composer require proximify/uniweb-api
4. Enter a client name and save
5. Click "View" on your new client to reveal the secret key

> [!TIP]
> Review the Profile and CV data schemas located at Administration → Schemas
### 2. Configure Credentials

Create `settings/credentials.json`:

```json
{
"clientName": "your_client_name",
"clientSecret": "your_client_secret",
"homepage": "your_uniweb_instance_url"
"clientName": "your_client_name",
"clientSecret": "your_client_secret",
"homepage": "your_uniweb_instance_url"
}
```

Expand Down Expand Up @@ -100,14 +146,90 @@ For detailed API documentation, see [Complete UNIWeb API Documentation](docs/uni
## Sample Use Cases

The `queries` folder contains example code for common API operations:

- Fetching user profiles
- Updating research activities
- Retrieving publication data
- And more...

## Resource Paths

Resources are identified by paths following this structure:

```
page/section/subsection/...
```

Example paths:

- `profile/affiliations`
- `cv/education/degrees`
- `profile/membership_information`

### Content Types

- `members`: Individual user data
- `units`: Organizational unit data
- `groups`: Group-related data

## Common Operations

### Reading Data

Send as GET or POST parameters.

```json
{
"action": "read",
"content": "members",
"filter": {
"unit": "Civil Engineering"
},
"resources": ["profile/biography"]
}
```

### Filtering Options

- `unit`: Filter by department/unit
- `title`: Filter by title (e.g., "Professor")
- `loginName`: Filter by username/email
- `modified_since`: Filter by modification date
- `onlyPublic`: Include/exclude private data

### Language Support

Add `language` parameter:

- `en`: English responses
- `fr`: French responses

## Error Handling

Errors are returned in JSON format:

```json
{
"error": {
"message": "Error description",
"type": "ErrorType",
"code": 98,
"error_subcode": 223
}
}
```

Common error codes:

- 98: OAuth token validation error
- 401: Unauthorized
- 403: Insufficient permissions
- 404: Resource not found

## API Capabilities

The UNIWeb API provides:

- Secure authentication
- User data management
- Research activity tracking
Expand All @@ -118,6 +240,7 @@ The UNIWeb API provides:
## Support

For technical questions or issues:

1. Check the [API Documentation](docs/uniweb-api.md)
2. Create an issue in this repository
3. Contact UNIWeb support through your institutional channels
125 changes: 62 additions & 63 deletions docs/uniweb-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,29 @@

# UNIWeb API

## Preamble
## Quick Note: Simple Integration

Before you spend time reading about the UNIWeb API, it is important to determine whether you need the API at all. There are some scenarios that can be resolved with the API, but that can also be resolved in a simpler way. One such case is the embedding of UNIWeb pages into an institutional website. UNIWeb pages allow for a special parameter to signal that the page will be embedded.
Before implementing the API, consider if you just need to embed UNIWeb content. You can use the embed parameter:

<pre>
<iframe src="https://uniweb.uottawa.ca/?embed=1#!uottawa/members/1667/profile" width="400" height="300"></iframe>
</pre>

The <code>?embed=1</code> part of the URI tells UNIWeb to only show the **main** content of the page and hide everything else. With this approach, user profiles and other pages can easily be reused in different contexts within an institutional website.
```html
<iframe
src="https://your-uniweb-instance.com/?embed=1#!uottawa/members/1667/profile"
width="400"
height="300"
>
</iframe>
```

## API Overview

The purpose of the API is to integrate UNIWeb with other systems within your organization. The Authenticated API provides secure read/write access to information stored by UNIWeb, and it provides a mechanism to reduce the need to duplicate data.

The UNIWeb API provides:

- An interface that allows you to control who has access to your institution's data through our API.
- A means by which to securely read and update your institution's information.
- Rich data in simple, straightforward JSON for maximum readability and reusability.
- The choice to pre-filter the requested data, to obtain just the subset of information in which you are interested.
- An interface that allows you to control who has access to your institution's data through our API.
- A means by which to securely read and update your institution's information.
- Rich data in simple, straightforward JSON for maximum readability and reusability.
- The choice to pre-filter the requested data, to obtain just the subset of information in which you are interested.

The UNIWeb API uses [Internet Engineering Task Force (IETF)](http://www.ietf.org/) open authentication standard [OAuth 2.0](http://oauth.net/2/), for authentication and authorization using the [Resource Owner Password Credentials Grant protocol](http://tools.ietf.org/html/rfc6749#section-4.3). In this protocol, only users with granted permission can access the API.

Expand Down Expand Up @@ -72,7 +75,7 @@ With the client credentials obtained in step 3, you can authenticate to the UNIW

With these pieces of information you will be allowed to make API requests. To do so, you can use one of our pre-built client libraries

- [PHP client lib](../README.md)
- [PHP client lib](../README.md)

#### 4. Access information through structured requests

Expand All @@ -82,33 +85,33 @@ Example request object:

```json
{
"action": "read",
"content": "members",
"filter": {
"loginName": "[email protected]"
},
"resource": ["profile/biography", "profile/selected_degrees"]
"action": "read",
"content": "members",
"filter": {
"loginName": "[email protected]"
},
"resource": ["profile/biography", "profile/selected_degrees"]
}
```

Example response for the above request:

```json
{
"[email protected]": {
"profile/biography": "Bob always knew he would be a great scientist",
"profile/selected_degrees": [
{
"degree_name": "PhD",
"organization": "McGill University",
"specialty": "Materials Engineering"
},
{
"degree_name": "Engineering",
"organization": "University of Ottawa"
}
]
}
"[email protected]": {
"profile/biography": "Bob always knew he would be a great scientist",
"profile/selected_degrees": [
{
"degree_name": "PhD",
"organization": "McGill University",
"specialty": "Materials Engineering"
},
{
"degree_name": "Engineering",
"organization": "University of Ottawa"
}
]
}
}
```

Expand Down Expand Up @@ -139,7 +142,7 @@ Optionally, a request path can be specified as a JSON object. In particular, thi

```json
{
"page/section/section/section/...": ["field name A", "field name B", "..."]
"page/section/section/section/...": ["field name A", "field name B", "..."]
}
```

Expand Down Expand Up @@ -504,12 +507,12 @@ The request that follows would return the public profile information of all peop

```json
{
"action": "read",
"content": "members",
"filter": {
"unit": "Civil Engineering"
},
"resources": "profile"
"action": "read",
"content": "members",
"filter": {
"unit": "Civil Engineering"
},
"resources": "profile"
}
```

Expand All @@ -522,24 +525,20 @@ The request that follows would return two resources belonging to the user with l

```json
{
"action": "read",
"content": "members",
"language": "fr",
"filter": {
"unit": "McGill",
"title": "Professor",
"login": "[email protected]"
},
"resources": [
"profile/research_interests",
{
"cv/education/degrees": [
"degree_name",
"specialization",
"thesis_title"
]
}
]
"action": "read",
"content": "members",
"language": "fr",
"filter": {
"unit": "McGill",
"title": "Professor",
"login": "[email protected]"
},
"resources": [
"profile/research_interests",
{
"cv/education/degrees": ["degree_name", "specialization", "thesis_title"]
}
]
}
```

Expand All @@ -551,11 +550,11 @@ Errors will give information about what went wrong with a corresponding request.

```json
{
"error": {
"message": "Error validating access token.",
"type": "OAuthException",
"code": 98,
"error_subcode": 223
}
"error": {
"message": "Error validating access token.",
"type": "OAuthException",
"code": 98,
"error_subcode": 223
}
}
```

0 comments on commit 9293189

Please sign in to comment.