GoIMDb API is a simple API for storing and retrieving movie data. The API is built using Go and Echo.
- Go 1.16 or later
- Echo v4
- RamSQL
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
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:
Returns a list of all movies or all movies from a specific year if the year
query parameter is provided.
Parameter | Description | Required |
---|---|---|
year |
The year for which to return movies | No |
GET /movies?year=2020
[
{
"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
}
]
Returns a specific movie.
Parameter | Description | Required |
---|---|---|
imdbID |
The IMDb ID of the movie | Yes |
GET /movies/tt0816692
{
"id": 1,
"imdbID": "tt0816692",
"title": "Interstellar",
"year": 2014,
"rating": 8.6,
"isSuperHero": false
}
Creates a new movie.
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 |
POST /movies
Content-Type: application/json
{
"imdbID": "tt0816692",
"title": "Interstellar",
"year": 2014,
"rating": 8.6,
"isSuperHero": false
}
{
"id": 1,
"imdbID": "tt0816692",
"title": "Interstellar",
"year": 2014,
"rating": 8.6,
"isSuperHero": false
}
Updates a specific movie's rating.