~www.0wx.es~ :: Хостинг файлів та інші корисні інструменти


Вивантаження TinyURL HugeURL Pastebin Про сервіс Поскаржитися Вхід
Українська
English English Español Español Català Català Galego Galego Português Português Français Français Italiano Italiano Română Română Deutsch Deutsch Nederlands Nederlands Dansk Dansk Svenska Svenska Bokmål Bokmål Íslenska Íslenska 日本語 日本語 简体中文 简体中文 繁體中文 繁體中文 한국어 한국어 Euskara Euskara Esperanto Esperanto Polski Polski Čeština Čeština Русский Русский Türkçe Türkçe Bahasa Indonesia Bahasa Indonesia Bahasa Melayu Bahasa Melayu

Для всіх функцій на www.0wx.es є API. Його можна використовувати у сценаріях або з консолі.

Everything the forms on this site do, for scripts. Every reply is JSON, including errors, so you never have to guess whether a body is a result or an explanation.

Making a request

POST to the endpoint with either form parameters or a JSON body. Both are equivalent; pick whichever your tooling makes easier. The action parameter selects what to do.

curl -X POST https://www.0wx.es/api.cgi \
     -d action=paste -d content='hello world'

curl -X POST https://www.0wx.es/api.cgi \
     -H 'Content-Type: application/json' \
     -d '{"action":"paste","content":"hello world"}'
Authentication

Optional. Without a key a request is anonymous and behaves exactly like an anonymous visitor — the result is public either way, the only difference is whether it lands in your file list. Generate a key on your account page and send it as a bearer token; passing it as an apikey parameter also works, but a key in a query string ends up in server logs and browser history.

curl -X POST https://www.0wx.es/api.cgi \
     -H 'Authorization: Bearer YOUR_KEY' \
     -d action=whoami
Actions
actionParametersDescription
whoamiConfirms a key works and reports the current limits. Costs nothing; call it first.
uploadfile (repeatable), resize, lifetimeUploads one or more files. Must be multipart/form-data.
tinyurlurl, lifetimeShortens a URL.
hugeurlurl, lifetimeLengthens a URL, absurdly, on purpose.
pastecontent, lifetimeStores a block of text and returns a link to it.
translatecontent, toTranslates text. to is an ISO 639 code — note these are not always country codes: Danish is da, not dk.
Uploading files

Uploads cannot use the JSON body, because a file has to be sent as multipart. Repeat the file part to send several at once. Each file is reported separately: the reply carries a files list of those that were accepted and a rejected list of those that were not, so a partial success is still a success.

curl -X POST https://www.0wx.es/api.cgi \
     -H 'Authorization: Bearer YOUR_KEY' \
     -F action=upload \
     -F file=@photo.jpg \
     -F file=@notes.txt \
     -F lifetime=7d
Lifetime

Optional on every action that stores something. Accepts bare seconds, or a number followed by m, h or d — the same forms the web forms take. Omit it or pass 0 to keep the item indefinitely.

Replies

Every reply is a JSON object with an ok field. On success it carries the result; on failure it carries a stable error code and a human-readable message. Branch on the code, log the message.

{"ok":true,"type":"paste","share":"Ab3xK9pQ",
 "url":"https://www.0wx.es/p/Ab3xK9pQ","bytes":11}

{"ok":false,"error":"url_too_long",
 "message":"URL exceeds the maximum length."}
Error codes
errorHTTPDescription
unknown_action400No such action.
bad_json400The body was not valid JSON, or a field held a nested structure.
bad_key401The key was not recognised. A wrong key is refused rather than silently treated as anonymous.
bad_url400The URL is malformed, or uses a scheme other than http(s), ftp or gopher.
bad_lifetime400The lifetime was not a number or a number followed by m, h or d.
no_content400Nothing was sent to store.
url_too_long413The URL is longer than the limit.
paste_too_long413The text is larger than the paste limit. Limits are measured in bytes of UTF-8, so non-Latin text counts more than its character count suggests.
too_many_files413More files than one call accepts.
no_usable_files415Every file was rejected. Check the rejected list for why.
backend_unavailable502The translation backend did not answer.
internal500Something failed unexpectedly. It has been logged.
Limits

Call whoami to read the current values rather than hardcoding them — they are set by the server operator and can change. Sizes are bytes of UTF-8.

Notes

There is deliberately no remote-fetch action. It would make the server retrieve a URL of the caller's choosing, which is a request-forgery surface, and a script can drive that far harder than a form. Upload the file yourself instead.


(p) 2018 www.0wx.es -/- Powered by Linux and GNU. Live free or die! (root@www.0wx.es)