API

SpinChimp

class spinchimp.SpinChimp(email, apikey, aid='')[source]

A class representing the Spin Chimp API (http://spinchimp.com/api). All articles must be in UTF-8 encoding!

URL = 'http://api.spinchimp.com/{method}?'

URL for invoking the API

_get_param_value(param_name, params, def_params={'applyinstantunique': '0', 'fullcharset': '0', 'rewrite': '0', 'spintidy': '0', 'spinwithinspin': '0', 'quality': '4', 'tagprotect': '', 'protectedterms': '', 'maxspindepth': '0', 'spinwithinhtml': '0', 'posmatch': '3', 'phraseignorequality': '0'})[source]

Returns parameter value or use default.

_send_request(method, text, params)[source]

Invoke Spin Chimp API with given parameters and return its response.

Parameters:params (dictionary) – parameters to pass along with the request
Returns:API’s response (article)
Return type:string
_validate(params)[source]

Checks every single parameter and raise error on wrong key or value.

_value_has(param, values, params)[source]

Raise WrongParameterVal if value of param is not in values.

_value_is_int(param, params)[source]

Raise WrongParameterVal if value of param is not integer.

quota_all()[source]

The server returns: daily limit, remaining daily limit, extended quota and bulk quota in dictionary for this account.

quota_left_total()[source]

The server returns remaining query times of this account.

static test_connection()[source]

Static method that checks server status. The server returns ‘OK’ on successful connection.

text_with_spintax(text, params=None)[source]

Return processed spun text with spintax.

Parameters:
  • text (string) – original text that needs to be changed
  • params (dictionary) – parameters to pass along with the request
Returns:

processed text in spintax format

Return type:

string

unique_variation(text, params=None)[source]

Return a unique variation of the given text.

Parameters:
  • text (string) – original text that needs to be changed
  • params (dictionary) – parameters to pass along with the request
Returns:

processed text

Return type:

string

unspun(text, dontincludeoriginal=0, reorderparagraphs=0)[source]

Generates an unspun doc from one with spintax. Optionally reorders paragraphs and removes original word.

Parameters:
  • text (string) – text in spintax format
  • dontincludeoriginal (integer) – 0 (False) or 1 (True)
  • reorderparagraphs (integer) – 0 (False) or 1 (True)
Returns:

unique text

Return type:

dictionary

word_density(text, minlength=3)[source]

Calculates the word densities of words and phrases in the article.

Parameters:
  • text (string) – original text
  • minlength (integer) – minimum length
Returns:

words as keys in dictionary and percents as values

Return type:

dictionary

Exceptions

exception spinchimp.exceptions.ArticleError(msg)[source]

Raised when spinning article.

exception spinchimp.exceptions.AuthenticationError(msg)[source]

Raised when authentication error occurs.

exception spinchimp.exceptions.InternalError(msg)[source]

Raised when unexpected error occurs on the API server when processing a request.

exception spinchimp.exceptions.NetworkError(msg)[source]

Raised if there are network problems, like timeout.

exception spinchimp.exceptions.QuotaLimitError(msg)[source]

Raised when API quota limit is reached.

exception spinchimp.exceptions.SpinChimpError(api_error_msg)[source]

Base class for exceptions in Spin Chimp module.

exception spinchimp.exceptions.UnknownError(msg)[source]

Raised when API call results in an unrecognized error.

exception spinchimp.exceptions.WrongParameterName(name)[source]

Raised on unsuppported parameter name.

exception spinchimp.exceptions.WrongParameterVal(name, val)[source]

Raised on invalid parameter value.