Skip to content

Commit

Permalink
Adding all the other pages
Browse files Browse the repository at this point in the history
  • Loading branch information
yuenmichelle1 committed Dec 15, 2023
1 parent ee0c9b8 commit 6e65ccd
Show file tree
Hide file tree
Showing 8 changed files with 453 additions and 116 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_site
.jekyll-cache
4 changes: 2 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
title: Test ERAS Doc
description: Test ERAS API Doc for Zooniverse's Stats Service
title: ERAS API Docs
description: ERAS API Documentation for Zooniverse's Stats Service
theme: just-the-docs

aux_links:
Expand Down
52 changes: 52 additions & 0 deletions examples-in-other-languages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: Examples in Other Languages
layout: page
nav_order: 6
---

# Quick Examples in Other Languages


## Python
```
import requests
api_url = 'https://eras.zooniverse.org/classifications'
headers = {'authorization': f"Bearer {_YOUR_BEARER_TOKEN_}"}
user_classification_counts_url = api_url + '/users/1234'
r = requests.get(user_classification_counts_url, headers=headers)
if r.status_code == 200:
data = r.json()
# Do something with data
else:
print('Error with retrieving data')
```

## Javascript

The following example is an authenticated callout to `/users` where `user_id=1234`
```
import fetch from 'node-fetch'
const apiUrl = 'https://eras.zooniverse.org/classifications'
const headers = { authorization: `Bearer ${_YOUR_BEARER_TOKEN_}`
}
fetch(apiUrl + '/users/1234', { headers })
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok')
}
return response.json();
})
.then(data => {
console.log('Data : ', data);
// Do something with the data
})
.catch(error => {
console.error('There was an error with fetching data')
});
```
91 changes: 0 additions & 91 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,94 +39,3 @@ If you are familiar with our older stats service ([https://github.com/zooniverse
* [https://eras.zooniverse.org](https://eras.zooniverse.org) Response Example:
* [https://stats.zooniverse.org](https://stats.zooniverse.org) Response Example:


## Querying Classification Counts By User Group


### What Are User Groups?

As a new feature of our stats service, we introduce the idea of user groups so that a group of volunteers can set shared goals and celebrate milestones. Whether it’s a classroom, after school club, a group of friends, or corporate volunteering program, this new group feature provides new avenues for fostering community and collaboration for our volunteers and contributors.

For more documentation on user groups within our stats service, you can view our documentation: here (https://github.com/zooniverse/eras/wiki/API-Callout-Examples#classificationsuser_groupsid)

Our stats API allows querying for a user group’s classification stats as long as the person querying has proper authorizations to access the group statistics. _In other words, querying classification counts by user group requires an authentication token to be supplied. _

This authentication token is known as a bearer token and is usually supplied as a HTTP `Authorization` header with the value prefixed by `Bearer` and then the token data.


---

You can query user group classification counts filtering by any of the following:



* project_id/s
* can search by multiple project_ids when entering a `,` separated string of ids
* eg. `?project_id=1,2,3,4`
* workflow_id/s
* can search by multiple workflow_ids when entering a `,` separated string of ids
* eg. `?workflow_id=1,2,3,4`
* Start_date
* Date Format must be in `YYYY-MM-DD`
* End_date
* Date Format must be in `YYYY-MM-DD`
* Period
* If this is a parameter, the response will include a `data` key which shows the breakdown of classification counts bucketed by your entered period.
* Allowable buckets are either:
* `day`
* `week`
* `month`
* `year`
* top_contributors (integer)
* Limit that dictates whether your response will show top contributors of the user group
* individual_stats_breakdown (true/false)
* Boolean that dictates whether your response will shows show a roster stats report per each individual member for the user group


### Example: Query User Group Classification Counts

If you were interested in the user group with user_group id=1234’s classification counts of all time. You will need your user_group_id and run the following:

Response:

The response for querying user group classification counts will look a bit different than the other queries from the previous examples. By default, querying user group classification counts will return the following:



* Total_count
* Integer
* The total count of classifications of queried user group
* Time_spent
* Float
* Total session time IN SECONDS of total classifications of user group
* Active_users
* Integer
* Total active users of the user group
* Active users being users who have made a classification given request parameters
* Project_contributions
* List
* List of all project contributions (project_id and count) of user group given request parameters
* NOTE: if `project_id` or `workflow_id` is a parameter in your request, the response will NOT include this list
* data
* Only returned when `period` is a request parameter
* This shows the total breakdown of classifications of the user group bucketed by `period` that make up the response’s `total_count`


### Example: Query User Group’s Group Member Stats Breakdown

If you were interested in the user group with user_group id=1234’s group member stats breakdown of all time, we can utilize the `?individual_stats_breakdown=true` parameter and request the following:

Response:

Note that in this particular response, it returns a list of each group member’s project contributions, session time and classification count, ordered by top total classification count of members in the group.


## Examples in Other Languages


### Python


### Javascript

The following example is an authenticated callout to `/users` where `user_id=1234`
Loading

0 comments on commit 6e65ccd

Please sign in to comment.