{"openapi":"3.1.0","info":{"title":"Petcu.dev reading list API","version":"0.1","description":"An experimental API for personal agents. Send the Poppy-Session and Poppy-Version headers with every request, and an access token as Authorization: Bearer when signed in. Listing articles works signed out. Reading-list operations need the user's account and return a 401 challenge naming the scope they need."},"servers":[{"url":"https://poppy.petcu.dev"}],"paths":{"/api/whoami":{"get":{"operationId":"whoami","summary":"Who the verified session belongs to, and whether it is signed in. Works signed out.","parameters":[{"$ref":"#/components/parameters/PoppyVersion"}],"security":[{"poppySession":[]}],"responses":{"200":{"description":"The session.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WhoAmI"}}}},"400":{"description":"invalid_session, session_ended or version_unsupported.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/articles":{"get":{"operationId":"listArticles","summary":"The published articles that can be saved to a reading list. Works signed out.","parameters":[{"$ref":"#/components/parameters/PoppyVersion"}],"security":[{"poppySession":[]}],"responses":{"200":{"description":"The articles, newest first.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ArticleList"}}}},"400":{"description":"invalid_session, session_ended or version_unsupported.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/reading-list":{"get":{"operationId":"getReadingList","summary":"The articles the signed-in user saved.","parameters":[{"$ref":"#/components/parameters/PoppyVersion"}],"security":[{"poppySession":[],"oauth":["reading-list:read"]}],"responses":{"200":{"description":"The saved articles.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReadingList"}}}},"400":{"description":"invalid_session, session_ended or version_unsupported.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Needs the user's account. WWW-Authenticate names the scope, or says invalid_token."},"403":{"description":"The access token lacks the scope named in WWW-Authenticate (insufficient_scope)."}}}},"/api/reading-list/{slug}":{"put":{"operationId":"saveArticle","summary":"Save an article to the signed-in user's reading list. Safe to repeat.","parameters":[{"$ref":"#/components/parameters/PoppyVersion"},{"name":"slug","in":"path","required":true,"schema":{"type":"string"},"example":"the-era-of-mediocrity"}],"security":[{"poppySession":[],"oauth":["reading-list:write"]}],"responses":{"200":{"description":"Saved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SaveResult"}}}},"400":{"description":"invalid_session, session_ended or version_unsupported.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Needs the user's account. WWW-Authenticate names the scope, or says invalid_token."},"403":{"description":"The access token lacks the scope named in WWW-Authenticate (insufficient_scope)."},"404":{"description":"No such article.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"removeArticle","summary":"Remove an article from the signed-in user's reading list. Safe to repeat.","parameters":[{"$ref":"#/components/parameters/PoppyVersion"},{"name":"slug","in":"path","required":true,"schema":{"type":"string"},"example":"the-era-of-mediocrity"}],"security":[{"poppySession":[],"oauth":["reading-list:write"]}],"responses":{"200":{"description":"Removed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SaveResult"}}}},"400":{"description":"invalid_session, session_ended or version_unsupported.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Needs the user's account. WWW-Authenticate names the scope, or says invalid_token."},"403":{"description":"The access token lacks the scope named in WWW-Authenticate (insufficient_scope)."},"404":{"description":"No such article.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"parameters":{"PoppyVersion":{"name":"Poppy-Version","in":"header","required":true,"schema":{"type":"string"},"example":"1.0"}},"securitySchemes":{"poppySession":{"type":"apiKey","in":"header","name":"Poppy-Session","description":"A Session JWT signed for this one request (spec 5.2)."},"oauth":{"type":"oauth2","flows":{"authorizationCode":{"authorizationUrl":"https://poppy.petcu.dev/oauth/authorize","tokenUrl":"https://poppy.petcu.dev/oauth/token","refreshUrl":"https://poppy.petcu.dev/oauth/token","scopes":{"reading-list:read":"See the articles you saved. Needed to show your reading list. Not needed to list or search articles","reading-list:write":"Add and remove articles on your reading list. Needed for any change to the list. Does not let the agent see the list"}}}}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"string"},"error_description":{"type":"string"}}},"WhoAmI":{"type":"object","properties":{"message":{"type":"string"},"client_id":{"type":"string"},"client_name":{"type":"string"},"user_id":{"type":"string"},"session_id":{"type":"string"},"signed_in":{"type":"boolean"},"scope":{"type":"string"}}},"Article":{"type":"object","properties":{"slug":{"type":"string"},"title":{"type":"string"},"published":{"type":"string","format":"date"},"url":{"type":"string","format":"uri"}}},"ArticleList":{"type":"object","properties":{"articles":{"type":"array","items":{"$ref":"#/components/schemas/Article"}}}},"ReadingList":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Article"}}}},"SaveResult":{"type":"object","properties":{"slug":{"type":"string"},"saved":{"type":"boolean"}}}}}}