GithubHelp home page GithubHelp logo

muvis-api's Introduction

Muvis API

This API is an excercise to put in practice the REST concepts and create an app with Express in Node. In first place, the server consumes The Movie DB API to generate a new database of movies. Then, the app expose some endpoints to make CRUD operations with the data.

Use of the project

The API can be use at this URL: https://muvis-api.herokuapp.com/api/

To install it in your own server, you have to clone this repository:

git clone https://github.com/livchits/muvis-api.git

Go to the project's directory and install the dependencies:

cd muvis-api
npm install

Create an .env file and edit it like this:

HOSTNAME=localhost
PORT=3000
API_KEY=YOUR_API_KEY
TOP_RATED_URL=https://api.themoviedb.org/3/movie/top_rated?api_key=
GENRES_URL=https://api.themoviedb.org/3/genre/movie/list?api_key=

Don't forget to replace the API_KEY value with your key. To get one in The Movie DB site you have to create an account there.

Finally run:

npm run start

Now you can access the API at localhost:3000/api

Endpoints

Method Endpoint Usage Returns
GET /api/muvis 100 movies in json format Movies
POST /api/muvis Adds a new movie and returns the added movie. They payload must be in json format Movie
GET /api/muvis/:id Get a movie Movie
PUT /api/muvis/:id Modify a movie with specified ID Movie
DELETE /api/muvis/:id Delete a movie with specified ID Movies
GET /api/muvis/years Get the list of movie's years Years
GET /api/muvis/rates Get the list of movie's rates Rates
GET /api/muvis/genres Get the list of movie's genres Genres

Query strings

Method Endpoint Query string Usage
GET /api/muvis ?year=1972 Get the list of movies released that year
GET /api/muvis ?genre=drama Get the list of movies with requested genre
GET /api/muvis ?sortBy=title Get the movies sorted by title in ascending order
GET /api/muvis ?sortBy=year Get the movies sorted by year in ascending order
GET /api/muvis ?sortBy=rate Get the movies sorted by rate in ascending order

Movie example

{
  "title": "The Godfather",
  "date": "March 14, 1972",
  "overview": "Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American Corleone crime family. When organized crime family patriarch, Vito Corleone barely survives an attempt on his life, his youngest son, Michael steps in to take care of the would-be killers, launching a campaign of bloody revenge.",
  "rate": 8.7,
  "genres": ["Crime", "Drama"],
  "poster": "https://image.tmdb.org/t/p/w1280/iVZ3JAcAjmguGPnRNfWFOtLHOuY.jpg",
  "backdrop": "https://image.tmdb.org/t/p/w1280/ejdD20cdHNFAYAN2DlqPToXKyzx.jpg",
  "id": 238
}

Accepted JSON object for PUT and POST requests:

{
  "title": "Pulp Fiction",
  "date": "September 10, 1994",
  "overview": "A burger-loving hit man, his philosophical partner, a drug-addled gangster's moll and a washed-up boxer converge in this sprawling, comedic crime caper. Their adventures unfurl in three stories that ingeniously trip back and forth in time.",
  "rate": 8.5,
  "genres": ["Crime", "Thriller"],
  "poster": "https://image.tmdb.org/t/p/w1280/yAaf4ybTENKPicqzsAoW6Emxrag.jpg",
  "backdrop": "https://image.tmdb.org/t/p/w1280/eDMZmfnH50DDboUxTRnOYYpE9aY.jpg"
}

Used technologies

  • NodeJS
  • Express
  • LowDB
  • Express Validator
  • Ajv Validator

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.