This module provides access to the ColourLovers API, a web service that allows users to publish colour themes and rate them. The API of this webservice allows to search for users (Lovers) and their posted contents (Colours, Patterns, Palettes).
Accessing the API requires an instance of ColourLovers which provides the methods to access the different content types: Colour, Palette, Pattern, Lover. Sending a request to ColourLovers is as easy as calling the corresponding method such as ColourLovers.palettes() to search for palettes. Additionally, the following arguments can be specified new, top, random with additional parameters. Please refer to the ColourLovers API documentation to find out more about the specific parameters and their restrictions at http://www.colourlovers.com/api.
You find the ColourLovers website at: http://www.colourlovers.com
Usage example:
>>> from colourlovers import ColourLovers
>>> cl = ColourLovers()
>>> cl.color('#37cbff')
[<Colour id='4767129' title='i feel pretty' rgb=(55, 203, 255)>]
>>> cl.palettes('new', keywords='funky', numResults=3)
[<Palette id='1940972' title='"Funky President"'>,
<Palette id='1936394' title='Barbie Doll Blonde'>,
<Palette id='1936247' title='Lily's Rainbow'>]
Another example:
>>> cl.patterns('random')
[<Pattern id='391644' title='acanalado'>]
>>> cl.colors('top', numResults=3)
[<Colour id='14' title='Black' rgb=(0, 0, 0)>,
<Colour id='16' title='white' rgb=(255, 255, 255)>,
<Colour id='1086335' title='dutch teal' rgb=(22, 147, 165)>]
| lover | Restrict results to specific COLOURlover by providing their user name. |
| hue_range | Hue range of the colour: 12,68. Values must be in range [0,359] and the left value must be less than the right value. |
| bri_range | Brightness range of the colours: 2,88. Values must be in range [0, 99] and the left value must be less than the right value. |
| keywords | String of keywords to search for in patterns. |
| keyword_exact | Perform an exact search for the keywords passed if set to 1. Default: 0. |
| order_col | dateCreated, score, name`, ``numVotes or numViews |
| sort_by | Sorting in asceding (ASC) or descending (DESC) order. Defaults to (ASC) |
| num_results | Number of results to be returned. Maximum: 100. Default: 20. |
| result_offset | Result offset, for paging. Default: 0. |
| lover | Restrict results to specific COLOURlover by providing their user name. |
| hue_option | yellow, orange, red or green, violet or blue |
| hex | Restrict results to patterns with a specific colour given as any valid 6-char hex value without preceeding #. |
| keywords | String of keywords to search for in patterns. |
| keyword_exact | Perform an exact search for the keywords passed if set to 1. Default: 0. |
| order_col | dateCreated, score, name`, ``numVotes or numViews |
| sort_by | Sorting in asceding (ASC) or descending (DESC) order. Defaults to (ASC) |
| num_results | Number of results to be returned. Maximum: 100. Default: 20. |
| result_offset | Result offset, for paging. Default: 0. |
| show_palette_widths | Shows palette’s colour’s widths if set to 1. Default: 0 |
| lover | Restrict results to specific COLOURlover by providing their user name. |
| hue_option | yellow, orange, red or green, violet or blue |
| hex | Restrict results to patterns with a specific colour given as any valid 6-char hex value without preceeding #. |
| keywords | String of keywords to search for in patterns. |
| keyword_exact | Perform an exact search for the keywords passed if set to 1. Default: 0. |
| order_col | dateCreated, score, name`, ``numVotes or numViews |
| sort_by | Sorting in asceding (ASC) or descending (DESC) order. Defaults to (ASC) |
| num_results | Number of results to be returned. Maximum: 100. Default: 20. |
| result_offset | Result offset, for paging. Default: 0. |
| comments | 0 or 1: if 1, will show last 10 comments for given Lover |
| order_col | Order in which the colours will be shown. Possible values are: dateCreated, score, name`, ``numVotes or numViews. |
| sort_by | Sorting in asceding (ASC) or descending (DESC) order. Defaults to (ASC) |
| num_results | Number of results to be returned. Maximum: 100. Default: 20. |
| result_offset | Result offset, for paging. Default: 0. |
Return the stats for stat_type. stat_type refers to one of the content types on ColourLovers and can be colors, lovers, patterns, palettes. A ColourLoversError is raised when an invalid type is requested.
Request the statistical value (total number) for stats_type. stats_type is a string that can be either of the following: colors, patterns, palettes, lovers.
This class defines a ColourLovers colour in the RGB and HSV colour spaces. The colour values can be accessed through the rgb and hsv respectively and are of type RGB and HSV.
Unique id for this Color as int.
Title / Name of the Color.
Username of the Color’s creator.
Number of views this Color has received as int.
Number of votes this Color has received as int.
Number of comments this Color has received as int.
Number of hearts this Color has in the range of [0,5] as float.
This Color’s rank on COLOURlovers.com as int.
Date this Color was created as a datetime object.
This Color’s description.
This Color’s COLOURlovers.com URL.
Link to a PNG version of this Color.
Link to a COLOURlovers.com badge for this Color.
This Color’s COLOURlovers.com API URL.
Create a new colour instance from xml. xml is a DOM element with the root element name color.
Returns the name of the XML tag for a colour object.
Unique id for this Palette as int.
Title / Name of the Palette.
Username of the Palette’s creator.
Number of views this Palette has received as int.
Number of votes this Palette has received as int.
Number of comments this Palette has received as int.
Number of hearts this Palette has in the range [0,5] as float.
This Palette’s rank on COLOURlovers.com as int.
Date this Palette was created as datetime object.
List of Colors within this Palette as hex values
This Palette’s Color’s widths in the range [0.0, 1.0] as float.
Note: this attribute is optional and might not be present if not returned by the API response.
This Palette’s description
This Palette’s COLOURlovers.com URL.
Link to a png version of this Palette.
Link to a COLOURlovers.com badge for this Palette.
This Palette’s COLOURlovers.com API URL.
Unique id for this Pattern as int.
Title / Name of the Pattern.
Username of the Pattern’s creator.
Number of views this Pattern has received as int.
Number of votes this Pattern has received as int.
Number of comments this Pattern has received as int.
Number of Hearts this Pattern has in the range [0,5] as float.
This Pattern’s rank on COLOURlovers.com as int.
Date this Pattern was created as datetime object.
List of colors within this Pattern as hex code.
This Pattern’s description.
This Pattern’s COLOURlovers.com URL
Link to a PNG version of this Pattern.
Link to a COLOURlovers.com badge for this Pattern.
This Pattern’s COLOURlovers.com API URL.
Unique id for this Lover as int.
This Lover’s Username.
Date this Lover registered with COLOURlovers.com as datetime object.
Date this Lover was last active on COLOURlovers.com as datetime object.
This Lover’s rating
This Lover’s location.
Number of Colors this Lover has made as int.
Number of Palettes this Lover has made as int.
Number of Patterns this Lover has made as int.
Number of comments this Lover has made as int.
Number of Lovers [friends] this Lover has as int.
Number of comments this Lover has on their profile as int.
Last 10 comments made on this Lover’s profile as list of Comment instances.
Note: this attribute is optional. It is only returned when sending the parameter comments=1 in the request.
This Lover’s COLOURlovers.com URL.
This Lover’s COLOURlovers.com API URL.
Define a RGB colour as a triple of integers in the range from 0 to 255. The colour channels are stored in attributes red, green, blue.
Create an instance of RGB from xml.
Red colour channel in range [0, 255]
Green colour channel in range [0, 255]
Blue colour channel in range [0, 255]
Return hex colour code corresponding to the RGB value.
Define a HSV colour instance from hue, saturation and value. The three values have to be integer values with hue in range [0, 360] and saturation, value in range [0, 255].
Create an instance of HSV from xml.
HSV hue channel in range [0, 360]
HSV saturation channel in range [0, 255]
HSV value channel in range [0, 255]