Skip to content

A Pinterest clone to save articles to boards and categorize them to read later.

License

Notifications You must be signed in to change notification settings

Build-Week-Pintereach1/backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pintereach API

https://pintereach1.herokuapp.com

Endpoints

Method Endpoint Description
POST /api/register Create user and return token
POST /api/login Authenticate user and return token
GET /api/validate Verify token
GET /api/articles Retrieve saved articles
GET /api/articles/:id Retrieve article by id
POST /api/articles/ Save article
PUT /api/articles/:id Edit saved article
DELETE /api/articles/:id Remove saved article
GET /api/categories Retrieve categories
POST /api/categories Add category
GET /api/categories/:id/articles Retrieve articles within a category
POST /api/categories/:id/articles Assign article to a category
DELETE /api/categories/:id/articles Remove article from a category
GET /api/boards/:id Retrieve board by id
POST /api/boards Add board

All routes

  • users only have access to their own resources
  • token in Authorization request header (required) - except /api/register, /api/login, and /api/validate

Questions

How do I post an article to a board?

Use the PUT /api/articles/:id endpoint to change an article's board_id property, which refers to the id of a given board. An article can only be posted to one board, but it may be assigned to more than one category.

POST /api/register

https://pintereach1.herokuapp.com/api/register

Create user and return token

  • username (required) - must be unique
  • password (required)
  • email (required) - must be unique

Body

{
    "username": "moo",
    "password": "cat",
    "email": "[email protected]"
}

POST /api/login

https://pintereach1.herokuapp.com/api/login

Authenticate user and return token

  • username (required)
  • password (required)

Body

{
    "username": "moo",
    "password": "cat"
}

GET /api/validate

https://pintereach1.herokuapp.com/api/validate

Verify token

Example Response

{
    "validToken": true,
    "message": "Valid token."
}

GET /api/articles

https://pintereach1.herokuapp.com/api/articles

Retrieve saved articles

Example Response

GET /api/articles/:id

https://pintereach1.herokuapp.com/api/articles/:id

Retrieve article by id

Example Response

{
    "id": 2,
    "url": "https://www.javascriptstuff.com/component-communication",
    "title": "8 no-Flux strategies for React component communication",
    "image": "https://www.javascriptstuff.com/static/parent-to-child-fc4c68730b003da3f9d20dd57cf52d20-8aa1a.png",
    "description": "Sending data between React components can seem like a pain at first. Here are some simple strategies.",
    "notes": null,
    "board_id": 1,
    "user_id": 1
}

POST /api/articles/:id

https://pintereach1.herokuapp.com/api/articles/:id

Save article

  • url (required)
  • title, image (image url), description - if unspecified in request body, Pintereach will attempt to populate these fields with values from LinkPreview API
  • notes
  • board_id
  • Returns saved articles

Example Response

PUT /api/articles/:id

https://pintereach1.herokuapp.com/api/articles/:id

Edit saved article

  • Returns updated article

Body

{
    "notes": "I better take notes on this!"
}

DELETE /api/articles

https://pintereach1.herokuapp.com/api/articles/:id

Remove saved article

  • Returns saved articles

GET /api/categories

https://pintereach1.herokuapp.com/api/categories

Retrieve categories

Example Response

POST /api/categories

https://pintereach1.herokuapp.com/api/categories

Add category

  • name (required)
  • Returns created category

Body

{
    "name": "JavaScript"
}

GET /api/categories/:id/articles

https://pintereach1.herokuapp.com/api/categories/:id/articles

Retrieve articles within a category

  • category id in route parameters (required)

Example Response

POST /api/categories/:id/articles

https://pintereach1.herokuapp.com/api/categories/:id/articles

Assign article to a category

  • category id in route parameters (required)
  • Returns articles within the given category

Body

{
   "article_id": "1"
}

DELETE /api/categories/:id/articles

https://pintereach1.herokuapp.com/api/categories/:id/articles/{?artid}

Remove article from a category

  • category id in route parameters (required)
  • article id as artid in query parameters (required)
  • Returns articles within the given category

Example Query String

https://pintereach1.herokuapp.com/api/categories/1/articles?artid=1

GET /api/boards/:id

https://pintereach1.herokuapp.com/api/boards/:id

Retrieve board by id

Example Response

POST /api/boards

https://pintereach1.herokuapp.com/api/boards

Add board

  • name (required)
  • description
  • private (boolean, default to false) - for features in a future release: ability to view other users' boards, make boards private
  • Returns created board

Example Response

{
    "id": 1,
    "name": "Full Stack Web",
    "description": "Learning front end and back end.",
    "private": false,
    "user_id": 1
}

About

A Pinterest clone to save articles to boards and categorize them to read later.

Resources

License

Stars

Watchers

Forks