Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Documentation #395

Closed
peepo5 opened this issue Aug 29, 2021 · 14 comments
Closed

API Documentation #395

peepo5 opened this issue Aug 29, 2021 · 14 comments
Labels

Comments

@peepo5
Copy link

peepo5 commented Aug 29, 2021

(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.
@FireMasterK
Copy link
Member

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 FireMasterK added the P1 label Sep 2, 2021
@peepo5
Copy link
Author

peepo5 commented Sep 2, 2021

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

@peepo5 peepo5 changed the title API Support API Documentation Sep 2, 2021
@FireMasterK
Copy link
Member

FireMasterK commented Sep 3, 2021

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.

@peepo5
Copy link
Author

peepo5 commented Sep 3, 2021

@FireMasterK

documentatoin

@FireMasterK
Copy link
Member

Whoops, that's fixed now!

@FireMasterK
Copy link
Member

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.

@peepo5
Copy link
Author

peepo5 commented Sep 4, 2021

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

@odnar-dev
Copy link

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

@FireMasterK
Copy link
Member

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

@trueauracoral
Copy link

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.

@FireMasterK
Copy link
Member

FireMasterK commented Feb 15, 2022

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)

@AbduAmeen
Copy link

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

@FireMasterK
Copy link
Member

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.

@AbduAmeen
Copy link

I think this addition would be really good for developers.

@Bnyro Bnyro closed this as completed Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants