An API which serves official presidential remarks one paragraph at a time.
Authorized users have the ability to POST
PATCH
DELETE
and are validated via Jason Web Tokens.
This project was made using Node, Express, Knex and PostgreSQL.
The testing utilizes Chai and Mocha.
The source of the data for the project is whitehouse.gov specifically the remarks section.
Visit the url above and login if you are an authorized user in order to receive a JWT granting POST
PATCH
DELETE
permissions.
A GET
to this endpoint returns and array of all remarks.
Remarks objects have id
title
topic
date
timestamp
properties.
The paragraphs corresponding to a particular remark_id
are found under the paragraphs endpoint.
[
{
"id": 1,
"title": "The Title",
"topic": "TOPIC ONE",
"date": "2/12/2018",
"created_at": "2018-03-30T05:36:53.234Z",
"updated_at": "2018-03-30T05:36:53.234Z"
},
{
"id": 2,
"title": "Another Title",
"topic": "TOPIC TWO",
"date": "2/14/2018",
"created_at": "2018-03-30T05:36:53.234Z",
"updated_at": "2018-03-30T05:36:53.234Z"
}
]
Pass in the id number of the remark in the place of :id
.
A GET
to this endpoint returns a specific remark.
[
{
"id": 1,
"title": "The Title",
"topic": "TOPIC ONE",
"date": "2/12/2018",
"created_at": "2018-03-30T05:36:53.234Z",
"updated_at": "2018-03-30T05:36:53.234Z"
}
]
Pass in the name of the topic your are searching for in place of TOPIC%20ONE
in the example above
A GET
will return the remark with the topic of your query if it exist in the database.
[
{
"id": 1,
"title": "The Title",
"topic": "TOPIC ONE",
"date": "2/12/2018",
"created_at": "2018-03-29T22:45:54.710Z",
"updated_at": "2018-03-29T22:45:54.710Z"
}
]
A GET
to this endpoint returns and array of all the remarks.
Paragraph objects have id
length
text
remarks_id
created_at
updated_at
properties.
[
{
"id": 1,
"length": "long",
"text": "Well, thank you everybody. This has been long in the making. You’ve heard many, many speeches by me and talks by me, and interviews where I talk about unfair trade practices. We’ve lost, over a fairly short period of time, 60,000 factories in our country — closed, shuttered, gone. Six million jobs, at least, gone. And now they’re starting to come back. You see what’s happening with Chrysler, with Foxconn, with so many other companies wanting to come back into the United States.",
"remarks_id": 1,
"created_at": "2018-03-30T05:36:53.242Z",
"updated_at": "2018-03-30T05:36:53.242Z"
},
{
"id": 2,
"length": "short",
"text": "But we have one particular problem. And I view them as a friend; I have tremendous respect for President Xi.",
"remarks_id": 1,
"created_at": "2018-03-30T05:36:53.242Z",
"updated_at": "2018-03-30T05:36:53.242Z"
},
{
"id": 3,
"length": "short",
"text": "We have a great relationship. They’re helping us a lot in North Korea. And that’s China.",
"remarks_id": 1,
"created_at": "2018-03-30T05:36:53.242Z",
"updated_at": "2018-03-30T05:36:53.242Z"
},
... continued
Pass in the id number of the paragraph in the place of :id.
A GET
to this endpoint returns a specific paragraph.
[
{
"id": 24,
"length": "medium",
"text": "We buy billions and billions of dollars’ worth of that beautiful F-35. It’s stealth. You cannot see it. Is that correct?",
"remarks_id": 1,
"created_at": "2018-03-30T05:36:53.242Z",
"updated_at": "2018-03-30T05:36:53.242Z"
}
]
POST
request to this endpoint require title
topic
date
token
parameters in the body.
{
title: 'Another Title',
topic: 'TOPIC TWO',
date: '02/28/2018',
token: "eyMhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBOYW1lIjoibXlBcHAiLCJlbWFpbCI6ImFkbWluQHR1cmluZy5pcyIsImlhdCI6MTUyMjUaNDYwOH0.uu0hwZ-Lkv5v6XbMNOBxBwisAVZDXMW_tGnbjesMJWs"
}
The remark id is returned in the case of a successful POST
. Your response has been added to the database.
{
"id": 3
}
POST
request to this endpoint require length
text
remarks_id
token
parameters in the body.
{
"length": "short",
"text": "This is the first of many. This is number one, but this is the first of many.",
"remarks_id": "1",
"token": "eyMhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBOYW1lIjoibXlBcHAiLCJlbWFpbCI6ImFkbWluQHR1cmluZy5pcyIsImlhdCI6MTUyMjUaNDYwOH0.uu0hwZ-Lkv5v6XbMNOBxBwisAVZDXMW_tGnbjesMJWs"
}
The paragraph id is returned in the case of a successful POST
. Your response has been added to the database.
{
"id": 31
}
Pass in the id number of the remark in the place of :id
.
PATCH
request to this endpoint require title
topic
date
token
parameters in the body.
{
title: 'Another Title',
topic: 'TOPIC TWO',
date: '02/28/2018',
token: "eyMhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBOYW1lIjoibXlBcHAiLCJlbWFpbCI6ImFkbWluQHR1cmluZy5pcyIsImlhdCI6MTUyMjUaNDYwOH0.uu0hwZ-Lkv5v6XbMNOBxBwisAVZDXMW_tGnbjesMJWs"
}
The remark id returned in the case of successful PATCH
. Your remark has been updated in the database.
{
"remark": 1
}
Pass in the id number of the paragraph in the place of :id
.
POST
request to this endpoint require length
text
remarks_id
token
parameters in the body.
{
"length": "short",
"text": "This is the first of many. This is number one, but this is the first of many.",
"remarks_id": "1",
"token": "eyMhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBOYW1lIjoibXlBcHAiLCJlbWFpbCI6ImFkbWluQHR1cmluZy5pcyIsImlhdCI6MTUyMjUaNDYwOH0.uu0hwZ-Lkv5v6XbMNOBxBwisAVZDXMW_tGnbjesMJWs"
}
A status of 201The paragraph id returned in the case of successful PATCH
. Your remark has been updated in the database.
{
"paragraph": 1
}
Pass in the id number of the remark in the place of :id
.
DELETE
request to this endpoint require token
parameters in the body.
{
token: "eyMhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBOYW1lIjoibXlBcHAiLCJlbWFpbCI6ImFkbWluQHR1cmluZy5pcyIsImlhdCI6MTUyMjUaNDYwOH0.uu0hwZ-Lkv5v6XbMNOBxBwisAVZDXMW_tGnbjesMJWs"
}
CASCADE DELETE
is used in this database.
Removing a remark
will delete all paragraphs
corrisponding to the remark.
The remark id returned in the case of successful DELETE
. Your remark has been removed from the database.
{
"remark": 1
}
Pass in the id number of the paragraph in the place of :id
.
DELETE
request to this endpoint require token
parameters in the body.
{
token: "eyMhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBOYW1lIjoibXlBcHAiLCJlbWFpbCI6ImFkbWluQHR1cmluZy5pcyIsImlhdCI6MTUyMjUaNDYwOH0.uu0hwZ-Lkv5v6XbMNOBxBwisAVZDXMW_tGnbjesMJWs"
}
The remark id returned in the case of successful DELETE
. Your remark has been removed from the database.
{
"paragraph": 1
}