Coder Social home page Coder Social logo

goimdb's Introduction

GoIMDB API

GoIMDb API is a simple API for storing and retrieving movie data. The API is built using Go and Echo.

Requirements

  • Go 1.16 or later
  • Echo v4
  • RamSQL

Installation

Clone the repository:

git clone https://github.com/nattrio/GoIMDb.git

Install dependencies:

go get github.com/labstack/echo/v4
go get github.com/labstack/echo/v4/middleware
go get github.com/erikstmartin/go-testdb

Usage

Start the server:

go run main.go

or using Docker

docker build -t go-multi -f Dockerfile.multi .
docker run -d -p 2565:2565 --name go-multi go-multi

Use the following endpoints:

GET /movies

Returns a list of all movies or all movies from a specific year if the year query parameter is provided.

Query Parameters

Parameter Description Required
year The year for which to return movies No

Example Request

GET /movies?year=2020

Example Response

[
  {
    "id": 1,
    "imdbID": "tt0816692",
    "title": "Interstellar",
    "year": 2014,
    "rating": 8.6,
    "isSuperHero": false
  },
  {
    "id": 2,
    "imdbID": "tt1375666",
    "title": "Inception",
    "year": 2010,
    "rating": 8.8,
    "isSuperHero": false
  }
]

GET /movies/:imdbID

Returns a specific movie.

URL Parameters

Parameter Description Required
imdbID The IMDb ID of the movie Yes

Example Request

GET /movies/tt0816692

Example Response

{
  "id": 1,
  "imdbID": "tt0816692",
  "title": "Interstellar",
  "year": 2014,
  "rating": 8.6,
  "isSuperHero": false
}

POST /movies

Creates a new movie.

Request Body

Field Type Description
imdbID string The IMDb ID of the movie
title string The title of the movie
year int The year the movie was released
rating float32 The rating of the movie
isSuperHero bool Whether or not the movie is a superhero movie

Example Request

POST /movies
Content-Type: application/json

{
    "imdbID": "tt0816692",
    "title": "Interstellar",
    "year": 2014,
    "rating": 8.6,
    "isSuperHero": false
}

Example Response

{
  "id": 1,
  "imdbID": "tt0816692",
  "title": "Interstellar",
  "year": 2014,
  "rating": 8.6,
  "isSuperHero": false
}

PUT /movies/:imdbID

Updates a specific movie's rating.

goimdb's People

Contributors

nattrio avatar

Watchers

 avatar

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.