Skip to content

jie-chen/mom

Repository files navigation

Luminate Music API Python Client

A Python client library for interacting with the Luminate Music API. This client handles authentication and provides convenient methods for making API requests.

Features

  • Automatic authentication and token management
  • Support for all HTTP methods (GET, POST, PUT, DELETE)
  • Token auto-refresh when expired
  • Simple and intuitive API
  • Type hints for better IDE support
  • Comprehensive error handling

Installation

  1. Clone this repository or download the source code

  2. Install dependencies:

pip install -r requirements.txt

Configuration

  1. Copy the .env.example file to .env:
cp .env.example .env
  1. Edit .env and add your Luminate API credentials:
LUMINATE_API_KEY=your_api_key_here
LUMINATE_USERNAME=your_username_here
LUMINATE_PASSWORD=your_password_here

Getting API Credentials

To obtain API credentials for the Luminate Music API:

  1. Contact [email protected] to request API access
  2. Once approved, you'll receive:
    • API Key
    • Username
    • Password

Usage

Basic Example

from luminate_client import LuminateClient, LuminateAPIError
import os
from dotenv import load_dotenv

# Load environment variables
load_dotenv()

# Initialize the client
client = LuminateClient(
    api_key=os.getenv("LUMINATE_API_KEY"),
    username=os.getenv("LUMINATE_USERNAME"),
    password=os.getenv("LUMINATE_PASSWORD")
)

try:
    # The client will automatically authenticate on the first request
    response = client.get('/your/endpoint', params={'key': 'value'})
    print(response)

except LuminateAPIError as e:
    print(f"API Error: {e}")

Making API Requests

GET Request

# Simple GET request
response = client.get('/endpoint')

# GET request with query parameters
response = client.get('/endpoint', params={
    'param1': 'value1',
    'param2': 'value2'
})

POST Request

response = client.post('/endpoint', data={
    'key1': 'value1',
    'key2': 'value2'
})

PUT Request

response = client.put('/endpoint', data={
    'key1': 'updated_value'
})

DELETE Request

response = client.delete('/endpoint')

Manual Authentication

While the client automatically authenticates when needed, you can manually authenticate:

token = client.authenticate()
print(f"Authentication token: {token}")

Running Examples

Run the basic usage example:

python examples/basic_usage.py

Project Structure

.
├── luminate_client/
│   ├── __init__.py          # Package initialization
│   └── client.py            # Main client class
├── examples/
│   └── basic_usage.py       # Basic usage example
├── requirements.txt         # Project dependencies
├── .env.example            # Example environment variables
└── README.md               # This file

API Reference

LuminateClient

__init__(api_key, username, password, base_url='https://api.luminatedata.com')

Initialize the Luminate API client.

Parameters:

  • api_key (str): Your Luminate API key
  • username (str): Your Luminate username
  • password (str): Your Luminate password
  • base_url (str, optional): Base URL for the API

authenticate() -> str

Manually authenticate with the API and obtain an access token.

Returns: Authentication token string

Raises: LuminateAPIError if authentication fails

get(endpoint, params=None) -> dict

Make a GET request to the API.

Parameters:

  • endpoint (str): The API endpoint path
  • params (dict, optional): Query parameters

Returns: JSON response as dictionary

post(endpoint, data=None) -> dict

Make a POST request to the API.

Parameters:

  • endpoint (str): The API endpoint path
  • data (dict, optional): Request body data

Returns: JSON response as dictionary

put(endpoint, data=None) -> dict

Make a PUT request to the API.

Parameters:

  • endpoint (str): The API endpoint path
  • data (dict, optional): Request body data

Returns: JSON response as dictionary

delete(endpoint) -> dict

Make a DELETE request to the API.

Parameters:

  • endpoint (str): The API endpoint path

Returns: JSON response as dictionary

Error Handling

The client raises LuminateAPIError for API-related errors:

from luminate_client import LuminateAPIError

try:
    response = client.get('/endpoint')
except LuminateAPIError as e:
    print(f"An error occurred: {e}")

Requirements

  • Python 3.7+
  • requests >= 2.31.0
  • python-dotenv >= 1.0.0

Resources

Support

For API access or authentication issues, contact [email protected]

License

This project is provided as-is for use with the Luminate Music API.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages