Skip to content

Commit

Permalink
Remove cURL examples, finish basic usage examples
Browse files Browse the repository at this point in the history
  • Loading branch information
campb303 committed Apr 2, 2021
1 parent f52d74f commit 858dd3b
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions docs/api/Getting Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,41 @@

The webqueue2 API is organized around [REST](https://en.wikipedia.org/wiki/Representational_state_transfer). The API has resource oriented URLs, accepts and returns JSON encoded request bodies, can be modified via the query string and uses standard HTTP response codes and verbs.

You can use the webqueue2 API hosted at `{{ production_url }}/api` or [install it on your own machine](Installation.md).

## Basic Usage

!!! example "Get the number of Items in a Queue"
=== "fetch"
```javascript
()();
```
!!! example "Get the first item in CE queue."
```javascript
let access_token = "{{ example_access_token }}";
let queue = "ce";

=== "cURL"
```bash
curl -K
```
fetch(
`https://engineering.purdue.edu/webqueue/webqueue2/build/api/data/${queue}`,
{ headers: {"Authorization":`Bearer ${access_token}` }}
)
.then( resp => resp.json() )
.then( data => console.log( data[0].items[0] ));
```
```js
// Expected Output
{ queue: "ce", number: 17, lastUpdated: "2021-03-29T17:12:00-0400" ... }
```

!!! example "Get the subject of an Item"
=== "fetch"
```javascript
console.log
```
!!! example "Get the subject of an CE 1."
```javascript
let access_token = "{{ example_access_token }}";
let queue = "ce";
let item_number = 1;

=== "cURL"
```bash
curl -K
```
fetch(
`https://engineering.purdue.edu/webqueue/webqueue2/build/api/data/${queue}/${item_number}`,
{ headers: {"Authorization":`Bearer ${access_token}` }}
)
.then( resp => resp.json() )
.then( data => console.log( data.subject ));
```
```js
// Expected Output
"Linux Server Purchase"
```

0 comments on commit 858dd3b

Please sign in to comment.