"Want to be a person who can be beautiful and smile, no matter how sad it is." 』
Hitokoto API Update: 2014.02.22 Issue/Feedback: API # hitokoto.us Data acquisition: [Data acquisition] Invocation Example: [JavaScript + HTML (sync)] [JavaScript + JSON CallBack (synchronous + asynchronous invocation)] Click here to see which websites are using the API
Data Acquisition Request AddressHttp://api.hitokoto.us/rand
SSLHttps://api.hitokoto.us:214/rand
Request MethodGet
Request Parameters CatReturns a word for the specified category, or a word that returns any category if it is empty. If the request parameter contains a UID, the cat corresponds to the CID
CharSetCharacter set, support Gbk/utf-8, default for Utf-8
lengthReturns the length limit of a sentence, breaks it and adds an ellipsis
encodeData format, corresponding to the following
JSONBy default, returns JSON format data
XMLreturn XML Format data
JSReturns a JavaScript script with the function named Hitokoto, which is used to synchronize calls to the
JSCReturns a JavaScript script that specifies the name of the callback function, which can be used to invoke an asynchronous
FunWhen used for asynchronous invocation, specifies the name of the callback function, and cannot contain special characters
UIDGet a WORD from me
MixAt the same time in the system included "a word" and get "my words" in random, if you want to specify user classification please use the UCAT parameter
UcatUsed with mix parameters to specify user classification CID
instance RequestHttp://api.hitokoto.us/rand?cat=a&charset=utf-8
return
{
ID: "1318722783000",
Hitokoto: "Na, know, cherry blossom falling speed, is five centimeters per second Oh ~",
Cat: "A",
CatName: "Animation",
Author: "Baked Fish's potatoes",
Source: "Five cm in seconds",
Like: "5",
Date: "2011.10.15 23:53:03"
}parameter Description IDThe ID of a word, you can view the specified entry by http://hitokoto.us/view/{id}.htmlHitokotoThe body part of a word, not including the front and back quotesCatClassification, the corresponding relationship is as followsaAnime-AnimationbComic-ComicsCGame-GamesDNovel-FictioneOriginalFFrom the networkgOtherCatNameCategory Cat corresponding nameauthorOne-word contributorsSourceThe source of a word, may be empty likeA word of love timesDateOne-word submission date
Invoke Example-JavaScript + HTML Script AddressHttp://api.hitokoto.us/rand?encode=jsSSLHttps://api.hitokoto.us:214/rand?encode=jsHow to use
1. Put the following code inside the head tag of the HTML page
<script type= "Text/javascript" src= "Http://api.hitokoto.us/rand?encode=js&charset=utf-8" ></script >
2. Put the following code into the page you need to show the location of a sentence
<div id= "Hitokoto" ><script>hitokoto () </script></div>
The script is essentially a document.write script.
Invocation Examples-JavaScript + JSON CallBack script Address http://api.hitokoto.us/rand?encode=jsc SSLHTTPS://API.HITOKOTO.US:214/RAND?ENCODE=JSC Using method synchronization
1. Put the following code inside the head tag of the HTML page
<script type= "Text/javascript" src= "Http://api.hitokoto.us/rand?encode=jsc&fun=sync" ></script>
The script is loaded synchronously with the page, the specified function name is automatically invoked when the load succeeds, the sync in this instance, and the data is passed to the function, which is defined in advance to receive and process a word data immediately. Asynchronous
1. Put the following code at the bottom of the HTML page
<script type= "text/javascript" >settimeout (function () {var hjs= Document.createelement (' script '); Hjs.setattribute (' src ', ' http://api.hitokoto.us/rand?encode=jsc&fun=async ') );d Ocument.body.appendChild (HJS);},100 </script>
to load JavaScript scripts by settimeout to achieve the purpose of asynchronously loading JS scripts. When the load succeeds, the specified function name is automatically invoked, async in this instance, and the data is passed to the function, which is defined in advance to receive and process a word data.
URL: http://hitokoto.us/api.html lost in the valley of the birds, flying alone in this huge world, but do not know where to fly to the side ...