Difference between revisions of "API Docs/Ratings"

From SponsorBlock
Jump to navigation Jump to search
(clarify optional types)
(deprecation notice)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''POST <code>/api/ratings/rate</code>'''
<big>'''Warning: Development of this API is stalled and may not continue'''</big>


Add user's rating to the video
Public API is available at https://sponsor.ajay.app.
 
'''Input''' (URL Parameters)<syntaxhighlight lang="ts">
{
  videoID: string
  userID: string, // Local UserID
  service: string, // Default YouTube - See refereneces
  type: int, // Rating type - See references
  enabled: boolean // Default true - if rating should count - set to false to undo vote
}
</syntaxhighlight>References: [[Types#service]], [[Types#Rating Types]]


'''Response'''<syntaxhighlight lang="ts">
'''GET <code>/api/ratings/rate/:sha256HashPrefix</code>'''
{
  Nothing (Status Code 200)
}
</syntaxhighlight>'''Error Codes'''


400: Bad Request (Your inputs are wrong/impossible)
'''GET''' '''<code>/api/ratings/rate</code>'''
----'''GET <code>/api/ratings/rate/:sha256HashPrefix</code>'''


Get rating of a video with extra privacy
Get rating of a video with extra privacy


<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.
<code>sha256HashPrefix</code> is a prefix of the 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.


'''Input''' (URL Parameters)<syntaxhighlight lang="ts">
'''Input''' (URL Parameters)<syntaxhighlight lang="ts">
{
{
   prefix: string, // alternative to path
   prefix: string, // alternative to path, can be repeated for bulk fetching (Max 75)
   type: int, // Optional: Rating type - default 1 and 0 - can be repeated for multiple types
   type: int, // Optional: Rating type - default 1 and 0 - can be repeated for multiple types
   types: [int], // Optional: Array of rating types
   types: [int], // Optional: Array of rating types
Line 44: Line 29:


404: No ratings for that type + videoID combination exist
404: No ratings for that type + videoID combination exist
----'''POST <code>/api/ratings/rate</code>'''
Add user's rating to the video
'''Input''' (URL Parameters)<syntaxhighlight lang="ts">
{
  videoID: string
  userID: string, // Local UserID
  service: string, // Default YouTube - See refereneces
  type: int, // Rating type - See references
  enabled: boolean // Default true - if rating should count - set to false to undo vote
}
</syntaxhighlight>References: [[Types#service]], [[Types#Rating Types]]


'''Response'''<syntaxhighlight lang="ts">
{
  Nothing (Status Code 200)
}
</syntaxhighlight>'''Error Codes'''
400: Bad Request (Your inputs are wrong/impossible)
=== VIP Calls ===
=== VIP Calls ===



Latest revision as of 19:50, 24 January 2022

Warning: Development of this API is stalled and may not continue

Public API is available at https://sponsor.ajay.app.

GET /api/ratings/rate/:sha256HashPrefix

GET /api/ratings/rate

Get rating of a video with extra privacy

sha256HashPrefix is a prefix of the hash of the YouTube videoID. 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.

Input (URL Parameters)

{
  prefix: string, // alternative to path, can be repeated for bulk fetching (Max 75)
  type: int, // Optional: Rating type - default 1 and 0 - can be repeated for multiple types
  types: [int], // Optional: Array of rating types
}

Response

[{ // Array of this object
   videoID: string,
   hash: string, // Full hash of the videoID
   type: int, // Type of rating
   count: int // Number of ratings of this type
}]

Error Codes

400: Bad Request (Your inputs are wrong/impossible)

404: No ratings for that type + videoID combination exist


POST /api/ratings/rate

Add user's rating to the video

Input (URL Parameters)

{
  videoID: string
  userID: string, // Local UserID
  service: string, // Default YouTube - See refereneces
  type: int, // Rating type - See references
  enabled: boolean // Default true - if rating should count - set to false to undo vote
}

References: Types#service, Types#Rating Types Response

{
  Nothing (Status Code 200)
}

Error Codes

400: Bad Request (Your inputs are wrong/impossible)

VIP Calls

POST /api/ratings/clearCache

Clear redis cache for video.

Input (Request Body):

{
  userID: string, // Local userID
  videoID: string
}

Response:

{
  Cache cleared on video videoID (status code 200)
}

Error codes:

400: Bad Request (Your inputs are wrong/impossible)

403: Unauthorized (You are not a VIP)