https://wiki.sponsor.ajay.app/api.php?action=feedcontributions&user=%D0%A1%D0%BD%D0%B5%D0%B6%D0%B0%D0%BD%D0%B0&feedformat=atom
SponsorBlock - User contributions [en-ca]
2024-03-29T10:22:54Z
User contributions
MediaWiki 1.41.0
https://wiki.sponsor.ajay.app/index.php?title=API_Docs&diff=894
API Docs
2022-02-12T04:45:13Z
<p>Снежана: </p>
<hr />
<div><!-- Formatting Notes:<br />
<br />
userID instead of user ID<br />
leave a space after the start of the comment, <br />
public userID & local userID --><br />
If you end up using the API, I'd love to know about how you're using it. Tell me about it by making a GitHub issue or emailing me :)<br />
<br />
The API and database follow [https://github.com/ajayyy/SponsorBlock/wiki/Database-and-API-License this license] unless you have explicit permission. [https://gist.github.com/ajayyy/4b27dfc66e33941a45aeaadccb51de71 Attribution Template]<br />
<br />
Public API available at https://sponsor.ajay.app. <br />
<br />
<sub>While this is a free unlimited use API, please don't abuse it. I have limited resources.</sub><br />
<br />
Database download: https://sponsor.ajay.app/database<br />
<br />
'''Libraries''': [https://www.npmjs.com/package/sponsorblock-api Node.js], [https://github.com/wasi-master/sponsorblock.py Python], [https://crates.io/crates/sponsor-block Rust]<br />
-----Online Database Explorer (By Lartza): https://sb.ltn.fi/<br />
<br />
Database Mirror (5 min update time, provided by Lartza): https://sb.ltn.fi/database/<br />
<br />
<sub>[https://sponsor.ajay.app/database Database Dump] | [https://github.com/ajayyy/SponsorBlock/wiki/Webhooks Webhook Docs] | [https://github.com/mchangrh/sb-openapi OpenAPI Docs]</sub> <br />
-----<br />
====='''GET''' <code>/api/skipSegments</code>=====<br />
Get segments for a video.<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
videoID: string,<br />
<br />
category: string, // Optional, defaults to "sponsor", can be repeated for multiple categories. [1]<br />
// OR<br />
categories: string[], // Optional [1]<br />
<br />
requiredSegment: string, // Segment UUID to require to be retrieved, even if they don't meet the minimum vote threshold. Can be repeated for multiple segments.<br />
// OR<br />
requiredSegments: string[], // Optional, array of required segment UUIDs<br />
<br />
actionType: string // Optional, default skip. Can be repeated for multiple types. [3]<br />
// OR <br />
actionTypes: string[] // Optional, array of action types<br />
<br />
service: string, // Optional, default is 'YouTube' [2]<br />
}<br />
</syntaxhighlight><br />
<br />
References: <ref name=":0">See [[Types]] for full list of possible categories. To get multiple, create an array with the format <code>["sponsor", intro"]</code>. </ref> <ref name=":1">Service to get segments for. See [https://wiki.sponsor.ajay.app/w/Types#service Types] for supported services</ref> <ref name=":2">Action Types: See [[Types]] for possible values. Select multiple with the format <code>["skip","mute]</code></ref><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
[{ // Array of this object<br />
segment: float[], //[0, 15.23] start and end time in seconds<br />
UUID: string,<br />
category: string,<br />
videoDuration: float // Duration of video when submission occurred (to be used to determine when a submission is out of date). 0 when unknown. +- 1 second<br />
actionType: string // actionType [3]<br />
userID: string, // public userID of submitter<br />
locked: int, // if submission is locked<br />
votes: int, // Votes on segment<br />
description: string, // unused<br />
}]<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
404: Not Found<br />
-----<br />
====='''GET''' <code>/api/skipSegments/:sha256HashPrefix</code>=====<br />
Get segments for a video with extra privacy<br />
<br />
<code>sha256HashPrefix</code> is a hash of the YouTube <code>videoID</code>. It should be the first 4 - 32 characters (4 is recommended). This provides extra privacy by potentially finding more than just the video you are looking for since the server will not know exactly what video you are looking for.<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
prefix: string, // Can be used instead of path<br />
<br />
category: string, // Optional, defaults to "sponsor", can be repeated for multiple categories. [1]<br />
// OR<br />
categories: string[], // Optional, array of categories [1]<br />
<br />
requiredSegment: string, // Segment UUID to require to be retrieved, even if they don't meet the minimum vote threshold. Can be repeated for multiple segments.<br />
// OR<br />
requiredSegments: string[], // Optional, array of required segment UUIDs<br />
<br />
actionType: string // Optional, default skip. Can be repeated for multiple types. [3]<br />
// OR <br />
actionTypes: string[] // Optional, array of action types [3]<br />
<br />
service: string // Optional, default is 'YouTube'. [2]<br />
}<br />
</syntaxhighlight><br />
<br />
References: <ref name=":0" /> <ref name=":1" /> <ref name=":2" /><br />
<br />
'''Response'''<br />
<syntaxhighlight lang="ts"><br />
[{ // Array of this object<br />
videoID: string,<br />
hash: string, // Full hash of the videoID<br />
segments: [{ // Array of this object<br />
segment: float[], // [0, 15.23] start and end time in seconds<br />
UUID: string,<br />
category: string, [1]<br />
actionType: string, // [1]<br />
locked: int, // if segment is locked<br />
votes: int, // votes on segment<br />
videoDuration: int, // Duration of video when submissions occurred<br />
userID: string, // Public userID of submitter<br />
description: string // unused<br />
}]<br />
}]<br />
</syntaxhighlight><br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
404: Not Found<br />
-----<br />
====='''POST''' <code>/api/skipSegments</code>=====<br />
Create a segment on a video<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
videoID: string,<br />
startTime: float,<br />
endTime: float,<br />
category: string, // [1]<br />
userID: string, // This should be a randomly generated UUID stored locally (not the public one)<br />
userAgent: string, // "Name of Client/Version" or "[BOT] Name of Bot/Version" ex. "Chromium/1.0.0"<br />
service: string, // Optional, default is 'YouTube'. [2]<br />
videoDuration: float, // Optional, duration of video, will attempt to retrieve from the YouTube API if missing (to be used to determine when a submission is out of date)<br />
actionType: string // Optional, default is "skip". [3]<br />
}<br />
</syntaxhighlight><br />
<br />
References: <ref name=":0" /> <ref name=":1" /> <ref name=":2" /><br />
<br />
'''OR'''<br />
<br />
'''Input''' (JSON Body):<br />
<syntaxhighlight lang="ts"><br />
{<br />
videoID: string,<br />
userID: string, // This should be a randomly generated UUID stored locally (not the public one)<br />
userAgent: string, // "Name of Client/Version" or "[BOT] Name of Bot/Version" ex. "Chromium/1.0.0"<br />
service: string, // Optional, default is 'YouTube'.[2]<br />
videoDuration: float, // Optional, duration of video, will attempt to retrieve from the YouTube API if missing (to be used to determine when a submission is out of date)<br />
<br />
segments: [{ // Array of this object<br />
segment: float[], // [0, 15.23] start and end time in seconds<br />
category: string, // [1]<br />
actionType: string // Optional, defaults to "skip". [3]<br />
}]<br />
}<br />
</syntaxhighlight><br />
<br />
References: <ref name=":0" /> <ref name=":1" /> <ref name=":2" /><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{ // array of this object<br />
UUID: string, // UUID of submitted segment<br />
category: string, // submitted category [1]<br />
segment: float[] // start and end time of submitted segment<br />
}[]<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
403: Rejected by auto moderator (Reason will be sent in the response)<br />
<br />
429: Rate Limit (Too many for the same user or IP)<br />
<br />
409: Duplicate<br />
-----<br />
====='''POST''' <code>/api/voteOnSponsorTime</code>=====<br />
Vote on a segment or vote to change the category of the segment.<br />
<br />
Creators of the segment and VIPs can remove the segment or change the category with only one vote.<br />
<br />
<div class="toccolours mw-collapsible mw-collapsed" style="width:400px;"><br />
<div style="font-weight:bold;">VIP voting notes</div><br />
<div class="mw-collapsible-content"><br />
VIP upvotes will:<br />
* lock the segment<br />
* remove "hidden" property<br />
* remove "shadowHidden" property<br />
</div></div><br />
<br />
'''Input: Normal Vote''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
UUID: string, // UUID of the segment being voted on<br />
userID: string, // Local userID<br />
type: int // 0 for downvote, 1 for upvote, 20 to undo vote<br />
}<br />
</syntaxhighlight><br />
<br />
'''OR'''<br />
<br />
'''Input: Category Vote''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
UUID: string, // UUID of the segment being voted on<br />
userID: string, // Local userID<br />
category: string // Category to change this submission to [1]<br />
} </syntaxhighlight><br />
<br />
References: <ref name=":0" /><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
Nothing (status code 200)<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
403: Reason given in request (moderation)<br />
-----<br />
<br />
====='''POST''' <code>/api/viewedVideoSponsorTime</code>=====<br />
Add view to segment<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
UUID: string // UUID of segment viewed<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
Nothing (status code 200)<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
-----<br />
====='''GET''' <code>/api/userInfo</code>=====<br />
Get information about a user<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
userID: string // local UserID<br />
// OR<br />
publicUserID: string // Public userID<br />
<br />
values: string[] // Optional, Values to get from userInfo<br />
// default values are<br />
// ["userID", "userName", "minutesSaved", "segmentCount", "ignoredSegmentCount",<br />
// "viewCount", "ignoredViewCount", "warnings", "warningReason", "reputation",<br />
// "vip", "lastSegmentID"]<br />
// OR<br />
value: string // Optional, Value to get from userInfo, can be repeated for multiple values<br />
}<br />
</syntaxhighlight><br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
userID: string, // Public userID<br />
userName: string, // Public userID if not set<br />
minutesSaved: float, // Minutes saved<br />
segmentCount: int, // Total number of segments excluding ignored/ hidden segments<br />
ignoredSegmentCount: int, // Total number of ignored/ hidden segments<br />
viewCount: int, // Total number of views excluding view on ignored/ hidden segments<br />
ignoredViewCount: int, // Total number of view on ignored/ hidden segments<br />
warnings: int, // Currently enabled warnings<br />
reputation: float, <br />
vip: int, // VIP status<br />
lastSegmentID: string // UUID of last submitted segment<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
-----<br />
====='''GET''' <code>/api/userStats</code>=====<br />
<br />
Get stats for a user<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
userID: string // local UserID<br />
// OR<br />
publicUserID: string // Public userID<br />
<br />
fetchCategoryStats: boolean // default false, display category stats<br />
fetchActionTypeStats: boolean // default false, display type stats<br />
}<br />
</syntaxhighlight><br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
userID: string // hashed userID<br />
userName: string // userName<br />
overallStats: {<br />
minutesSaved: integer // same as userInfo<br />
segmentCount: integer // same as userInfo<br />
}<br />
// IF CHOSEN<br />
categoryCount: { // # of segments per category<br />
sponsor: integer<br />
intro: integer<br />
outro: integer<br />
interaction: integer<br />
selfpromo: integer<br />
music_offtopic: integer<br />
preview: integer<br />
poi_highlight: integer<br />
filler: integer,<br />
exclusive_access: integer<br />
}<br />
// IF CHOSEN<br />
actionTypeCount: { // # of segments per type<br />
skip: integer,<br />
mute: integer,<br />
full: integer,<br />
poi: integer<br />
}<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
-----<br />
====='''GET''' <code>/api/getViewsForUser</code>=====<br />
Get the number of views a user has on all their segments<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
userID: string // Local userID<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="js"><br />
{<br />
viewCount: int<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
404: Not Found<br />
-----<br />
====='''GET''' <code>/api/getSavedTimeForUser</code>=====<br />
Get the total time saved from all the user's segments<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
userID: string // Local userID<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
timeSaved: float // In minutes<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
404: Not Found<br />
-----<br />
====='''POST''' <code>/api/setUsername</code>=====<br />
Set a username for a userID<br />
<br />
'''Input''' (URL Parameters): Setting username for self<br />
<syntaxhighlight lang="ts"><br />
{<br />
userID: string, // Local userID<br />
username: string, // Optional<br />
}<br />
</syntaxhighlight><br />
<br />
'''OR'''<br />
<br />
'''Input''' (URL Parameters): Setting username as '''admin'''<syntaxhighlight lang="ts"><br />
{<br />
userID: string, // Public userID<br />
username: string, // Optional<br />
adminUserID: string // Admin's local userID<br />
}<br />
</syntaxhighlight>'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
Nothing (status code 200)<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
403: Unauthorized (You are not an admin)<br />
-----<br />
====='''GET''' <code>/api/getUsername</code>=====<br />
Get current username<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
userID: string // Local userID<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
userName: string // Public userID if no username has been set<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
-----<br />
====='''GET''' <code>/api/segmentInfo</code>=====<br />
Get information about segments<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
// Only the first 10 entries will be processed<br />
UUID: string, // Can be repeated for multiple segments<br />
// OR<br />
UUIDs: string[] // Looks like ["a...0", "b...1"]<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
[{ // Array of this object<br />
videoID: string,<br />
startTime: float,<br />
endTime: float,<br />
votes: int,<br />
locked: int, // Status of lock - If upvoted by a VIP, the segment is locked<br />
UUID: string,<br />
userID: string, // PublicID of submitter<br />
timeSubmitted: int,<br />
views: int, // Number of reported views on the segment<br />
category: string, // [1]<br />
service: string, // [2]<br />
videoDuration: int,<br />
hidden: int, // If the segment has 2 downvotes or was downvoted by a VIP<br />
reputation: int, // Reputation of submitter at time of submission<br />
shadowHidden: int, // If the submitter is shadowbanned<br />
userAgent: string // userAgent of the submitter,<br />
actionType: string // [3]<br />
}]<br />
</syntaxhighlight><br />
<br />
References: <ref name=":0" /> <ref name=":1" /> <ref name=":2" /><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
404: Not Found<br />
-----<br />
====='''GET''' <code>/api/userID</code>=====<br />
List all users matching the username search<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
username: string, // search string for username<br />
// case sensitive<br />
// minimum for non-exact search is 3 characters, maximum is 64 characters<br />
exact: boolean // searches for exact username with no wildcard at end<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
[{ // Array of this object - maximum 10 results<br />
userName: string,<br />
userID: string<br />
}]<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible) or exceed the character limits<br />
<br />
404: Not Found<br />
-----<br />
====='''GET''' <code>/api/lockCategories</code>=====<br />
Get locked categories for a video<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
videoID: string,<br />
actionTypes: string[] // [3]<br />
// default [skip, mute]<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
categories: string[], // [1]<br />
reason: string, // Specified reason for the lock<br />
// Only the most recent reason will be returned<br />
actionTypes: string[] // [3]<br />
}<br />
</syntaxhighlight><br />
<br />
References: <ref name=":0" /> <ref name=":2" /><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
404: Not Found<br />
-----<br />
====='''GET''' <code>/api/lockCategories/:sha256HashPrefix</code>=====<br />
Get locked categories for a video with extra privacy<br />
<br />
<code>sha256HashPrefix</code> is a hash of the YouTube <code>videoID</code>. It should be the first 4 - 32 characters (4 is recommended). This provides extra privacy by potentially finding more than just the video you are looking for. This makes the server not know exactly what video you are looking for.<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
prefix: sha256HashPrefix // Optional if not sent through path<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
[{ // Array of this object<br />
videoID: string,<br />
hash: string, // The full hash of the videoID<br />
categories": string[], // [1]<br />
reason: string // Specified reason for the lock<br />
}]<br />
</syntaxhighlight><br />
<br />
References: <ref name=":0" /><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
404: Not Found<br />
-----<br />
====='''GET''' <code>/api/lockReason</code>=====<br />
Get reason for lock(s)<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
videoID: string<br />
<br />
// Categories to get reasons for, defaults to all [1]<br />
category: string<br />
// OR<br />
categories: string[],<br />
actionTypes: string[] // [3]<br />
}<br />
</syntaxhighlight><br />
<br />
References: <ref name=":0" /> <ref name=":2" /><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
[{ // Array of this object<br />
category: string, // category [1]<br />
locked: integer, // status of lock<br />
reason: string, // reason for lock<br />
userID: string, // publicID of locking VIP<br />
userName: string // username of locking VIP<br />
}]<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
-----<br />
====='''GET''' <code>/api/searchSegments</code>=====<br />
Get all segments of a video based on specified filters. Note: It is suggested that you don't use this for knowing which segments to skip on your client, as thresholds and values that determine which segments are the best change over time. Using [https://wiki.sponsor.ajay.app/index.php/API_Docs#GET_.2Fapi.2FskipSegments /api/skipSegments] ensures that you will always get the best segments.<br />
<br />
'''Input''' (URL Parameters) '''OR''' (JSON Body):<br />
<syntaxhighlight lang="ts"><br />
{<br />
// See skipSegments<br />
videoID: string<br />
<br />
category: string // [1]<br />
// OR<br />
categories: string[]<br />
<br />
actionType: string // [3]<br />
// OR<br />
actionTypes: string[]<br />
<br />
service: string // [2]<br />
// End SkipSegments<br />
<br />
page: int // Page to start from (default 0)<br />
<br />
// Vote/ view thresholds, inclusive, default includes all segments<br />
minVotes: int<br />
maxVotes: int<br />
<br />
minViews: int<br />
maxViews: int<br />
<br />
// Default true - if false, don't show segments that match type<br />
locked: boolean<br />
hidden: boolean<br />
ignored: boolean // hidden or below vote threshold<br />
}<br />
</syntaxhighlight><br />
<br />
References: <ref name=":0" /> <ref name=":1" /> <ref name=":2" /><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
segmentCount: int, // Total number of segments matching query<br />
page: int, // Page number<br />
segments: [{ // Array of this object, max 10<br />
// see segmentInfo<br />
UUID: string,<br />
timeSubmitted: int,<br />
startTime: int,<br />
endTime: int,<br />
category: int, // [1]<br />
actionType: int, // [3]<br />
votes: int,<br />
views: int,<br />
locked: int,<br />
hidden: int,<br />
shadowHidden: int,<br />
userID: string, // UUID of submitter<br />
}]<br />
}<br />
</syntaxhighlight><br />
<br />
References: <ref name=":0" /> <ref name=":2" /><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
404: Not Found<br />
<br />
-----<br />
====='''GET''' <code>/api/status/:value</code>=====<br />
Get status of server<br />
<br />
'''Input:''' (URL path)<br />
<br />
Can be any key value in response, requests without path will return all values.<br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
uptime: int, // Uptime of server in seconds<br />
commit: string, // Full SHA hash of latest git commit, development or test<br />
db: int, // Current database version<br />
startTime: int, // Unix time that request was received<br />
processTime: int, // Seconds between startTime and sending response<br />
loadavg: int[], // 5 and 15 minute loadavg<br />
statusRequests: int // number of /status requests in the last minute<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
404: Not Found<br />
-----<br />
===Stats Calls===<br />
====='''GET''' <code>/api/getTopUsers</code>=====<br />
Get top submitters<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
sortType: int<br />
// 0 for by minutes saved<br />
// 1 for by view count<br />
// 2 for by total submissions<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
userNames: string[],<br />
viewCounts: int[],<br />
totalSubmissions: int[],<br />
minutesSaved: float[]<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
-----'''GET''' <code>/api/getTopCategoryUsers</code><br />
<br />
Get top submitters by category<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
sortType: int,<br />
// 0 for by minutes saved<br />
// 1 for by view count<br />
// 2 for by total submissions<br />
category: string // category to fetch stats for<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
userNames: string[],<br />
viewCounts: int[],<br />
totalSubmissions: int[],<br />
minutesSaved: float[]<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
-----<br />
====='''GET''' <code>/api/getTotalStats</code>=====<br />
Get total stats<br />
<br />
'''Input''' (URL Parameters):<br />
<br />
<syntaxhighlight lang="ts"><br />
{<br />
countContributingUsers: boolean // Optional, default false<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
userCount: int, // Only if countContributingUsers was true<br />
activeUsers: int, // Sum of public install stats from Chrome webstore and Firefox addons store<br />
apiUsers: int, // 48-hour active API users (https://github.com/ajayyy/PrivacyUserCount)<br />
viewCount: int,<br />
totalSubmissions: int,<br />
minutesSaved: float<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
None<br />
-----<br />
====='''GET''' <code>/api/getDaysSavedFormatted</code>=====<br />
Get days saved by all skips<br />
<br />
'''Input''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
Nothing<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
daysSaved: float (2 decimal places)<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
None<br />
-----<br />
===VIP Calls===<br />
These can only be called by the users added to the VIP table.<br />
====='''GET''' <code>/api/isUserVIP</code>=====<br />
If the user is a VIP<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
userID: string, // Local userID<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
hashedUserID: string, // Public userID<br />
vip: boolean<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
-----<br />
====='''POST''' <code>/api/lockCategories</code>=====<br />
Create a category lock on the video, disallowing further submissions for that category<br />
<br />
'''Input''' (Request Body):<br />
<syntaxhighlight lang="ts"><br />
{<br />
videoID: string,<br />
userID: string, // Local userID<br />
categories: string[], // [1]<br />
actionTypes: string[], // [3]<br />
reason: string, // Reason for lock<br />
}<br />
</syntaxhighlight><br />
<br />
References: <ref name=":0" /> <ref name=":2" /><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
submitted: string, // categories<br />
submittedValues: {<br />
actionType: actionType,<br />
category: category<br />
} // array of this object<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
403: Unauthorized (You are not a VIP)<br />
-----<br />
===== '''DELETE''' <code>/api/lockCategories</code>=====<br />
Delete existing category locks on that video<br />
<br />
'''Input''' (Request Body):<br />
<syntaxhighlight lang="ts"><br />
{<br />
videoID: string,<br />
userID: string, // Local userID<br />
categories: string[] // [1]<br />
}<br />
</syntaxhighlight><br />
<br />
References: <ref name=":0" /><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
message: "Removed lock categories entrys for video videoID"<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
403: Unauthorized (You are not a VIP)<br />
-----<br />
====='''POST''' <code>/api/shadowBanUser</code>=====<br />
Shadow banned submissions are hidden for everyone but the IP that originally submitted it. Shadow banning a user shadow bans all future submissions.<br />
<br />
User can be re-shadowbanned if segments were not previously hidden<br />
<br />
'''Input''' (URL Parameters):<br />
<syntaxhighlight lang="ts"><br />
{<br />
userID: string, // Public userID of the user you want to shadowBan<br />
adminUserID: string, // Local userID of VIP or Admin<br />
enabled: boolean, // Optional, default true, enable or disable ban<br />
unHideOldSubmissions: boolean, // Optional, should all previous submissions be banned as well?<br />
categories: string // Optional, defaults to all categories, in the format "["sponsor", "selfpromo"]" etc...<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
Nothing (status code 200)<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
403: Unauthorized (You are not a VIP)<br />
<br />
409: Duplicate (User already shadowbanned & unHideOldSubmissions not changed)<br />
-----<br />
===== '''POST''' <code>/api/warnUser</code>=====<br />
Temporary ban that shows a warning asking them to contact us.<br />
<br />
If a user is re-warned but there is still a non-expired warning, it is reenabled<br />
<br />
'''Input''' (Request Body):<br />
<syntaxhighlight lang="ts"> {<br />
issuerUserID: string, // Issuer userID (Local userID)<br />
userID: string, // Public userID you are warning<br />
enabled: boolean // Optional, default true<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
Nothing (status code 200)<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
403: Unauthorized (You are not a VIP)<br />
<br />
409: User already warned<br />
-----<br />
====='''POST''' <code>/api/clearCache</code>=====<br />
Clear redis cache for video.<br />
<br />
'''Input''' (Request Body):<br />
<syntaxhighlight lang="ts"><br />
{<br />
userID: string, // Local userID<br />
videoID: string<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
Cache cleared on video videoID (status code 200)<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
403: Unauthorized (You are not a VIP)<br />
-----<br />
====='''POST''' <code>/api/purgeAllSegments</code>=====<br />
Hide all segments on a video without affecting submitters' reputation<br />
<br />
'''Input''' (Request Body):<br />
<syntaxhighlight lang="ts"><br />
{<br />
userID: string, // Local userID<br />
videoID: string,<br />
service: string // Service of video, defaults to YouTube<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
Nothing (status code 200)<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
403: Unauthorized (You are not a VIP)<br />
-----<br />
====='''POST''' <code>/api/segmentShift</code>=====<br />
Shift all segments on a video<br />
<br />
'''Input''' (Request Body):<br />
<syntaxhighlight lang="ts"><br />
{<br />
videoID: string,<br />
userID: string, // Local userID<br />
startTime: float,<br />
endTime: float<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
Nothing (status code 200)<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
403: Unauthorized (You are not a VIP) <br />
-----<br />
====='''POST''' <code>/api/addUserAsTempVIP</code>=====<br />
Add temporary 24 Hour Channel VIP<br />
<br />
A user cannot be a VIP of multiple channels, the most recent channel will take precedence and override <br />
<br />
'''Input''' (Request Body):<br />
<syntaxhighlight lang="ts"><br />
{<br />
userID: string, // User to grant temp VIP to<br />
adminUserID: string, // Local userID of existing VIP<br />
channelVideoID: string, // videoID of channel to grant VIP on<br />
enabled: string // default "true" Enable or disable VIP status<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
Temp VIP added on channel channelName (status code 200)<br />
Temp VIP removed (status code 200)<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
403: Unauthorized (You are not a VIP) <br />
<br />
404: Not Found (No channel found for videoID) <br />
<br />
409: Duplicate (User is already a permanent VIP) <br />
-----<br />
===Admin Calls===<br />
These can only be called by the server administrator, set in the config.<br />
====='''POST''' <code>/api/addUserAsVIP</code>=====<br />
VIPs have extra privileges and their votes count more.<br />
<br />
'''Input''' (Request Body):<br />
<syntaxhighlight lang="ts"><br />
{<br />
userID: string, // Public userID of the user you want to add to the VIP list<br />
adminUserID: string, // Admin's local userID<br />
enabled: boolean // Optional, to be able to add and remove users<br />
}<br />
</syntaxhighlight><br />
<br />
'''Response''':<br />
<syntaxhighlight lang="ts"><br />
{<br />
Nothing (status code 200)<br />
}<br />
</syntaxhighlight><br />
<br />
'''Error codes''':<br />
<br />
400: Bad Request (Your inputs are wrong/impossible)<br />
<br />
403: Unauthorized (You are not an admin)<br />
-----<br />
===Legacy API===<br />
https://github.com/ajayyy/SponsorBlock/wiki/Legacy-API<br />
===Local userID vs Public userID===<br />
The local userID should be a randomly generated and saved client side and must be 32 characters (or more). If it is not 32 characters or more, you will not be able to vote or submit. The public userID is what is used as an identifier in the database. This is the local userID with a SHA 256 hash 5000 times.<br />
<br />
=== References ===<br />
<references /><br />
__INDEX__<br />
__NEWSECTIONLINK__</div>
Снежана