CRUD Models
All models represented in Brigadehub are accessible via REST API (Built on mortimer, GraphQL API is on the roadmap).
Models
The models that are represented in the Core API are as follows:
Model | Endpoint slug | Use |
---|---|---|
Brigade |
brigade |
The brigadehub instance's brigade-specific configuration and profile information |
Users |
users |
A list of each user, their profile information, and associated jwt keys (scrubbed when accessing via API) |
Projects |
projects |
A list of each project in the brigade, their profile information, contact/contributor information and code location |
Events |
events |
A list of upcoming events for the brigade, the contact and venue information |
Posts |
posts |
A list of blog posts for the brigade, markdown formatted, along with metadata |
Checkins |
checkins |
An audit log of event check-ins, for monitoring event turnout |
Endpoint formatting
These endpoints are formatted as follows:
yourbrigade.org/api/:model[/:id]
where :model
represents the corresponding endpoint slug for the model, and :id
represents a specific document's mongo ID.
Pagination
By default, only 10 results are returned on a list call. To change the pagination settings, use one of the following parameters:
Parameter | Effect | Example |
---|---|---|
_limit |
number per page (default 10 ) |
_limit=50 |
_skip |
number of pages to skip (default 0 ) |
_skip=3 |
_limit=1
Filtering
Parameter | Effect | Example |
---|---|---|
_fields |
only return the specified fields (defaults to returning whole document) | _fields=profile.name |
_sort |
Sort the results by the field specified, reverse the sort with `- |
_sort=profile.name ,_sort=-profile.name |
<field>__<operator> |
a general field filter, where <field> is the field within the document (e.g. lastLogin ), and <operator> is an operator on the field (available operators are listed below) |
lastLogin__gt=1485227510000 |
Available operators
Operator | Effect | Example | |
---|---|---|---|
eq |
Exact Equal | projects?name__eq=Adopt-a-Drain |
|
ne |
Not Equal | projects?name__ne=TrustOSS |
|
lt |
Less Than | users?createdAt__lt=1485227510000 |
|
gt |
Greater Than | users?createdAt__gt=1485227510000 |
|
lte |
Less Than or Equal to | users?createdAt__lte=1485227510000 |
|
gte |
Greater Than or Equal to | users?createdAt__gte=1485227510000 |
|
regex |
Regex match | ||
in |
Field equals any in comma-delineated string | projects?name__in=Adopt-a-Drain,TrustOSS,WeVote |
Response
Usage examples
Read
List
To return a list of documents for any of the above models, omit the [/:id]
from the request:
Method | Example Endpoint | Results |
---|---|---|
GET |
yourbrigade.org/api/projects |
{} |
GET |
yourbrigade.org/api/users |
{} |