api.txt 12 KB

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