api.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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 "npt". To get the
  50. 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. + /ami4get
  85. Tells you basic information about the 4get instance. CORS requests
  86. are allowed on this endpoint.
  87. + /api/v1/web
  88. + &extendedsearch
  89. When using the ddg(DuckDuckGo) scraper, you may make use of the
  90. &extendedsearch parameter. If you need rich answer data from
  91. additional sources like StackOverflow, music lyrics sites, etc.,
  92. you need to specify the value of (string)"true".
  93. The default value is "false" for API calls.
  94. + Parse the "spelling"
  95. The array index named "spelling" contains 3 indexes ::
  96. spelling:
  97. type: "including"
  98. using: "4chan"
  99. correction: '"4cha"'
  100. The "type" may be any of these 3 values. When rendering the
  101. autocorrect text inside your application, it should look like
  102. what follows right after the parameter value ::
  103. no_correction <Empty>
  104. including Including results for %using%. Did you mean
  105. %correction%?
  106. not_many Not many results for %using%. Did you mean
  107. %correction%?
  108. As of right now, the "spelling" is only available on
  109. "/api/v1/web".
  110. + Parse the "answer"
  111. The array index named "answer" may contain a list of multiple
  112. answers. The array index "description" contains a linear list of
  113. nodes that can help you construct rich formatted data inside of
  114. your application. The structure is similar to the one below:
  115. answer:
  116. 0:
  117. title: "Higurashi"
  118. description:
  119. 0:
  120. type: "text"
  121. value: "Higurashi is a great show!"
  122. 1:
  123. type: "quote"
  124. value: "Source: my ass"
  125. Each "description" node contains an array index named "type".
  126. Here is a list of them:
  127. text
  128. + title
  129. italic
  130. + quote
  131. + code
  132. inline_code
  133. link
  134. + image
  135. + audio
  136. Each individual node prepended with a "+" should be prepended by
  137. a newline when constructing the rendered description object.
  138. There are some nodes that differ from the type-value format.
  139. Please parse them accordingly ::
  140. + link
  141. type: "link"
  142. url: "https://lolcat.ca"
  143. value: "Visit my website!"
  144. + image
  145. type: "image"
  146. url: "https://lolcat.ca/static/pixels.png"
  147. + audio
  148. type: "audio"
  149. url: "https://lolcat.ca/static/whatever.mp3"
  150. The array index named "table" is an associative array. You can
  151. loop over the data using this PHP code, for example ::
  152. foreach($table as $website_name => $url){ // ...
  153. The rest of the JSON is pretty self explanatory.
  154. + /api/v1/images
  155. All images are contained within "image". The structure looks like
  156. below ::
  157. image:
  158. 0:
  159. title: "My awesome Higurashi image"
  160. source:
  161. 0:
  162. url: "https://lolcat.ca/static/profile_pix.png"
  163. width: 400
  164. height: 400
  165. 1:
  166. url: "https://lolcat.ca/static/pixels.png"
  167. width: 640
  168. height: 640
  169. 2:
  170. url: "https://tse1.mm.bing.net/th?id=OIP.VBM3BQg
  171. euf0-xScO1bl1UgHaGG"
  172. width: 194
  173. height: 160
  174. The last image of the "source" array is always the thumbnail, and is
  175. a good fallback to use when other sources fail to load. There can be
  176. more than 1 source; this is especially true when using the Yandex
  177. scraper, but beware of captcha rate limits.
  178. + /api/v1/videos
  179. The "time" parameter for videos may be set to "_LIVE". For live
  180. streams, the amount of people currently watching is passed in
  181. "views".
  182. + /api/v1/news
  183. Just make a request to "/api/v1/news?s=elon+musk". The payload
  184. has nothing special about it and is very self explanatory, just like
  185. the endpoint above.
  186. + /api/v1/music
  187. Each entry under "song" contains a array index called "stream" that
  188. looks like this ::
  189. endpoint: sc
  190. url: https://api-v2.soundcloud <...>
  191. When the endpoint is something else than "linear", you MUST use
  192. the specified endpoint. Otherwise, you are free to handle that
  193. json+m3u8 crap yourself. If the endpoint is equal to "linear", the
  194. URL should return a valid HTTP audio stream. To access the endpoint,
  195. you must add the following prefix in your request, like so:
  196. https://4get.ca/audio/<endpoint>?s=<url>
  197. + /favicon
  198. Get the favicon for a website. The only parameter is "s", and must
  199. include the protocol for fetching in case the favicon is not cached
  200. yet.
  201. Example ::
  202. /favicon?s=https://lolcat.ca
  203. If we had to revert to using Google's favicon cache, it will throw
  204. an error in the X-Error header field. If Google's favicon cache
  205. also failed to return an image, or if you're too retarded to specify
  206. a valid domain name, a default placeholder image will be returned
  207. alongside the "404" HTTP error code.
  208. + /proxy
  209. Get a proxied image. Useful if you don't want to leak your user's IP
  210. address. The parameters are "i" for the image link and "s" for the
  211. size.
  212. Acceptable "s" parameters:
  213. portrait 90x160
  214. landscape 160x90
  215. square 90x90
  216. thumb 236x180
  217. cover 207x270
  218. original <Original resolution>
  219. You can also ommit the "s" parameter if you wish to view the
  220. original image. When an error occurs, an "X-Error" header field
  221. is set.
  222. + /audio/linear
  223. Get a proxied audio file. Does not support "Range" headers, as it's
  224. only used to proxy small files (hence why it's called linear DUH)
  225. The parameter is "s" for the audio link.
  226. + /audio/sc
  227. Get a proxied audio file for SoundCloud. Does not support downloads
  228. trough WGET or CURL, since it returns 30kb~160kb "206 Partial
  229. Content" parts, due to technical limitations that comes with
  230. converting m3u8 playlists to seekable audio files. If you use this
  231. endpoint, you must support these 206 codes and also handle the
  232. initial 302 HTTP redirect. I used this method as I didn't want to
  233. store information about your request needlessly. This method also
  234. allows noJS users to access the files.
  235. The parameter is "s" for the SoundCloud JSON m3u8 abomination. It
  236. does not support "normal" SoundCloud URLs at this time.
  237. + /audio/spotify
  238. Get a proxied Spotify audio file. Accepts a track ID for the "s"
  239. parameter. Will only allow you to fetch the 30 second preview since
  240. I don't feel like fucking with cookies and accounts every fucking
  241. living moment of my life. You must handle the initial 302 redirect
  242. to the /audio/linear endpoint.
  243. + Appendix
  244. If you have any questions or need clarifications, please send an
  245. email my way to will at lolcat.ca