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-
12+ CATEGORY_SLUG = "JSON-RPC API Reference"
1313
1414class Action (Enum ):
1515 ADD = 'add'
@@ -18,9 +18,9 @@ class Action(Enum):
1818
1919
2020def getListOfRPCDocs (headers ):
21- response = requests .get (f"{ URL } /categories/{ CATEGORY_SLUG } /docs " , headers = headers )
21+ response = requests .get (f"{ URL } /categories/reference/ { quote ( CATEGORY_SLUG ) } /pages " , headers = headers )
2222 if response .status_code == 200 :
23- return response .json ()
23+ return response .json (). get ( 'data' , [])
2424 else :
2525 return []
2626
@@ -30,28 +30,30 @@ def publishDoc(action, title, body, order, headers):
3030 "title" : title ,
3131 "type" : "basic" ,
3232 "body" : body ,
33- "category" : CATEGORY_ID ,
33+ "category" : {
34+ "id" : CATEGORY_ID
35+ },
3436 "hidden" : False ,
3537 "order" : order ,
3638 }
37- # title == slug
3839 if action == Action .ADD :
3940 # create doc
40- response = requests .post (URL + "/docs" , json = payload , headers = headers )
41+ payload ['slug' ] = title
42+ response = requests .post (URL + "/reference" , json = payload , headers = headers )
4143 if response .status_code != 201 :
4244 print (response .text )
4345 else :
4446 print ("Created " , title )
4547 elif action == Action .UPDATE :
4648 # update doc
47- response = requests .put (f"{ URL } /docs /{ title } " , json = payload , headers = headers )
49+ response = requests .patch (f"{ URL } /reference /{ title } " , json = payload , headers = headers )
4850 if response .status_code != 200 :
4951 print (response .text )
5052 else :
5153 print ("Updated " , title )
5254 elif action == Action .DELETE :
5355 # delete doc
54- response = requests .delete (f"{ URL } /docs /{ title } " , headers = headers )
56+ response = requests .delete (f"{ URL } /reference /{ title } " , headers = headers )
5557 if response .status_code != 204 :
5658 print (response .text )
5759 else :
@@ -79,7 +81,7 @@ def main():
7981 headers = {
8082 "accept" : "application/json" ,
8183 "content-type" : "application/json" ,
82- "authorization " : "Basic " + os .environ .get ("README_API_KEY" ),
84+ "Authorization " : "Bearer " + os .environ .get ("README_API_KEY" ),
8385 }
8486
8587 # path to the rst file from where we fetch all the RPC commands
0 commit comments