Last February, we presented our Great Words project. In this topic, I want to present our API, created so that third-party developers can create their products based on our project. Using quotes in your designs is now easy and simple.
Our API "communicates" in XML . The following are the request format and response format. All you have to do is send the generated request to http://api.greatwords.ru/ and parse the answer.
Previously, to start using the API, you send us an email (address see page http://api.greatwords.ru/), in which you need to indicate in which software product (application, widget, website) quotes will be used. After that, you will receive a unique key (API key), which you will need to pass in the request.
Requests are accepted by the GET and POST methods. The following parameters can be used in the request:
apikey = - your unique key (required parameter);
by = (author | keyword | user | favorites | random | new) - by what parameter (by author, by label, by user who added a quote, from a selected user, randomly, new by date) do you want to get a quote or quotes (required parameter );
condition = <condition> - condition; the condition may be the identifier of the author, tag or user, as well as the name of the author, tag word, user name or search query (optional parameter);
count = <amount> - the number of citations you need (optional parameter);
random = 1 - a parameter indicating that you need randomly selected quotes that satisfy the condition (optional parameter).
For example, to get all quotes for the label “ love ”, the query should look like this: by = keyword & condition = 7 (where 7 is the id of this label). In addition, you can use this type of query: by = keyword & condition = love , but in this case, pay attention to the fact that the text should be in UTF-8 encoding.
Another example: you need to get 10 random quotes. In this case, the request should look like this: by = random & count = 10 . And to get 10 new quotes, you should use the query by = new & count = 10 .
And finally, an example if you want to get a random quote from your favorites each time. Then you need to use the following query: by = favorites & condition =& count = 1 & random = 1 (Where Is your user id) or even by = favorites & condition =& count = 1 & random = 1 (Where - your login).
The answer is formed in the following format:
http://greatwords.ru/quote/20/ It is not a shame to be born stupid, it is a shame only to die a fool. Erich Maria Remarque
http://greatwords.ru/author/2/
"Three comrades" 1938 year
...
When using the API, a hyperlink to greatwords.ru and / or to the pages of authors / quotes is obligatory.