Piped icon indicating copy to clipboard operation
Piped copied to clipboard

API Documentation

Open peepo5 opened this issue 4 years ago • 14 comments
trafficstars

(edit: read below two comments) Will there ever be api support so apps can use the Piped Extraction? Invidious has api support and services like FreeTube cannot interact with it unless it is through the UI.

  • thanks.

peepo5 avatar Aug 29 '21 12:08 peepo5

There is API, but it's currently undocumented, it's something that has to be done. The official client (this repository) uses it.

The list of API instances can be found at https://github.com/TeamPiped/Piped/wiki/Instances

FireMasterK avatar Sep 02 '21 14:09 FireMasterK

OK. So this issue is now based around documenting the API.

peepo5 avatar Sep 02 '21 19:09 peepo5

Some basic documentation for the Streams API has been added, let me know what you think about it: https://piped-docs.kavin.rocks/docs/api-documentation/, I'll be adding the remaining within the next few days hopefully.

~~The comments/description for the fields look a bit odd, but that can be fixed hopefully.~~ Fixed.

FireMasterK avatar Sep 03 '21 16:09 FireMasterK

@FireMasterK

documentatoin

peepo5 avatar Sep 03 '21 16:09 peepo5

Whoops, that's fixed now!

FireMasterK avatar Sep 03 '21 16:09 FireMasterK

More API documentation has been added, precisely comments, trending, playlists, search suggestions, and sponsors/SponsorBlock.

The Search API is subject to a lot of changes, so that will be added later.

Are you interested in the private/authenticated API too? If not, I will defer the writing of documentation for that.

FireMasterK avatar Sep 04 '21 14:09 FireMasterK

I mean yes it would be useful for authenticated use. Would make sense so more people can interact with this project.

peepo5 avatar Sep 04 '21 15:09 peepo5

This just some notes I found when I was trying to implement your API in my script

# Trending 
	api : ${PIPEDAPI_URL}/trending?region={query}
	- support select region: use region as query					
	- region parameter is necessary, use US if empty				
	- region parameter need to be a valide ISO 3166-1 codes, 		
	- not all ISO 3166-1 codes are supported,fallback to US			
	- don't support pagination , mark first page as the last page	
# Search 
	api : ${PIPEDAPI_URL}/search?q={query}&filter=videos
	- support pagination, use nextpagequery							
	- last page indicator is "nextpage=null"						
	- nexpage search api is different from search api				
	- need to encode {nextpage}										
	nextpagequery = "search/?nextpage={nextpage}&q={query}&filter=videos"
# URL Handler
## */channel/*, */c/*, */user/*  
	api : ${PIPEDAPI_URL}/{type}/{channelid}
	- don't support search query						 
	- support pagination, use nextpagequery				 
	- last page indicator is "nextpage=null"			 
	- nexpage channel api is different from search api	 
	- need to extract channelid from api for /c/, /user/ 
	- channelid only available in first page			 
	nextpagequery = "channel/{channelid}/?nextpage={nextpage}"
## *"/playlist?list="*  		   
	api : ${PIPEDAPI_URL}/playlists/{playlistid}
	- don't support search query						 
	- support pagination, use nextpagequery				 
	- last page indicator is "nextpage=null"			 
	- nexpage playlist api is different from search api  
	nextpagequery = "playlists/{playlistid}/?nextpage={nextpage}"
# Next Page 
	api : ${PIPEDAPI_URL}/nextpage/{nextpagequery}
# Limitation
	- don't support search in channels

odnar-dev avatar Sep 06 '21 00:09 odnar-dev

All of these should be already documented with the exception of search.

You can find a list of accepted countries at: https://github.com/TeamNewPipe/NewPipeExtractor/blob/4b147863ec44b77a85dfe0a99a010cd10a7f23b4/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java#L202-L209

FireMasterK avatar Sep 06 '21 08:09 FireMasterK

I know I am about a year or so late but is it possible that:

  • Search gets documented on the api documentation
  • The search easily provides the videoId not with "/watch?v=" nonesense

I need this for a python script I am trying to create for searching different platforms and I would like to show comments, for that I need to get the videoId which is harder to get when for some reason "/wach?v=" is in the url value.

trueauracoral avatar Feb 15 '22 01:02 trueauracoral

You can use the following regex to extract the ID: ([a-zA-Z0-9_-]{11})

Python code:

regex = r"([a-zA-Z0-9_-]{11})"

test_str = "/watch?v=qwertyuiopq"

matches = re.finditer(regex, test_str)

FireMasterK avatar Feb 15 '22 01:02 FireMasterK

Are we able to get updated docs for the current state of the API? Many routes such as search are still undocumented.

AbduAmeen avatar Jun 03 '22 18:06 AbduAmeen

You can have a look at https://elements-demo.stoplight.io/?spec=https://raw.githubusercontent.com/TeamPiped/OpenAPI/main/swagger.yaml#/operations/trending, however many routes are still not present. (such as search)

I will take a look at adding it in the near future.

FireMasterK avatar Jun 06 '22 03:06 FireMasterK

I think this addition would be really good for developers.

AbduAmeen avatar Jun 06 '22 04:06 AbduAmeen