Skip to content

sebastijan94/Sebastijan-SDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Lord of the Rings SDK

A Python SDK for accessing the Lord of the Rings API, allowing developers to easily fetch movie and quote information from the API.

Features

  • Fetch movie details by ID
  • Fetch quotes by ID
  • Fetch all movies with optional pagination
  • Fetch all quotes with optional pagination
  • Fetch quotes associated with a specific movie

Installation

  1. Ensure you are using Python version >= 3.9

  2. Install the SDK:

    pip install git+https://github.com/sebastijan94/Sebastijan-SDK.git

Usage

Here is a quick example of how to use the SDK:

from lotr_sdk.client import Client

# Initialize the client with your API key
client = Client(api_key="your_api_key_here")

# Fetch a movie by ID
movie = client.get_movie_by_id("5cd95395de30eff6ebccde5b")
print(f"Movie Name: {movie.name}")

# Fetch all movies with pagination
movies = client.get_all_movies(limit=5, page=1)
print(f"Total Movies: {len(movies)}")

# Fetch quotes for a specific movie
quotes = client.get_movie_quotes("5cd95395de30eff6ebccde5b", limit=5)
for quote in quotes:
    print(f"Quote: {quote.dialog}")

Methods

  • get_movie_by_id(movie_id: str)
  • get_all_movies(limit: int = 100, page: int = None, offset: int = None)
  • get_quote_by_id(quote_id: str)
  • get_all_quotes(limit: int = 100, page: int = None, offset: int = None)
  • get_movie_quotes(movie_id: str, limit: int = 100, page: int = None, offset: int = None)
  • get_movie_with_quotes(movie_id: str, limit: int = 100, page: int = None, offset: int = None)

Error Handling

The SDK raises exceptions for various error scenarios:

  • NotFoundError: Raised when a requested resource is not found.
  • AuthenticationError: Raised when the API key is invalid.
  • SDKError: For general errors related to the API call. (This error will be raised also for invalid IDs, that is how API currently works)

Testing

  1. Ensure you are using Python version >= 3.9

  2. Clone the repository:

    git clone https://github.com/sebastijan94/Sebastijan-SDK.git
    cd Sebastijan-SDK
  3. Install the required dependencies:

    pip install -r requirements.txt
  4. Create a .env file in the root directory and add your API key:

    LOTR_API_KEY=api_key
    
  5. Run:

    pytest tests/test_sdk.py

About

The Lord of the Rings SDK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages