api.txt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. __ __ __
  2. / // / ____ ____ / /_
  3. / // /_/ __ `/ _ \/ __/
  4. /__ __/ /_/ / __/ /_
  5. /_/ \__, /\___/\__/
  6. /____/
  7. + Welcome to the 4get API documentation +
  8. + Terms of use
  9. Do NOT misuse the API. Misuses can include... ::
  10. 1. Serp SEO scanning
  11. 2. Intensive scraping
  12. 3. Any other activity that isn't triggered by a human
  13. 4. Illegal activities in Canada
  14. 5. Constant "test" queries while developping your program
  15. (please cache the API responses!)
  16. Examples of good uses of the API ::
  17. 1. A chatroom bot that presents users with search results
  18. 2. Personal use
  19. 3. Any other activity that is initiated by a human
  20. If you wish to engage in the activities listed under "misuses", feel
  21. free to download the source code of the project and running 4get
  22. under your own terms. Please respect the terms of use listed here so
  23. that this website may be available to all in the far future.
  24. P.s fuck whoever botted my site for months on end, choke on my dick
  25. lol!!!!
  26. Get your instance running here ::
  27. https://git.lolcat.ca/lolcat/4get
  28. Thanks!
  29. + Passes
  30. Depending of the instance, you may need to provide a "pass" token
  31. in the cookies of your request. These can be obtained from solving
  32. a captcha which will allow you to make 100 requests in the next 24
  33. hours. In the future, you will be able to ask the serber maintainer
  34. for a "pass" which will allow you to bypass the captcha requirement.
  35. The captcha doesn't need javascript to work.
  36. + Decode the data
  37. All payloads returned by the API are encoded in the JSON format. If
  38. you don't know how to tackle the problem, maybe programming is not
  39. for you.
  40. All of the endpoints use the GET method.
  41. + Check if an API call was successful
  42. All API responses come with an array index named "status". If the
  43. status is something else than the string "ok", something went wrong.
  44. You can supply the content of the "status" string back to your
  45. application to inform the user of what went wrong.
  46. The HTTP code will be 429 if your pass is invalid. It is set to 200
  47. otherwise.
  48. + Get the next page of results
  49. All API responses come with an array index named "nextpage". To get
  50. the next page of results, you must make another API call with &npt.
  51. Example ::
  52. + First API call
  53. /api/v1/web?s=higurashi
  54. + Second API call
  55. /api/v1/web?npt=ddg1._rJ2hWmYSjpI2hsXWmYajJx < ... >
  56. You shouldn't specify the search term, only the &npt parameter
  57. suffices.
  58. The first part of the token before the dot (ddg1) refers to an
  59. array position on the serber's memory. The second part is an
  60. encryption key used to decode the data at that position. This way,
  61. it is impossible to supply invalid pagination data and it is
  62. impossible for a 4get operator to peek at the private data of the
  63. user after a request has been made.
  64. The tokens will expire as soon as they are used or after a 15
  65. minutes inactivity period, whichever comes first.
  66. + Beware of null values!
  67. Most fields in the API responses can return "null". You don't need
  68. to worry about unset values.
  69. + API Parameters
  70. To construct a valid request, you can use the 4get web interface
  71. to craft a valid request, and replace "/web" with "/api/v1/web".
  72. + "date" and "time" parameters
  73. "date" always refer to a calendar date.
  74. "time" always refer to the duration of some media.
  75. They are both integers that uses seconds as its unit. The "date"
  76. parameter specifies the number of seconds that passed since January
  77. 1st 1970.
  78. ______ __ _ __
  79. / ____/___ ____/ /___ ____ (_)___ / /______
  80. / __/ / __ \/ __ / __ \/ __ \/ / __ \/ __/ ___/
  81. / /___/ / / / /_/ / /_/ / /_/ / / / / / /_(__ )
  82. /_____/_/ /_/\__,_/ .___/\____/_/_/ /_/\__/____/
  83. /_/
  84. + /api/v1/web
  85. + &extendedsearch
  86. When using the ddg(DuckDuckGo) scraper, you may make use of the
  87. &extendedsearch parameter. If you need rich answer data from
  88. additional sources like StackOverflow, music lyrics sites, etc.,
  89. you need to specify the value of (string)"true".
  90. The default value is "false" for API calls.
  91. + Parse the "spelling"
  92. The array index named "spelling" contains 3 indexes ::
  93. spelling:
  94. type: "including"
  95. using: "4chan"
  96. correction: '"4cha"'
  97. The "type" may be any of these 3 values. When rendering the
  98. autocorrect text inside your application, it should look like
  99. what follows right after the parameter value ::
  100. no_correction <Empty>
  101. including Including results for %using%. Did you mean
  102. %correction%?
  103. not_many Not many results for %using%. Did you mean
  104. %correction%?
  105. As of right now, the "spelling" is only available on
  106. "/api/v1/web".
  107. + Parse the "answer"
  108. The array index named "answer" may contain a list of multiple
  109. answers. The array index "description" contains a linear list of
  110. nodes that can help you construct rich formatted data inside of
  111. your application. The structure is similar to the one below:
  112. answer:
  113. 0:
  114. title: "Higurashi"
  115. description:
  116. 0:
  117. type: "text"
  118. value: "Higurashi is a great show!"
  119. 1:
  120. type: "quote"
  121. value: "Source: my ass"
  122. Each "description" node contains an array index named "type".
  123. Here is a list of them:
  124. text
  125. + title
  126. italic
  127. + quote
  128. + code
  129. inline_code
  130. link
  131. + image
  132. + audio
  133. Each individual node prepended with a "+" should be prepended by
  134. a newline when constructing the rendered description object.
  135. There are some nodes that differ from the type-value format.
  136. Please parse them accordingly ::
  137. + link
  138. type: "link"
  139. url: "https://lolcat.ca"
  140. value: "Visit my website!"
  141. + image
  142. type: "image"
  143. url: "https://lolcat.ca/static/pixels.png"
  144. + audio
  145. type: "audio"
  146. url: "https://lolcat.ca/static/whatever.mp3"
  147. The array index named "table" is an associative array. You can
  148. loop over the data using this PHP code, for example ::
  149. foreach($table as $website_name => $url){ // ...
  150. The rest of the JSON is pretty self explanatory.
  151. + /api/v1/images
  152. All images are contained within "image". The structure looks like
  153. below ::
  154. image:
  155. 0:
  156. title: "My awesome Higurashi image"
  157. source:
  158. 0:
  159. url: "https://lolcat.ca/static/profile_pix.png"
  160. width: 400
  161. height: 400
  162. 1:
  163. url: "https://lolcat.ca/static/pixels.png"
  164. width: 640
  165. height: 640
  166. 2:
  167. url: "https://tse1.mm.bing.net/th?id=OIP.VBM3BQg
  168. euf0-xScO1bl1UgHaGG"
  169. width: 194
  170. height: 160
  171. The last image of the "source" array is always the thumbnail, and is
  172. a good fallback to use when other sources fail to load. There can be
  173. more than 1 source; this is especially true when using the Yandex
  174. scraper, but beware of captcha rate limits.
  175. + /api/v1/videos
  176. The "time" parameter for videos may be set to "_LIVE". For live
  177. streams, the amount of people currently watching is passed in
  178. "views".
  179. + /api/v1/news
  180. Just make a request to "/api/v1/news?s=elon+musk". The payload
  181. has nothing special about it and is very self explanatory, just like
  182. the endpoint above.
  183. + /api/v1/music
  184. Each entry under "song" contains a array index called "stream" that
  185. looks like this ::
  186. endpoint: audio_sc
  187. url: https://api-v2.soundcloud <...>
  188. When the endpoint is "audio_sc", you MUST use 4get's audio_sc
  189. endpoint, for example, if you want an audio stream back. Otherwise,
  190. you are free to handle the json+m3u8 crap yourself. If the endpoint
  191. is equal to "audio", that URL SHOULD return a valid HTTP audio
  192. stream, and using the "audio" endpoint becomes optional again.
  193. + /favicon
  194. Get the favicon for a website. The only parameter is "s", and must
  195. include the protocol.
  196. Example ::
  197. /favicon?s=https://lolcat.ca
  198. If we had to revert to using Google's favicon cache, it will throw
  199. an error in the X-Error header field. If Google's favicon cache
  200. also failed to return an image, or if you're too retarded to specify
  201. a valid domain name, a default placeholder image will be returned
  202. alongside the "404" HTTP error code.
  203. + /proxy
  204. Get a proxied image. Useful if you don't want to leak your user's IP
  205. address. The parameters are "i" for the image link and "s" for the
  206. size.
  207. Acceptable "s" parameters:
  208. portrait 90x160
  209. landscape 160x90
  210. square 90x90
  211. thumb 236x180
  212. cover 207x270
  213. original <Original resolution>
  214. You can also ommit the "s" parameter if you wish to view the
  215. original image. When an error occurs, an "X-Error" header field
  216. is set.
  217. + /audio
  218. Get a proxied audio file. Does not support "Range" headers, as it's
  219. only used to proxy small files.
  220. The parameter is "s" for the audio link.
  221. + /audio_sc
  222. Get a proxied audio file for SoundCloud. Does not support downloads
  223. trough WGET or CURL, since it returns 30kb~160kb "206 Partial
  224. Content" parts, due to technical limitations that comes with
  225. converting m3u8 playlists to seekable audio files. If you use this
  226. endpoint, you must support these 206 codes and also handle the
  227. initial 302 HTTP redirect. I used this method as I didn't want to
  228. store information about your request needlessly. This method also
  229. allows noJS users to access the files.
  230. The parameter is "s" for the SoundCloud JSON m3u8 abomination. It
  231. does not support "normal" SoundCloud URLs at this time.
  232. + Appendix
  233. If you have any questions or need clarifications, please send an
  234. email my way to will at lolcat.ca