11import os
2+ from urllib .parse import quote
23from time import sleep
34import requests
45import re
56from enum import Enum
67
78# readme url
8- URL = "https://dash .readme.com/api/v1 "
9+ URL = "https://api .readme.com/v2/branches/stable "
910# category id for API reference
1011CATEGORY_ID = "685ce4df1df887006ff221c5"
11- CATEGORY_SLUG = "json-rpc-apis "
12+ CATEGORY_SLUG = "JSON-RPC API Reference "
1213
1314
1415class Action (Enum ):
@@ -18,9 +19,9 @@ class Action(Enum):
1819
1920
2021def getListOfRPCDocs (headers ):
21- response = requests .get (f"{ URL } /categories/{ CATEGORY_SLUG } /docs " , headers = headers )
22+ response = requests .get (f"{ URL } /categories/reference/ { quote ( CATEGORY_SLUG ) } /pages " , headers = headers )
2223 if response .status_code == 200 :
23- return response .json ()
24+ return response .json (). get ( 'data' , [])
2425 else :
2526 return []
2627
@@ -30,28 +31,30 @@ def publishDoc(action, title, body, order, headers):
3031 "title" : title ,
3132 "type" : "basic" ,
3233 "body" : body ,
33- "category" : CATEGORY_ID ,
34+ "category" : {
35+ "id" : CATEGORY_ID
36+ },
3437 "hidden" : False ,
3538 "order" : order ,
3639 }
37- # title == slug
3840 if action == Action .ADD :
3941 # create doc
40- response = requests .post (URL + "/docs" , json = payload , headers = headers )
42+ payload ['slug' ] = title
43+ response = requests .post (URL + "/reference" , json = payload , headers = headers )
4144 if response .status_code != 201 :
4245 print (response .text )
4346 else :
4447 print ("Created " , title )
4548 elif action == Action .UPDATE :
4649 # update doc
47- response = requests .put (f"{ URL } /docs /{ title } " , json = payload , headers = headers )
50+ response = requests .patch (f"{ URL } /reference /{ title } " , json = payload , headers = headers )
4851 if response .status_code != 200 :
4952 print (response .text )
5053 else :
5154 print ("Updated " , title )
5255 elif action == Action .DELETE :
5356 # delete doc
54- response = requests .delete (f"{ URL } /docs /{ title } " , headers = headers )
57+ response = requests .delete (f"{ URL } /reference /{ title } " , headers = headers )
5558 if response .status_code != 204 :
5659 print (response .text )
5760 else :
@@ -79,7 +82,7 @@ def main():
7982 headers = {
8083 "accept" : "application/json" ,
8184 "content-type" : "application/json" ,
82- "authorization " : "Basic " + os .environ .get ("README_API_KEY" ),
85+ "Authorization " : "Bearer " + os .environ .get ("README_API_KEY" ),
8386 }
8487
8588 # path to the rst file from where we fetch all the RPC commands
0 commit comments