musixmatch.api.Request Class Reference
Inheritance diagram for musixmatch.api.Request:
Inheritance graph
Collaboration diagram for musixmatch.api.Request:
Collaboration graph

Public Member Functions

def __init__ (self, api_method, query=(), keywords)
 
def api_method (self)
 
def query_string (self)
 
def response (self)
 
def __repr__ (self)
 
def __str__ (self)
 
def __hash__ (self)
 
def __cmp__ (self, other)
 
def __init__ (self, api_method, query=(), keywords)
 
def api_method (self)
 
def query_string (self)
 
def response (self)
 
def __repr__ (self)
 
def __str__ (self)
 
def __hash__ (self)
 
def __cmp__ (self, other)
 
def __init__ (self, api_method, query=(), keywords)
 
def api_method (self)
 
def query_string (self)
 
def response (self)
 
def __repr__ (self)
 
def __str__ (self)
 
def __hash__ (self)
 
def __cmp__ (self, other)
 
def __init__ (self, api_method, query=(), keywords)
 
def api_method (self)
 
def query_string (self)
 
def response (self)
 
def __repr__ (self)
 
def __str__ (self)
 
def __hash__ (self)
 
def __cmp__ (self, other)
 

Private Member Functions

def _received (self)
 
def _received (self)
 
def _received (self)
 
def _received (self)
 

Private Attributes

 __api_method
 
 __query_string
 
 __response
 

Detailed Description

This is the main API class. Given a :py:class:`Method` or a method name, a
:py:class:`QueryString` or a :py:class:`dict`, it can build the API query
URL, run the request and return the response either as a string or as a
:py:class:`ResponseMessage` subclass. Assuming the default web services
location, this class try to build a proper request:

>>> from musixmatch.api import Request, Method, QueryString
>>> method_name = 'artist.chart.get'
>>> method = Method(method_name)
>>> keywords = { 'country': 'it', 'page': 1, 'page_size': 3 }
>>> query_string = QueryString(keywords)
>>> 
>>> r1 = Request(method_name, keywords)
>>> r2 = Request(method_name, **keywords)
>>> r3 = Request(method_name, query_string)
>>> r4 = Request(method, keywords)
>>> r5 = Request(method, **keywords)
>>> r6 = Request(method, query_string)

If **method** is string, try to cast it into a :py:class:`Method`. If
**query_string** is a :py:class:`dict`, try to cast it into a
:py:class:`QueryString`. If **query_string** is not specified, try to
use **keywords** arguments as a :py:class:`dict` and cast it into a
:py:class:`QueryString`.

Turning the :py:class:`Request` into a :py:class:`str` returns the URL
representing the API request:

>>> str(Request('artist.chart.get', { 'country': 'it', 'page': 1 }))
'http://api.musixmatch.com/ws/1.1/artist.chart.get?country=it&page=1'

Definition at line 293 of file musixmatch-master/build/lib/musixmatch/api.py.

Constructor & Destructor Documentation

def musixmatch.api.Request.__init__ (   self,
  api_method,
  query = (),
  keywords 
)
def musixmatch.api.Request.__init__ (   self,
  api_method,
  query = (),
  keywords 
)

Definition at line 326 of file musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request.__init__ (   self,
  api_method,
  query = (),
  keywords 
)
def musixmatch.api.Request.__init__ (   self,
  api_method,
  query = (),
  keywords 
)

Definition at line 326 of file Yading/musixmatch-master/musixmatch/api.py.

Member Function Documentation

def musixmatch.api.Request.__cmp__ (   self,
  other 
)
def musixmatch.api.Request.__cmp__ (   self,
  other 
)

Definition at line 388 of file musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request.__cmp__ (   self,
  other 
)

Definition at line 388 of file Yading/musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request.__cmp__ (   self,
  other 
)
def musixmatch.api.Request.__hash__ (   self)
def musixmatch.api.Request.__hash__ (   self)
def musixmatch.api.Request.__hash__ (   self)

Definition at line 385 of file musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request.__hash__ (   self)

Definition at line 385 of file Yading/musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request.__repr__ (   self)
def musixmatch.api.Request.__repr__ (   self)

Definition at line 375 of file musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request.__repr__ (   self)

Definition at line 375 of file Yading/musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request.__repr__ (   self)
def musixmatch.api.Request.__str__ (   self)
def musixmatch.api.Request.__str__ (   self)

Definition at line 378 of file musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request.__str__ (   self)
def musixmatch.api.Request.__str__ (   self)

Definition at line 378 of file Yading/musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request._received (   self)
private
A context manager to handle url opening

Definition at line 345 of file musixmatch-master/build/lib/musixmatch/api.py.

Referenced by musixmatch.api.Request._received(), and musixmatch.api.Request.response().

def musixmatch.api.Request._received (   self)
private
A context manager to handle url opening

Definition at line 345 of file Yading/musixmatch-master/build/lib/musixmatch/api.py.

def musixmatch.api.Request._received (   self)
private
A context manager to handle url opening

Definition at line 345 of file musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request._received (   self)
private
A context manager to handle url opening

Definition at line 345 of file Yading/musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request.api_method (   self)
The :py:class:`Method` instance.

Definition at line 335 of file Yading/musixmatch-master/build/lib/musixmatch/api.py.

def musixmatch.api.Request.api_method (   self)
The :py:class:`Method` instance.

Definition at line 335 of file musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request.api_method (   self)
The :py:class:`Method` instance.

Definition at line 335 of file Yading/musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request.api_method (   self)
def musixmatch.api.Request.query_string (   self)
def musixmatch.api.Request.query_string (   self)
The :py:class:`QueryString` instance.

Definition at line 340 of file Yading/musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request.query_string (   self)
The :py:class:`QueryString` instance.

Definition at line 340 of file musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request.query_string (   self)
The :py:class:`QueryString` instance.

Definition at line 340 of file Yading/musixmatch-master/build/lib/musixmatch/api.py.

def musixmatch.api.Request.response (   self)
The :py:class:`ResponseMessage` based on the **format** key in the
:py:class:`QueryString`.

Definition at line 354 of file Yading/musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request.response (   self)
The :py:class:`ResponseMessage` based on the **format** key in the
:py:class:`QueryString`.

Definition at line 354 of file musixmatch-master/musixmatch/api.py.

def musixmatch.api.Request.response (   self)
The :py:class:`ResponseMessage` based on the **format** key in the
:py:class:`QueryString`.

Definition at line 354 of file Yading/musixmatch-master/build/lib/musixmatch/api.py.

def musixmatch.api.Request.response (   self)
The :py:class:`ResponseMessage` based on the **format** key in the
:py:class:`QueryString`.

Definition at line 354 of file musixmatch-master/build/lib/musixmatch/api.py.

Referenced by musixmatch.api.Request.response().

Field Documentation

musixmatch.api.Request.__api_method
private
musixmatch.api.Request.__query_string
private
musixmatch.api.Request.__response
private

The documentation for this class was generated from the following file: