Skip to content

MovieHut is a free and open-source, Node.js, "random movie suggestion" REST API.

License

Notifications You must be signed in to change notification settings

k2maan/moviehut-random-movie-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎞 MovieHut - Random Movie API

moviehut-wide

MovieHut is a free and open source, Node.js REST API, a mini-project I did for fun really. It has three endpoints : /random, /movie/:name, and /movies, all explained below.

📌 Index

Server and deployment

Deployed on Heroku (Previously on EC2)

Deployed on MongoDB Atlas, the database includs top 1000 rated movies from IMDb.

The API is accessible here. See the docs for further examples of usage on other endpoints.

API Documentation

Random movie

GET /api/random

Example Response

{
    "_id": "6062ff36dd0c731bbd383d16",
    "name": "12 Angry Men",
    "releaseYear": 1957,
    "certificate": "U",
    "runtime": "96 min",
    "genre": "Crime, Drama",
    "imdbRating": 9,
    "overview": "A jury holdout attempts to prevent a miscarriage of justice by forcing his colleagues to reconsider the evidence.",
    "metaScore": "96",
    "director": "Sidney Lumet"
}

Movie by name

GET /api/movie/:name

Example Response

{
    "_id": "6062ff36dd0c731bbd383d1b",
    "name": "Fight Club",
    "releaseYear": 1999,
    "certificate": "A",
    "runtime": "139 min",
    "genre": "Drama",
    "imdbRating": 8.8,
    "overview": "An insomniac office worker and a devil-may-care soapmaker form an underground fight club that evolves into something much, much more.",
    "metaScore": "66",
    "director": "David Fincher"
}

List of movies sorted by IMDb Rating

GET /api/movies

Query parameters

Parameter Type Description Example
limit Number Minimum: 1, Maximum: 100, Default: 10
The number of movies to fetch at once per page
See in browser
page Number Minimum: 1, Maximum: 100, Default: 1
The page no. for the results
See in browser
select String Fetch only the selected/particular feilds for the movie. Must be comma seperated (see example) See in browser

Example Response

The data array containes 5 (the limit we give) objects...

{
    "status": true,
    "pagination": {
        "next": {
            "page": 6,
            "limit": 5
        },
        "prev": {
            "page": 4,
            "limit": 5
        }
    },
    "data": [{}, {}, {}, {}, {}]
}

Local setup

Requirements

Make sure you are atleast using the following versions:

  • Node: 14.5.5
  • npm: 6.14.11
  • MongoDB: 4.4.2

Database and Environment variables

  • Create a MongoDB database locally or on Atlas

  • Seed the db using mongoimport (or some other way your prefer)

  • Create a file named config.env in the config folder. Add the following variables with your parameters:

NODE_ENV=<your-enviroment>

PORT=<port>

MONGO_URI=<your-local-or-atlas-mongodb-uri>

Installing dependencies and starting the server

  • Do the good old:
npm i && nodemon server

Contributing

All contributions, from code to docs' improvement are more than welcome. To do so you can:

  • Fork the repo

  • Clone the forked repo on your local machine

  • Create a new branch from master

  • Do your thing and commit your changes

  • Push the changes to your fork

  • Add a pull request on the project and wait until we review and merge them

About

MovieHut is a free and open-source, Node.js, "random movie suggestion" REST API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published