Your goal is to build a API about yourself. Your API will incorporate:
- some basic details about you
/apiendpoints that return JSON- RESTful Routing (GET, POST, UPDATE, DELETE)
- CRUDing (of at least one resource)
Please fork & clone this repo to get started.
Before we start coding, our first goal together is to configure our application so that it can be deployed to Heroku (a web application host).
Follow the instructions here: Deploying Express Apps to Heroku
As you continue to work on this project, you'll need to remember to push your changes to heroku (just like you would with github!):
# git add . -A
# git commit -m "detailed description of what I changed"
git push heroku master
heroku openIt's common for code to break "in production" (broken links, different environment, missing dependenies...), so do your best to debug!
Now that we're deployed, it's time to start coding your "personal" api!
- Documentation: You must create a README.md file that specifies what endpoints are available on your API, what your endpoints expect from the request (verb + route + data), and what they will respond with (structure of JSON). We really want to know how to use your API! And we highly recommend that you do this first!
- A profile endpoint (
/api/profile) that responds with:name- a stringgithub_link- a url to your github profilegithub_profile_image- the url of your github profile imagecurrent_cityfamily_members- an array of family member objects- e.g.
[{name: "foo", relationship: "father"}, {name: "bar", relationship: "mother"}]
- e.g.
- At least one resource that you can CRUD using RESTful Routes
- That means endpoints for
index,show,createupdate,delete! - Here are some ideas:
- Wish list (e.g.
giftsorwishes)- _id, description, price, amazon_link
booksyou've read- _id, title, author, genre, notes
quotesyou like, ortweets- _id, text, date, author
moviesorshowsyou like- _id, title, season, director
projectsorpoems- _id, title, body, date
- Wish list (e.g.
- That means endpoints for
All API Endpoints must return JSON.
- Profile info stretch goals
- Add a
days_oldfield that calculates how many days old you are. - Add an
is_awakefield that's onlytruebetween 8am and 10pm! - Add an
is_hungryfield that's onlytruearound lunch and dinner!
- Add a
- CRUD resource stretch goals
- Use query parameters to filter results from one of your CRUD endpoints:
- e.g.
?limit=2only return two results
- e.g.
- Create a
/searchendpoint- e.g.
?q=mad+menonly returns tv shows with that in the title - e.g.
?type=romanceonly returns romance novels
- e.g.
- Use query parameters to filter results from one of your CRUD endpoints:
An example API for 'Jon Snow' might have endpoints like:
JSON API Endpoint Response JSON
============= =============
GET /api/profile {
name: "Jon Snow",
github_link: "http://github.com/u-know-nothing-jon-snow",
current_city: "The Wall",
is_awake: false,
family_members: [ { name: 'Arya Stark', relationship: 'sister' }, { name: 'Bran Stark', relationship: 'brother' }]
}
GET /api/projects [
{
_id: 2,
name: 'Defeat the wildlings',
type: 'quest',
opponents: [ 'Mance Rayder', 'Lord of Bones'],
status: 'resolved'
},
{
_id: 3,
name: 'Save the wildlings',
type: 'campaign',
opponents: ['the Night Watch', 'the Others'],
status: 'pending'
}
]
GET /api/projects?limit=1 [ { _id: 2, name:'Defeat...' } ]
GET /api/projects?status=pending
[ { _id: 3, name:'Save...' } ]
GET /api/projects/2 { _id: 2, name:'Defeat...' }
POST /api/projects etc
PUT /api/projects/2 etc
DELETE /api/projects/2 etc
Consume the Personal API you just created, and use it to build your own personal dashboard.
- Create an
index.htmlhomepage that's linked to your main javascript and css files. - Use jQuery and AJAX to consume your Personal API.
- Display at least one image/gif that you retrieved from your Personal API.
- Create at least one form, so you can CRUD at least one of your resources.
- Make your momma proud.
- What's the
current_weatherlike in yourcurrent_city? Use this Weather API. You can decide whether you want to do a front-end (client-side) integration, or a back-end (server-side) integration with the API. - Add a
most_recent_tweetor amost_recent_instagramfield and consume the [Twitter API] or the [Instagram API] on the server side (hint, you'll need to use the Request library). - Embed your favorite youtube videos or soundcloud/spotify tracks.
##Recommended File Structure
A good express file tree structure:
├── server.js // your server code
├── package.json // lists dependencies; changed by npm install --save somePackage
├── public // i.e. client-side
│ ├── images // images to serve to client
│ ├── javascripts
│ │ └── app.js // client-side javascript file
│ └── stylesheets
│ └── style.css
├── vendor // includes jQuery & bootstrap if we choose not to use CDN
├── views // html files that we'll serve
│ ├── index.html
