-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswagger.json
1 lines (1 loc) · 29.1 KB
/
swagger.json
1
{"swagger":"2.0","info":{"description":"# Introduction\nYou've found the sxcu.net API documentation! These pages are dedicated to showing you all the ways that you can use sxcu.net to make cool stuff.\nAll of our [documentation is on GitHub](https://github.com/MisterFixx/sxcu-docs), so feel free to submit corrections and improvements!\n## Bugs\nIf you believe you're experiencing a bug with our API or want to report incorrect documentation, open an issue on our [issue tracker](https://github.com/MisterFixx/sxcu-docs/issues).\n## Still need some help?\nJoin the [Official Discord server](https://discord.gg/Yuf6ukX) for support and discussion regarding sxcu.net's APIs.\n# API Reference\n## Base URL\n```text\nhttps://sxcu.net/api\n```\n## User Agent\nClients using the HTTP API must provide a valid [User Agent](https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43) which specifies information about the client library and version in the following format:\n### User Agent Example\n```text\nUser-Agent: sxcuUploader/$versionNumber (+$url)\n```\nClients may append more information and metadata to the end of this string as they wish.\n## Nullable and Optional Resource Fields\nResource fields that may contain a null value have types that are prefixed with a question mark. Resource fields that are optional have names that are suffixed with a question mark.\n### Example Nullable and Optional Fields\nFIELD | TYPE\n-----------------------------|--------\noptional_field? | string\nnullable_field | ?string\noptional_and_nullable_field? | ?string\n## Boolean Query Strings\nCertain endpoints in the API are documented to accept booleans for their query string parameters. While there is no standard system for boolean representation in query string parameters, sxcu.net represents such cases using True, true, or 1 for true and False, false or 0 for false.\n## Snowflakes\nsxcu.net utilizes a customized version of Twitter's [snowflake](https://github.com/twitter-archive/snowflake/tree/scala_28) format for uniquely identifiable descriptors (IDs).\nThese IDs are guaranteed to be unique across all of sxcu.net. \nBecause Snowflake IDs are up to 53 bits in size (e.g. a uint64), they are always referred by as base 63 encoded strings to prevent integer overflows in some languages and also to make them visually nicer. \nSince Snowflakes are always base 63 encoded, in order to do any bitwise operations on then, they have to first be converted back into base 10. \n**Note**: sxcu.net started employing Snowflakes for its object IDs since the 30th of June, 2021 at 14:40 PM, any ID before that is not a valid Snowflake.\n### Snowflake ID Broken Down in Binary\n```text\n1111111111111111111111111111111 1111 1111 11111111111111\n53 22 18 14 0\n```\n### Snowflake ID Format Structure (Left to Right)\nField | Bits | Number of bits | Description | Retrieval\n------------|----------|----------------|---------------------------------------------------------------------------------------|---------------------------------\nTimestamp | 53 to 22 | 31 bits | Seconds since sxcu.net Epoch, which is 1326466131. | `(snowflake >> 22) + 1326466131`\nObject type | 21 to 18 | 4 bits | Indicates the type of object this snowflake belongs to. | `(snowflake >> 18 & 15)`\nObject flag | 17 to 14 | 4 bits | Will be 0 unless object type is 1, then it will contain the type of an uploaded file. | `(snowflake >> 14 & 15)`\nSequence | 13 to 0 | 14 bits | This number is incremented for every ID that is generated in the same second. | `snowflake & 16383`\n#### Object types field\n1 = uploaded file \n2 = redirect (link) \n3 = collection \n4 = paste (used in cancer-co.de) \n#### Object flags field\n1 = png \n2 = jpeg \n3 = gif \n4 = ico \n5 = bmp \n6 = tiff \n7 = webm \n### Convert Snowflake to DateTime\n![Graphical representation of how a Snowflake is constructed](https://sxcu.net/assets/img/53fMTmLR4.png)\n## API error reference\nsxcu.net uses internal error codes and an HTTP status code of 400 for any API error, instead of per-error HTTP status codes. This gives us the ability to assign a unique code to each error, instead of having to reuse codes from a narrow selection of HTTP status codes.\nEach error code is specific to the endpoint it originates at, so there are some errors that have multiple error codes, but originate in different places.\n### Table of errors\nError | Message \n------|------------------------------------------------------------------------\n11 | Title not provided \n12 | Privacy setting not provided \n13 | Unlisted parameter not provided \n14 | value of 'unlisted' must be boolean \n15 | value of 'private' must be boolean \n16 | An error occoured while creating the collection, plese try again later \n17 | Title too long \n18 | Description too long \n19 | Rate limit exceeded \n31 | Subdomain not provided \n41 | Collection ID not provided \n42 | Collection token not provided \n43 | Rate limit exceeded \n44 | Value of 'unlised' must be boolean \n45 | Token mismatch \n46 | Collection not found \n51 | No 'link' parameter sent \n52 | URL parameter too long \n71 | Requested file not found \n72 | File ID not sent \n801 | File type not allowed \n802 | Upload error 101x \n803 | User-agent header not set \n804 | File is over the maximum file size limit \n805 | File is under the minimum file size limit \n806 | Malformed JSON in OpenGraph properties \n807 | og_properties object is too long \n808 | Subdomain is private, a valid upload token is required \n809 | No upload token \n810 | Invalid collection token \n811 | Collection is private, valid collection token must be provided \n812 | Collection not found \n813 | The file was not uploaded due to an unknown error \n814 | No file sent\n815 | Rate limit exceeded \n91 | No host parameter sent \n101 | Link not found \n102 | File not found \n103 | Missing object ID or deletion token\n104 | Rate limit exceeded\n301 | Collection not found\n302 | No collection ID provided \n## Rate Limits\nsxcu.net's API rate limits requests in order to prevent abuse and overload of our services. Rate limits are applied on a per-route basis (meaning they can be different for each route called) Not every endpoint has an endpoint-specific ratelimit. \n<br>\nBy \"per-route\", we mean that unique rate limits exist for the path you are accessing on our API, sometimes including the HTTP method (GET, POST) and including major parameters. This means that different HTTP methods (for example, both GET and POST) may share the same rate limit if the route is the same. Additionally, rate limits take into account major parameters in the URL. Currently, the only major parameters are file_id, collection_id, and link_id.\n<br> \n\"Per-route\" rate limits may be shared across multiple, similar-use routes (or even the same route with a different HTTP method). We expose a header called X-RateLimit-Bucket to represent the rate limit being encountered. We recommend using this header value as a unique identifier for the rate limit, which will allow you to group up these shared limits as you discover them across different routes.\n<br> \nBecause we may change rate limits at any time and rate limits can be different per application, rate limits should not be hard coded into your application. In order to properly support our dynamic rate limits, your application should parse for our rate limits in response headers and locally prevent exceeding the limits as they change. \n### Header Format\nFor every API request made, we return optional HTTP response headers containing the rate limit encountered during your request. \n#### Rate Limit Header Examples\n```text\nX-RateLimit-Limit: 5\nX-RateLimit-Remaining: 0\nX-RateLimit-Reset: 1626083167\nX-RateLimit-Bucket: abcd1234\n```\nX-RateLimit-Global \n Returned only on a HTTP 429 response if the rate limit headers returned are of the global rate limit (not per-route) \n<br>\nX-RateLimit-Limit \n The number of requests that can be made\n<br> \nX-RateLimit-Remaining \n The number of remaining requests that can be made\n<br> \nX-RateLimit-Reset \n Epoch time (seconds since 00:00:00 UTC on January 1, 1970) at which the rate limit resets\n<br> \nX-RateLimit-Reset-After \n Total time (in seconds) of when the current rate limit bucket will reset. Can have decimals to match previous millisecond ratelimit precision\n<br> \nX-RateLimit-Bucket \n A unique string denoting the rate limit being encountered (non-inclusive of major parameters in the route path) \n## Migrating from API v1\nThe new and old APIs have a few slight differences between them making them incompatible, any existing projects that use the old sxcu.net API would have to migrate before the old API gets completley removed.\n### API changes made in v2\n#### Global\nAll endpoints no longer return different status codes for different errors, instead they all return status code 400 with an error explaination in the response.\n#### Subdomains\n/api?action=domains \n URL changed to [/api/subdomains](#get-/subdomains) \n Field `img_views` changed to `file_views` \n[Added a new endpoint](#get-/subdomains/check/-subdomain-)\n#### Files\n/upload \n URL changed to [/api/files/create](#post-/files/create) \n `image` field changed to `file` \n<br> \nsxcu.net/{fileId}.json \n URL changed to [/api/files/{fileId}](#get-/files/-fileId-) \n Field `img_id` changed to `id` \n<br> \n/d/{fileId}/{deletionToken} -> URL changed to [/api/files/delete/{fileId}/{deletionToken}](#get-/files/delete/-fileId-/-deletionToken-) \n#### Collections\nsxcu.net/c/{collectionId}.json \n URL changed to [/api/collections/{collectionId}](#get-/collection/-collectionId-) \n Field `img_views` changed to `file_views` \n Field `images` changed to `files` \n<br>\nCollection creation endpoint URL changed to [/api/collections/create](#post-/collections/create) \nCollection edit endpoint URL changed to [/api/collections/edit/{collectionId}](#post-/collections/edit/-collectionId-) \n#### Links\n/shorten -> URL changed to [/api/links/create](#post-/links/create) \n/d/{linkId}/{deletionToken} -> URL changed to [/api/links/delete/{linkId}/{deletionToken}](#get-/links/delete/-linkId-/-deletionToken-)"},"host":"sxcu.net","basePath":"/api","tags":[{"name":"Files"},{"name":"Subdomains"},{"name":"Collections"},{"name":"Links"},{"name":"Text"}],"paths":{"/subdomains/check/{subdomain}":{"get":{"tags":["Subdomains"],"summary":"Check if subdomain exists","description":"Check if a subdomain is already regisetered on sxcu.net","operationId":"checkSubdomain","consumes":["text/plain; charset=utf-8"],"produces":["application/json"],"parameters":[{"name":"subdomain","in":"path","description":"The subdomain to check","required":true,"type":"string","x--nullable":false}],"responses":{"200":{"description":"","schema":{"type":"object","properties":{"exists":{"type":"boolean","description":"Whether the subdomain exists or not","x--optional":false,"x--nullable":false}}}},"400":{"description":"","schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","x--optional":false,"x--nullable":false},"code":{"type":"integer","description":"Error's internal code","x--optional":false,"x--nullable":false}}}}},"security":[]}},"/collections/{collectionId}":{"get":{"tags":["Collections"],"summary":"Get collection meta","description":"Returns meta info about a collection.","operationId":"getCollection","consumes":["text/plain; charset=utf-8"],"produces":["application/json"],"parameters":[{"name":"collectionId","in":"path","description":"The ID of the collection","required":true,"type":"snowflake","x--nullable":false}],"responses":{"200":{"description":"","schema":{"type":"object","properties":{"id":{"type":"snowflake","description":"Collection's ID","x--optional":false,"x--nullable":false},"title":{"type":"string","description":"Collection title","x--optional":false,"x--nullable":false},"desc":{"type":"string","description":"Collection description","x--optional":false,"x--nullable":false},"views":{"type":"integer","description":"Collection view count","x--optional":false,"x--nullable":false},"creation_time":{"type":"integer","format":"int64","description":"Unix timestamp of when the collection was created","x--optional":false,"x--nullable":false},"public":{"type":"boolean","description":"Whether the collection is public or not","x--optional":false,"x--nullable":false},"unlisted":{"type":"boolean","description":"Whether the collection is unlisted or not","x--optional":false,"x--nullable":false},"file_views":{"type":"integer","description":"Amount of views all of the files in the collection got","x--optional":false,"x--nullable":false},"files":{"type":"array","description":"Array of files in collection","x--optional":false,"x--nullable":false,"items":{"type":"object","properties":{"url":{"type":"string","format":"url","description":"URL of the file"},"thumb":{"type":"string","format":"url","description":"Thumbnail URL of the file"},"upload_time":{"type":"integer","format":"int64","description":"Time of upload of the file"},"views":{"type":"integer","description":"Views the file accumulated"}}}}}}},"400":{"description":"","schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","x--optional":false,"x--nullable":false},"code":{"type":"integer","description":"Error's internal code","x--optional":false,"x--nullable":false}}}}},"security":[]}},"/collections/create":{"post":{"tags":["Collections"],"summary":"Create a new collection","description":"","operationId":"createCollection","consumes":["application/x-www-form-urlencoded"],"produces":["application/json"],"parameters":[{"name":"title","in":"formData","description":"The title of the collection being created.","required":true,"type":"string","x--nullable":false,"maxLength":250},{"name":"desc","in":"formData","description":"Description of the collection being created","required":false,"type":"string","x--nullable":false,"maxLength":2000},{"name":"private","in":"formData","description":"Whether the collection should be private or not","required":true,"type":"boolean","x--nullable":false},{"name":"unlisted","in":"formData","description":"Whether the collection should be unlisted or not.","required":true,"type":"string","x--nullable":false}],"responses":{"200":{"description":"","schema":{"type":"object","properties":{"collection_id":{"type":"snowflake","description":"Collection's ID","x--optional":false,"x--nullable":false},"collection_token":{"type":"string","description":"Collection's upload token, will be present if `private` is set to `true` in the request","x--optional":true,"x--nullable":false}}}},"400":{"description":"","schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","x--optional":false,"x--nullable":false},"code":{"type":"integer","description":"Error's internal code","x--optional":false,"x--nullable":false}}}}},"security":[]}},"/files/create":{"post":{"tags":["Files"],"summary":"Upload new file","description":"Upload a new file to sxcu.net.<br>Max file size: 95 MB<br>Allowed file types: [png, gif, jpeg, ico, bmp, tiff, webm]","operationId":"createFile","consumes":["multipart/x-www-form-urlencoded"],"produces":["application/json"],"parameters":[{"name":"file","in":"formData","description":"The file to be uploaded","required":true,"type":"file","x--nullable":false},{"name":"token","in":"formData","description":"Subdomain's upload token","required":false,"type":"string","x--nullable":false},{"name":"collection_token","in":"formData","description":"Collection's upload token","required":false,"type":"string","x--nullable":false},{"name":"noembed","in":"formData","description":"If present, will make the API respond with a url directly to the file instead of its page","required":false,"type":"void","x--nullable":false},{"name":"og_properties","in":"formData","type":"string","description":"\nOpenGraph properties for this file. Example: <br>\n{ <br>\n \"color\":\"#7289DA\", <br>\n \"title\":\"Some title\", <br>\n \"description\":\"A cool description!\", <br>\n \"discord_hide_url\": false <br>\n}","required":false,"x--nullable":false,"maxLength":250}],"responses":{"200":{"description":"","schema":{"type":"object","properties":{"url":{"type":"string","format":"url","description":"URL to the created file","x--optional":false,"x--nullable":false},"del_url":{"type":"string","format":"url","description":"Deletion url for the created file","x--optional":false,"x--nullable":false},"thumb":{"type":"string","format":"url","description":"Thumbnail URL for the created file","x--optional":true,"x--nullable":false}}}},"400":{"description":"","schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","x--optional":false,"x--nullable":false},"code":{"type":"integer","description":"Error's internal code","x--optional":false,"x--nullable":false}}}}},"security":[]}},"/links/create":{"post":{"tags":["Links"],"summary":"Create a new link redirect","description":"","operationId":"createLink","consumes":["application/x-www-form-urlencoded"],"produces":["application/json"],"parameters":[{"name":"link","in":"formData","description":"The link to redirect.","required":true,"type":"string","format":"url","x--nullable":false,"maxLength":1500}],"responses":{"200":{"description":"","schema":{"type":"object","properties":{"url":{"type":"string","format":"url","description":"The created link","x--optional":false,"x--nullable":false},"del_url":{"type":"string","format":"url","description":"Deletion url for that link","x--optional":false,"x--nullable":false}}}},"400":{"description":"","schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","x--optional":false,"x--nullable":false},"code":{"type":"integer","description":"Error's internal code","x--optional":false,"x--nullable":false}}}}},"security":[]}},"https://cancer-co.de/upload":{"post":{"tags":["Text"],"summary":"Create a new cancer-co.de paste","description":"Create a new text document via cancer-co.de","operationId":"createText","consumes":["application/x-www-form-urlencoded"],"produces":["application/json"],"parameters":[{"name":"text","in":"formData","description":"Text to upload","required":true,"type":"string","x--nullable":false,"maxLength":8000000}],"responses":{"200":{"description":"","schema":{"type":"object","properties":{"url":{"type":"string","format":"url","description":"The created document","x--optional":false,"x--nullable":false},"del_url":{"type":"string","format":"url","description":"Deletion url for that document","x--optional":false,"x--nullable":false}}}},"400":{"description":"","schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","x--optional":false,"x--nullable":false},"code":{"type":"integer","description":"Error's internal code","x--optional":false,"x--nullable":false}}}}},"security":[]}},"/files/delete/{fileId}/{deletionToken}":{"get":{"tags":["Files"],"summary":"Delete file","description":"Delete a file from sxcu.net","operationId":"deleteFile","consumes":["text/plain; charset=utf-8"],"produces":["application/json"],"parameters":[{"name":"fileId","in":"path","description":"The ID of the file","required":true,"type":"snowflake","x--nullable":false},{"name":"deletionToken","in":"path","description":"The deletion token for the file","required":true,"type":"string","x--nullable":false}],"responses":{"200":{"description":"","schema":{"type":"object","properties":{"message":{"type":"string","description":"Success status message","x--optional":false,"x--nullable":false}}}},"400":{"description":"","schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","x--optional":false,"x--nullable":false},"code":{"type":"integer","description":"Error's internal code","x--optional":false,"x--nullable":false}}}}},"security":[]}},"/links/delete/{linkId}/{deletionToken}":{"get":{"tags":["Links"],"summary":"Delete link redirect","description":"Delete a link redirect from sxcu.net","operationId":"deleteLink","consumes":["text/plain; charset=utf-8"],"produces":["application/json"],"parameters":[{"name":"linkId","in":"path","description":"The ID of the link","required":true,"type":"snowflake","x--nullable":false},{"name":"deletionToken","in":"path","description":"The deletion token for the link","required":true,"type":"string","x--nullable":false}],"responses":{"200":{"description":"","schema":{"type":"object","properties":{"message":{"type":"string","description":"Success status message","x--optional":false,"x--nullable":false}}}},"400":{"description":"","schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","x--optional":false,"x--nullable":false},"code":{"type":"integer","description":"Error's internal code","x--optional":false,"x--nullable":false}}}}},"security":[]}},"https://cancer-co.de/d/{pasteId}/{deletionToken}":{"get":{"tags":["Text"],"summary":"Delete cancer-co.de paste","description":"Delete a paste from cancer-co.de","operationId":"deletePaste","consumes":["text/plain; charset=utf-8"],"produces":["application/json"],"parameters":[{"name":"pasteId","in":"path","description":"The ID of the paste","required":true,"type":"snowflake","x--nullable":false},{"name":"deletionToken","in":"path","description":"The deletion token for the paste","required":true,"type":"string","x--nullable":false}],"responses":{"200":{"description":"","schema":{"type":"object","properties":{"message":{"type":"string","description":"Success status message","x--optional":false,"x--nullable":false}}}},"400":{"description":"","schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","x--optional":false,"x--nullable":false},"code":{"type":"integer","description":"Error's internal code","x--optional":false,"x--nullable":false}}}}},"security":[]}},"/collections/edit/{collectionId}":{"post":{"tags":["Collections"],"summary":"Edit collection","description":"Edit collection properties","operationId":"editCollection","consumes":["multipart/x-www-form-urlencoded"],"produces":["application/json"],"parameters":[{"name":"collectionId","in":"path","description":"Collection's ID","required":true,"type":"snowflake","x--nullable":false},{"name":"collection_token","in":"formData","description":"Collection's token","required":true,"type":"string","x--nullable":false},{"name":"title","in":"formData","description":"Collection's new title","required":false,"type":"string","x--nullable":false,"maxLength":250},{"name":"desc","in":"formData","description":"Collection's new description","required":false,"type":"string","x--nullable":false,"maxLength":2000},{"name":"unlisted","in":"formData","type":"boolean","description":"Collection's new unlisted status","required":false,"x--nullable":false},{"name":"regen_token","in":"formData","type":"void","description":"If present, will re-assign the collection a new upload token, and return it in the response","required":false,"x--nullable":false},{"name":"empty_collection","in":"formData","type":"void","description":"If present, will disassociate all files in collection from it, leaving the collection empty","required":false,"x--nullable":false},{"name":"delete_collection","in":"formData","type":"void","description":"If present, will disassociate all files in collection from it, and delete the collection.","required":false,"x--nullable":false}],"responses":{"200":{"description":"","schema":{"type":"object","properties":{"success":{"type":"boolean","description":"Sent to avoid sending an empty body","x--optional":false,"x--nullable":false},"token":{"type":"string","description":"Collection's new token","x--optional":true,"x--nullable":false}}}},"400":{"description":"","schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","x--optional":false,"x--nullable":false},"code":{"type":"integer","description":"Error's internal code","x--optional":false,"x--nullable":false}}}}},"security":[]}},"/files/{fileId}":{"get":{"tags":["Files"],"summary":"Get file meta","description":"Returns meta info about a file.","operationId":"getFile","consumes":["text/plain; charset=utf-8"],"produces":["application/json"],"parameters":[{"name":"fileId","in":"path","description":"The ID of the file","required":true,"type":"snowflake","x--nullable":false}],"responses":{"200":{"description":"","schema":{"type":"object","properties":{"id":{"type":"snowflake","description":"Files's ID","x--optional":false,"x--nullable":false},"url":{"type":"string","format":"url","description":"File's public URL","x--optional":false,"x--nullable":false},"views":{"type":"integer","description":"File's view count","x--optional":false,"x--nullable":false},"viewable":{"type":"boolean","description":"Whether file can still be viewed or not","x--optional":false,"x--nullable":false},"collection":{"type":"snowflake","description":"ID of a collection the file is associated with","x--optional":false,"x--nullable":true},"size":{"type":"integer","format":"int64","description":"File size in bytes","x--optional":false,"x--nullable":false},"creation_time":{"type":"integer","format":"int64","description":"Unix timestamp of when the file was created","x--optional":false,"x--nullable":false},"og_properties":{"type":"array","description":"OpenGraph properties for this file","x--optional":true,"x--nullable":false,"items":{"type":"object","properties":{"color":{"type":"string","description":"OpenGraph HEX color code value","x--optional":true},"title":{"type":"string","description":"OpenGraph title value","x--optional":true},"description":{"type":"string","description":"OpenGraph description value","x--optional":true},"discord_hide_url":{"type":"boolean","description":"Whether to hide this file's url in Discord or not when sent","x--optional":true}}}}}}},"400":{"description":"","schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","x--optional":false,"x--nullable":false},"code":{"type":"integer","description":"Error's internal code","x--optional":false,"x--nullable":false}}}}},"security":[]}},"/subdomains":{"get":{"tags":["Subdomains"],"summary":"List subdomains","description":"","operationId":"listDomains","consumes":["text/plain; charset=utf-8"],"produces":["application/json"],"parameters":[],"responses":{"200":{"description":"","schema":{"type":"object","properties":{"domain":{"type":"string","description":"Subdomain name","x--optional":false,"x--nullable":false},"upload_count":{"type":"integer","format":"int32","description":"Number of files uploaded to this subdomain","x--optional":false,"x--nullable":false},"public":{"type":"boolean","description":"Whether it's public or not","x--optional":false,"x--nullable":false},"file_views":{"type":"integer","format":"int64","description":"Number of file views on this subdomain","x--optional":false,"x--nullable":false}}}},"400":{"description":"","schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","x--optional":false,"x--nullable":false},"code":{"type":"integer","description":"Error's internal code","x--optional":false,"x--nullable":false}}}}},"security":[]}}}}